Skip to content

Commit

Permalink
Put back staging/prod search test elements
Browse files Browse the repository at this point in the history
  • Loading branch information
kathy-t committed Feb 13, 2025
1 parent 1959db4 commit c016ca4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
40 changes: 27 additions & 13 deletions cypress/e2e/smokeTests/sharedTests/basic-enduser.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
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', () => {
testEntry('Tools');
testEntry('Workflows');
testEntry('Notebooks');
});

// TODO: set to only 'entryColumn' when search cards are deployed to staging and prod
function getSearchDataCy(tab: string = 'Workflow') {
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');
cy.get(`[data-cy=${getSearchDataCy(tab)}] 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);
})
Expand Down Expand Up @@ -54,11 +73,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('/');
Expand Down Expand Up @@ -90,7 +104,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');
Expand All @@ -109,7 +123,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) => {
Expand All @@ -125,7 +139,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/);
});
});
Expand All @@ -134,11 +148,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();
});
});

Expand Down
14 changes: 10 additions & 4 deletions cypress/e2e/smokeTests/sharedTests/search.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isStagingOrProd } from '../../../support/commands';

describe('Admin UI', () => {
before(() => {
cy.visit('');
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c016ca4

Please sign in to comment.