Skip to content

Commit

Permalink
add tests, fix view public and trs link (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
NatalieEO authored Jan 25, 2022
1 parent 3e14769 commit 77a7914
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 7 deletions.
153 changes: 153 additions & 0 deletions cypress/integration/group2/githubAppTools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import { goToTab, insertAppTools, isActiveTab, resetDB, setTokenUserViewPort, typeInInput } from '../../support/commands';
import { LambdaEvent } from '../../../src/app/shared/swagger';

describe('GitHub App Tools', () => {
resetDB();
insertAppTools();
setTokenUserViewPort();

function selectUnpublishedTab(org: string) {
cy.get('#tool-path').should('be.visible');
cy.get('mat-panel-title')
.contains(org)
.parentsUntil('mat-accordion')
.should('be.visible')
.contains('.mat-tab-label-content', 'Unpublished')
.should('be.visible')
.click();
}

function selectUnpublishedGitHubAppTab(org: string) {
cy.get('#workflow-path').should('be.visible');
cy.get('mat-panel-title')
.contains(org)
.parentsUntil('mat-accordion')
.should('be.visible')
.contains('.mat-tab-label-content', 'Unpublished')
.click();
}

function selectGitHubAppTool(tool: string) {
cy.get('#workflow-path').should('be.visible');
cy.contains('div .no-wrap', tool).should('be.visible').click();
cy.get('#workflow-path').contains(tool);
}

describe('My Tools', () => {
it('Side Bar', () => {
cy.visit('/my-tools');

// Registration
cy.get('#register_tool_button').click();
cy.contains('Register using GitHub Apps');
cy.get('#3-register-workflow-option').click();
cy.contains('Install our GitHub App on your');
cy.get('.modal-footer').contains('Next').first().click();
cy.contains('Navigate to GitHub to install our GitHub app');
cy.contains('Tool storage type').click();
cy.contains('Close').click();

// GitHub App Logs
cy.contains('See GitHub Apps Logs').click();
cy.contains('There were problems retrieving GitHub App logs for this organization.');
cy.contains('Close').click();
cy.server();
cy.route({
method: 'GET',
url: '/api/lambdaEvents/**',
response: [],
}).as('lambdaEvents');
cy.contains('See GitHub Apps Logs').click();
cy.contains('There are no GitHub App logs for this organization.');
cy.contains('Close').click();

const realResponse: LambdaEvent[] = [
{
eventDate: 1582165220000,
githubUsername: 'testUser',
id: 1,
message: 'HTTP 418 ',
organization: 'C',
reference: 'refs/head/main',
repository: 'test-github-app-tools',
success: true,
type: 'PUSH',
},
];
cy.route({
method: 'GET',
url: '/api/lambdaEvents/**',
response: realResponse,
}).as('lambdaEvents');
cy.contains('See GitHub Apps Logs').click();
cy.contains('1 – 1 of 1');
cy.contains('Close').click();
});

it('GitHub Tool Private View', () => {
selectGitHubAppTool('test-github-app-tools/testing');
cy.get('#publishButton').should('not.be.disabled');
cy.get('#publishButton').contains('Unpublish');
cy.get('[data-cy=viewPublicWorkflowButton]').should('not.be.disabled');
cy.get('[data-cy=refreshButton]').should('not.exist');

goToTab('Info');
isActiveTab('Info');

// Add tests once fixed.
goToTab('Launch');
isActiveTab('Launch');

goToTab('Versions');
isActiveTab('Versions');
cy.get('table>tbody>tr').should('have.length', 1);
cy.contains('button', 'Actions').should('be.visible').click();
cy.contains('button', 'Refresh Version').should('be.disabled');

// Fix hiding a version. You have to refresh the page to see that it was hidden in the table
cy.contains('Edit').click();
cy.get('[data-cy=hiddenLabel]').click();
cy.get('[data-cy=save-version]').click();
// cy.get('[data-cy=valid').should('exist');

goToTab('Files');
isActiveTab('Files');
cy.contains('tools/Dockstore.cwl');
cy.contains('class: CommandLineTool');
goToTab('Configuration');
cy.contains('Configuration');
cy.contains('/.dockstore.yml');

selectUnpublishedGitHubAppTab('github.com/C');
selectGitHubAppTool('test-github-app-tools/md5sum');
cy.get('#publishButton').should('not.be.disabled');
cy.get('[data-cy=viewPublicWorkflowButton]').should('not.exist');
cy.get('#publishButton').contains('Publish').click();
cy.contains('Default Version Required');
cy.contains('button', 'OK').click();
goToTab('Versions');
cy.contains('button', 'Actions').should('be.visible').click();
cy.contains('button', 'Set as').click();
cy.get('#publishButton').should('not.be.disabled');
cy.get('#publishButton').contains('Publish').click();

// Fix that the entry list on the left doesn't update without refreshing the page
// selectGitHubAppTool('test-github-app-tools/testing');
});

it('Public view', () => {
cy.get('[data-cy=viewPublicWorkflowButton]').click();
cy.get('[data-cy=tool-icon]').should('exist');
cy.contains('Tool Information');
cy.contains('Tool Version Information');
cy.get('[data-cy=workflowTitle]').contains('github.com/C/test-github-app-tools/md5sum:invalidTool');
goToTab('Versions');
cy.contains('main').click();
cy.get('[data-cy=workflowTitle]').contains('github.com/C/test-github-app-tools/md5sum:main');
cy.get('#starringButton').click();
cy.get('#starCountButton').should('contain', '1');
goToTab('Info');
cy.get('[data-cy=trs-link]').contains('TRS: github.com/C/test-github-app-tools/md5sum');
});
});
});
6 changes: 6 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export function resetDB() {
});
}

export function insertAppTools() {
before(() => {
cy.exec(psqlInvocation + ' -h localhost webservice_test -U dockstore < test/github_app_tool_db_dump.sql');
});
}

export function typeInInput(fieldName: string, text: string) {
cy.contains('span', fieldName).parentsUntil('.mat-form-field-wrapper').find('input').first().should('be.visible').clear().type(text);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/container/container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class ContainerComponent extends Entry implements AfterViewInit, OnInit {
}

public setupPublicEntry(url: String) {
if (url.includes('/containers/github.com')) {
if (url.includes('/containers/github.com') || url.includes('/tools/github.com')) {
this.containerService.setTool(null);
this.displayAppTool = true;
} else if (url.includes('containers') || url.includes('tools')) {
Expand Down
7 changes: 5 additions & 2 deletions src/app/workflow/info-tab/info-tab.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@
<strong matTooltip="The source code for this workflow is stored on Dockstore.org">Source Code</strong>:
<i>The source code for this workflow is stored on Dockstore.org</i>
</li>
<li *ngIf="isPublic && isValidVersion">
<li *ngIf="isPublic && isValidVersion" data-cy="trs-link">
<strong matTooltip="TRS link to the main descriptor for the selected workflow version">TRS</strong>:
<a [href]="trsLink"> #{{ entryType$ | async }}/{{ workflow?.full_workflow_path }}</a>
<a [href]="trsLink" *ngIf="(entryType$ | async) === EntryType.BioWorkflow || (entryType$ | async) === EntryType.Service">
#{{ entryType$ | async }}/{{ workflow?.full_workflow_path }}</a
>
<a [href]="trsLink" *ngIf="(entryType$ | async) === EntryType.Tool"> {{ workflow?.full_workflow_path }}</a>
<button mat-icon-button color="secondary" matTooltip="Copy TRS ID" [cdkCopyToClipboard]="displayTextForButton" appSnackbar>
<mat-icon class="mat-icon-copy-button">file_copy</mat-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ <h4 mat-dialog-title>
</div>
<div class="col-sm-9 col-md-9 col-lg-9 col-sm-offset-3"></div>
<div class="form-group form-group-sm" *ngIf="!isPublic" style="clear: both">
<label class="col-sm-3 col-md-3 col-lg-3 control-label"> Hidden: </label>
<label class="col-sm-3 col-md-3 col-lg-3 control-label" data-cy="hiddenLabel"> Hidden: </label>
<div class="col-sm-9 col-md-9 col-lg-9">
<div>
<label>
Expand Down
2 changes: 1 addition & 1 deletion src/app/workflow/versions/versions.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
Valid
</th>
<td mat-cell *matCellDef="let version">
<mat-icon *ngIf="version.valid">check</mat-icon>
<mat-icon *ngIf="version.valid" data-cy="valid">check</mat-icon>
</td>
</ng-container>

Expand Down
4 changes: 2 additions & 2 deletions src/app/workflow/workflow.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ <h2 class="text-center">The workflow linked to could not be found!</h2>
<ngx-json-ld [json]="schema"></ngx-json-ld>
<div fxFlex="80">
<h3 id="workflow-path" data-cy="workflowTitle" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="1rem">
<span *ngIf="entryType === EntryType.BioWorkflow || entryType === EntryType.Service">
<span *ngIf="entryType === EntryType.BioWorkflow || entryType === EntryType.Service" data-cy="workflow-icon">
<img src="../../assets/svg/workflow-circle.svg" alt="workflow icon" />
</span>
<span *ngIf="entryType === EntryType.AppTool">
<span *ngIf="entryType === EntryType.Tool" data-cy="tool-icon">
<img src="../../assets/svg/tool-circle.svg" alt="tool icon" />
</span>
<span fxLayout.lt-sm="column" style="word-break: break-word">
Expand Down
Loading

0 comments on commit 77a7914

Please sign in to comment.