From 23f53ab150fe61496d0eaa3c4d5ac26ece4254b5 Mon Sep 17 00:00:00 2001 From: Hallie Swan <26949006+hallieswan@users.noreply.github.com> Date: Fri, 26 Apr 2024 12:21:44 -0700 Subject: [PATCH] AG-1408: add e2e test --- tests/gene-comparison-tool.spec.ts | 7 +++---- tests/gene-details.spec.ts | 12 ++++++++++++ tests/gene-resources.spec.ts | 7 +++---- tests/helpers/utils.ts | 7 +++++++ 4 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 tests/helpers/utils.ts diff --git a/tests/gene-comparison-tool.spec.ts b/tests/gene-comparison-tool.spec.ts index f203600a..9a3f12c5 100644 --- a/tests/gene-comparison-tool.spec.ts +++ b/tests/gene-comparison-tool.spec.ts @@ -1,4 +1,5 @@ import { test, expect } from '@playwright/test'; +import { waitForSpinnerNotVisible } from './helpers/utils'; test.describe('specific viewport block', () => { test.slow(); @@ -8,8 +9,7 @@ test.describe('specific viewport block', () => { await page.goto('/genes/comparison?category=Protein+-+Differential+Expression'); // wait for page to load (i.e. spinner to disappear) - await expect(page.locator('div:nth-child(4) > div > .spinner')) - .not.toBeVisible({ timeout: 250000}); + await waitForSpinnerNotVisible(page); // Expect a title "to contain" a substring. await expect(page).toHaveTitle('Gene Comparison | Visual comparison tool for AD genes'); @@ -20,8 +20,7 @@ test.describe('specific viewport block', () => { await page.goto('/genes/comparison?category=Protein+-+Differential+Expression'); // wait for page to load (i.e. spinner to disappear) - await expect(page.locator('div:nth-child(4) > div > .spinner')) - .not.toBeVisible({ timeout: 150000}); + await waitForSpinnerNotVisible(page, 150000); // expect sub-category dropdown to be SRM const dropdown = page.locator('#subCategory'); diff --git a/tests/gene-details.spec.ts b/tests/gene-details.spec.ts index 31883aac..6e7258a4 100644 --- a/tests/gene-details.spec.ts +++ b/tests/gene-details.spec.ts @@ -1,4 +1,5 @@ import { test, expect } from '@playwright/test'; +import { waitForSpinnerNotVisible } from './helpers/utils'; test.describe('specific viewport block', () => { test.slow(); @@ -14,4 +15,15 @@ test.describe('specific viewport block', () => { // expect div for page not found content to be visible expect(page.locator('.page-not-found')).toBeVisible(); }); + + test('consistency of change section heading is visible when using anchor link', async ({ page}) => { + await page.goto( + '/genes/ENSG00000178209/evidence/rna?model=AD Diagnosis males and females#consistency-of-change' + ); + + await waitForSpinnerNotVisible(page); + + const header = page.getByRole('heading', { name: 'Consistency of Change in Expression'}); + expect(header).toBeInViewport(); + }); }); \ No newline at end of file diff --git a/tests/gene-resources.spec.ts b/tests/gene-resources.spec.ts index f109b1d8..ff9b63bb 100644 --- a/tests/gene-resources.spec.ts +++ b/tests/gene-resources.spec.ts @@ -1,4 +1,5 @@ import { test, expect } from '@playwright/test'; +import { waitForSpinnerNotVisible } from './helpers/utils'; test.describe('specific viewport block', () => { test.slow(); @@ -8,8 +9,7 @@ test.describe('specific viewport block', () => { await page.goto('/genes/ENSG00000178209/resources'); // wait for page to load (i.e. spinner to disappear) - await expect(page.locator('div:nth-child(4) > div > .spinner')) - .not.toBeVisible({ timeout: 250000}); + await waitForSpinnerNotVisible(page); // Expect a title "to contain" a substring. await expect(page).toHaveTitle('Agora'); @@ -20,8 +20,7 @@ test.describe('specific viewport block', () => { await page.goto('/genes/ENSG00000178209/resources'); // wait for page to load (i.e. spinner to disappear) - await expect(page.locator('div:nth-child(4) > div > .spinner')) - .not.toBeVisible({ timeout: 150000}); + await waitForSpinnerNotVisible(page, 150000); // expect link named 'Visit AMP-PD' const link = page.getByRole('link', { name: 'Visit AMP-PD' }); diff --git a/tests/helpers/utils.ts b/tests/helpers/utils.ts new file mode 100644 index 00000000..e6d122f3 --- /dev/null +++ b/tests/helpers/utils.ts @@ -0,0 +1,7 @@ +import { Page, expect } from '@playwright/test'; + +export const waitForSpinnerNotVisible = async (page: Page, timeout = 250000) => { + await expect( + page.locator('div:nth-child(4) > div > .spinner') + ).not.toBeVisible({ timeout: timeout }); +};