diff --git a/cypress/e2e/smokeTests/sharedTests/basic-enduser.ts b/cypress/e2e/smokeTests/sharedTests/basic-enduser.ts index 5cd4dbc4f..6220f01a4 100644 --- a/cypress/e2e/smokeTests/sharedTests/basic-enduser.ts +++ b/cypress/e2e/smokeTests/sharedTests/basic-enduser.ts @@ -1,6 +1,6 @@ import { ga4ghPath } from '../../../../src/app/shared/constants'; import { ToolDescriptor } from '../../../../src/app/shared/openapi'; -import { goToTab, checkFeaturedContent, checkNewsAndUpdates, checkMastodonFeed } from '../../../support/commands'; +import { goToTab, checkFeaturedContent, checkNewsAndUpdates, checkMastodonFeed, isStagingOrProd } from '../../../support/commands'; // Test an entry, these should be ambiguous between tools, workflows, and notebooks. describe('run stochastic smoke test', () => { @@ -8,14 +8,34 @@ describe('run stochastic smoke test', () => { testEntry('Workflows'); testEntry('Notebooks'); }); + +// TODO: set to only 'entryColumn' when search cards are deployed to staging and prod +function getSearchDataCy(tab: string = 'Workflows') { + return isStagingOrProd() ? getLinkName(tab) : 'entryColumn'; +} + +function getLinkName(tab: string): string { + switch (tab) { + case 'Tools': + return 'toolNames'; + case 'Workflows': + return 'workflowColumn'; + case 'Notebooks': + return 'notebookColumn'; + default: + throw new Error('unknown tab'); + } +} + function testEntry(tab: string) { function goToRandomEntry() { cy.visit('/search'); - cy.get('[data-cy=entryColumn] a'); + // Get a workflow in the table results to make sure things are loaded. + cy.get(`[data-cy=${getSearchDataCy()}] a`); goToTab(tab); // select a random entry on the first page and navigate to it let chosen_index = 0; - cy.get('[data-cy=entryColumn]') + cy.get(`[data-cy=${getSearchDataCy(tab)}]`) .then(($list) => { chosen_index = Math.floor(Math.random() * $list.length); }) @@ -54,11 +74,6 @@ function testEntry(tab: string) { }); } -function isStagingOrProd() { - const baseUrl = Cypress.config('baseUrl'); - return baseUrl === 'https://staging.dockstore.org' || baseUrl === 'https://dockstore.org'; -} - describe('Check organizations page', () => { it('has multiple organizations and org with content', () => { cy.visit('/'); @@ -90,7 +105,7 @@ describe('Test logged out home page', () => { describe('Test search page functionality', () => { it('displays tools', () => { cy.visit('/search'); - cy.get('[data-cy=entryColumn]').should('have.length.of.at.least', 1); + cy.get(`[data-cy=${getSearchDataCy()}]`).should('have.length.of.at.least', 1); }); it('has working tag cloud', () => { cy.visit('/search'); @@ -109,7 +124,7 @@ describe('Test search page functionality', () => { cy.visit('/search'); cy.wait(2500); // Wait less than ideal, facets keep getting rerendered is the problem cy.contains('mat-checkbox', 'Nextflow').click(); - cy.get('[data-cy=entryColumn] a'); + cy.get(`[data-cy=${getSearchDataCy()}] a`); cy.wait(2500); // Wait less than ideal, facets keep getting rerendered is the problem cy.contains('mat-checkbox', 'Nextflow'); // wait for the checkbox to reappear, indicating the filtering is almost complete cy.get('[data-cy=descriptorType]').each(($el, index, $list) => { @@ -125,7 +140,7 @@ describe('Test search page functionality', () => { cy.visit('/search'); cy.contains('mat-checkbox', /^[ ]*verified/).click(); cy.url().should('contain', 'verified=1'); - cy.get('[data-cy=entryColumn] a'); + cy.get(`[data-cy=${getSearchDataCy()}] a`); cy.contains('mat-checkbox', /^[ ]*verified/); }); }); @@ -134,11 +149,11 @@ describe('Test workflow page functionality', () => { it('find a WDL workflow', () => { cy.visit('/search'); cy.contains('.mat-tab-label', 'Workflows'); - cy.get('[data-cy=entryColumn]').should('have.length.of.at.least', 1); + cy.get(`[data-cy=${getSearchDataCy()}]`).should('have.length.of.at.least', 1); // Use facet to find WDL workflow cy.contains('mat-checkbox', 'WDL').click(); - cy.get('[data-cy=entryColumn] a').first().click(); + cy.get(`[data-cy=${getSearchDataCy()}] a`).first().click(); }); }); diff --git a/cypress/e2e/smokeTests/sharedTests/search.ts b/cypress/e2e/smokeTests/sharedTests/search.ts index 9d8b4aea9..43ed11591 100644 --- a/cypress/e2e/smokeTests/sharedTests/search.ts +++ b/cypress/e2e/smokeTests/sharedTests/search.ts @@ -1,3 +1,5 @@ +import { isStagingOrProd } from '../../../support/commands'; + describe('Admin UI', () => { before(() => { cy.visit(''); @@ -25,15 +27,19 @@ describe('Admin UI', () => { cy.url().should('not.include', 'search=dhockstore'); cy.contains('Items per page'); - cy.get('[data-cy=search-entry-table-paginator]').within(() => { + // TODO: set to '[data-cy=search-entry-table-paginator]' when search cards are in staging and prod + const searchPaginatorDataCy = isStagingOrProd() + ? '[data-cy=search-workflow-table-paginator]' + : '[data-cy=search-entry-table-paginator]'; + cy.get(searchPaginatorDataCy).within(() => { cy.get('.mat-paginator-range-label').contains('10 of'); }); - cy.get('[data-cy=search-entry-table-paginator]').contains(10).should('be.visible').click(); + cy.get(searchPaginatorDataCy).contains(10).should('be.visible').click(); cy.get('mat-option').contains(20).click(); - cy.get('[data-cy=search-entry-table-paginator]').contains(20); + cy.get(searchPaginatorDataCy).contains(20); cy.get('a').contains('Organizations').click(); cy.go('back'); - cy.get('[data-cy=search-entry-table-paginator]').contains(20); + cy.get(searchPaginatorDataCy).contains(20); cy.get('[data-cy=basic-search]').type('dockstore_{enter}'); cy.contains('Open Advanced Search').click(); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index afd66d01d..7844195cd 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -18,6 +18,11 @@ // const psqlInvocation: string = 'PASSWORD=dockstore docker exec -i postgres1 psql'; const psqlInvocation: string = 'PASSWORD=dockstore psql'; +export function isStagingOrProd() { + const baseUrl = Cypress.config('baseUrl'); + return baseUrl === 'https://staging.dockstore.org' || baseUrl === 'https://dockstore.org'; +} + export function goToTab(tabName: string): void { // cypress tests run asynchronously, so if the DOM changes and an element-of-interest becomes detached while we're manipulating it, the test will fail. // our current (admittedly primitive) go-to solution is to wait (sleep) for long enough that the DOM "settles", thus avoiding the "detached element" bug.