From 77a7914ecd76475caa9f9e21c1ee76b54a8bc8d4 Mon Sep 17 00:00:00 2001 From: NatalieEO Date: Tue, 25 Jan 2022 12:54:41 -0800 Subject: [PATCH] add tests, fix view public and trs link (#1433) Add some tests https://ucsc-cgl.atlassian.net/browse/SEAB-3733 icon: https://ucsc-cgl.atlassian.net/browse/SEAB-3827 fix redirect: https://ucsc-cgl.atlassian.net/browse/SEAB-3825 trs link: https://ucsc-cgl.atlassian.net/browse/SEAB-3828e --- cypress/integration/group2/githubAppTools.ts | 153 ++++++++++++++ cypress/support/commands.ts | 6 + src/app/container/container.component.ts | 2 +- .../workflow/info-tab/info-tab.component.html | 7 +- .../version-modal.component.html | 2 +- .../workflow/versions/versions.component.html | 2 +- src/app/workflow/workflow.component.html | 4 +- test/github_app_tool_db_dump.sql | 198 ++++++++++++++++++ 8 files changed, 367 insertions(+), 7 deletions(-) create mode 100644 cypress/integration/group2/githubAppTools.ts create mode 100644 test/github_app_tool_db_dump.sql diff --git a/cypress/integration/group2/githubAppTools.ts b/cypress/integration/group2/githubAppTools.ts new file mode 100644 index 0000000000..d9d031f8cd --- /dev/null +++ b/cypress/integration/group2/githubAppTools.ts @@ -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'); + }); + }); +}); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 788c215e64..c50864dfc1 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -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); } diff --git a/src/app/container/container.component.ts b/src/app/container/container.component.ts index 1907e0a01b..68d13aaa12 100644 --- a/src/app/container/container.component.ts +++ b/src/app/container/container.component.ts @@ -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')) { diff --git a/src/app/workflow/info-tab/info-tab.component.html b/src/app/workflow/info-tab/info-tab.component.html index c143acd9fd..502f613853 100644 --- a/src/app/workflow/info-tab/info-tab.component.html +++ b/src/app/workflow/info-tab/info-tab.component.html @@ -55,9 +55,12 @@ Source Code: The source code for this workflow is stored on Dockstore.org -
  • +
  • TRS: - #{{ entryType$ | async }}/{{ workflow?.full_workflow_path }} + + #{{ entryType$ | async }}/{{ workflow?.full_workflow_path }} + {{ workflow?.full_workflow_path }} diff --git a/src/app/workflow/version-modal/version-modal.component.html b/src/app/workflow/version-modal/version-modal.component.html index 1c0c0354fb..f676da00b4 100644 --- a/src/app/workflow/version-modal/version-modal.component.html +++ b/src/app/workflow/version-modal/version-modal.component.html @@ -170,7 +170,7 @@

    - +