Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search smoke tests in staging and prod #2062

Merged
merged 3 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions cypress/e2e/smokeTests/sharedTests/basic-enduser.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
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 = '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);
})
Expand Down Expand Up @@ -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('/');
Expand Down Expand Up @@ -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');
Expand All @@ -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) => {
Expand All @@ -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/);
});
});
Expand All @@ -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();
});
});

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
Loading