From e203798657f0868b53d5feadf77aa166de81e8c2 Mon Sep 17 00:00:00 2001 From: sagely1 <114952739+sagely1@users.noreply.github.com> Date: Mon, 13 May 2024 09:04:52 -0700 Subject: [PATCH 1/3] AG-1409 fix sort bug when switching categories --- .../gene-comparison-tool.component.ts | 1 + tests/gene-comparison-tool.spec.ts | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/app/features/genes/components/gene-comparison-tool/gene-comparison-tool.component.ts b/src/app/features/genes/components/gene-comparison-tool/gene-comparison-tool.component.ts index d538b0dc..83d8aed6 100644 --- a/src/app/features/genes/components/gene-comparison-tool/gene-comparison-tool.component.ts +++ b/src/app/features/genes/components/gene-comparison-tool/gene-comparison-tool.component.ts @@ -360,6 +360,7 @@ export class GeneComparisonToolComponent implements OnInit, AVI, OnDestroy { if (!this.sortField || !this.columns.includes(this.sortField)) { this.sortField = this.columns[0]; + this.sortOrder = -1; } const preSelection = this.helperService.getGCTSelection(); diff --git a/tests/gene-comparison-tool.spec.ts b/tests/gene-comparison-tool.spec.ts index f203600a..db664d56 100644 --- a/tests/gene-comparison-tool.spec.ts +++ b/tests/gene-comparison-tool.spec.ts @@ -27,4 +27,41 @@ test.describe('specific viewport block', () => { const dropdown = page.locator('#subCategory'); await expect(dropdown).toHaveText('Targeted Selected Reaction Monitoring (SRM)'); }); + + test('switching from RNA to Protein with RNA-specific column ordering reverts back to Risk Score descending', async ({ page }) => { + // set category for Protein - Differential Expression + await page.goto('/genes/comparison?sortField=FP&sortOrder=1'); + + // wait for page to load (i.e. spinner to disappear) + await expect(page.locator('div:nth-child(4) > div > .spinner')) + .not.toBeVisible({ timeout: 150000}); + + // Gene Comparison Overview tutorial modal + const tutorialModal = page.getByText('Gene Comparison Overview'); + await expect(tutorialModal).toBeVisible({ timeout: 10000}); + + // close the Gene Comparison Overview tutorial modal + const closeButton = page.locator('.p-dialog-header-close-icon'); + await closeButton.click(); + + // Gene Comparison Overview tutorial modal + await expect(tutorialModal).not.toBeVisible({ timeout: 10000}); + + // sort by FP ascending + const FPColumn = page.getByText('FP'); + // first click sorts descending + await FPColumn.click(); + // second click sorts ascending + await FPColumn.click(); + + // expect url to be correct + expect(page.url()).toBe('http://localhost:8080/genes/comparison?sortField=FP&sortOrder=1'); + + // change category to Protein + await page.locator('p-dropdown').filter({ hasText: 'RNA - Differential Expression' }).getByLabel('dropdown trigger').click(); + await page.getByText('Protein - Differential Expression').click(); + + // expect url to be correct + expect(page.url()).toBe('http://localhost:8080/genes/comparison?category=Protein+-+Differential+Expression'); + }); }); From 22435d51e7874476daa23bd148272233a0129f80 Mon Sep 17 00:00:00 2001 From: sagely1 <114952739+sagely1@users.noreply.github.com> Date: Mon, 13 May 2024 15:20:44 -0700 Subject: [PATCH 2/3] AG-1409 adding addition assertion to check for sort direction --- tests/gene-comparison-tool.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/gene-comparison-tool.spec.ts b/tests/gene-comparison-tool.spec.ts index db664d56..ccd55c1c 100644 --- a/tests/gene-comparison-tool.spec.ts +++ b/tests/gene-comparison-tool.spec.ts @@ -63,5 +63,10 @@ test.describe('specific viewport block', () => { // expect url to be correct expect(page.url()).toBe('http://localhost:8080/genes/comparison?category=Protein+-+Differential+Expression'); + + // expect sort arrow to be descending + await expect( + page.getByRole('columnheader', { name: 'RISK SCORE' }).locator('i') + ).toHaveClass(/pi-sort-amount-down/); }); }); From 881bd286cb29579993b26281348af0d7a781af99 Mon Sep 17 00:00:00 2001 From: sagely1 <114952739+sagely1@users.noreply.github.com> Date: Tue, 14 May 2024 13:00:09 -0700 Subject: [PATCH 3/3] AG-1409 refactor to use new helper methods --- tests/gene-comparison-tool.spec.ts | 37 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tests/gene-comparison-tool.spec.ts b/tests/gene-comparison-tool.spec.ts index a71b2b1e..571c8702 100644 --- a/tests/gene-comparison-tool.spec.ts +++ b/tests/gene-comparison-tool.spec.ts @@ -1,27 +1,33 @@ import { test, expect } from '@playwright/test'; -import { URL_GCT_PROTEIN } from './helpers/constants'; +import { GCT_CATEGORIES, URL_GCT_PROTEIN } from './helpers/constants'; import { waitForSpinnerNotVisible } from './helpers/utils'; +import { baseURL } from '../playwright.config'; +import { changeGctCategory, closeGctHelpDialog } from './helpers/gct'; + +const URL_GCT = '/genes/comparison'; +const URL_RNA = '/genes/comparison?'; +const URL_PROTEIN = '/genes/comparison?category=Protein+-+Differential+Expression'; test.describe('specific viewport block', () => { test.slow(); test.use({ viewport: { width: 1600, height: 1200 } }); test('has title', async ({ page }) => { - await page.goto(URL_GCT_PROTEIN); + await page.goto(`${ URL_GCT }`); // wait for page to load (i.e. spinner to disappear) - await waitForSpinnerNotVisible(page, 250000); + await waitForSpinnerNotVisible(page, 250_000); // Expect a title "to contain" a substring. await expect(page).toHaveTitle('Gene Comparison | Visual comparison tool for AD genes'); }); - test('sub-category is SRM by default', async ({ page }) => { + test('protein has sub-category of SRM by default', async ({ page }) => { // set category for Protein - Differential Expression await page.goto(URL_GCT_PROTEIN); // wait for page to load (i.e. spinner to disappear) - await waitForSpinnerNotVisible(page, 150000); + await waitForSpinnerNotVisible(page, 150_000); // expect sub-category dropdown to be SRM const dropdown = page.locator('#subCategory'); @@ -29,23 +35,21 @@ test.describe('specific viewport block', () => { }); test('switching from RNA to Protein with RNA-specific column ordering reverts back to Risk Score descending', async ({ page }) => { - // set category for Protein - Differential Expression - await page.goto('/genes/comparison?sortField=FP&sortOrder=1'); + // set category to RNA + await page.goto(`${ URL_RNA }`); // 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, 150_000); // Gene Comparison Overview tutorial modal const tutorialModal = page.getByText('Gene Comparison Overview'); - await expect(tutorialModal).toBeVisible({ timeout: 10000}); + await expect(tutorialModal).toBeVisible({ timeout: 10_000}); // close the Gene Comparison Overview tutorial modal - const closeButton = page.locator('.p-dialog-header-close-icon'); - await closeButton.click(); + await closeGctHelpDialog(page); // Gene Comparison Overview tutorial modal - await expect(tutorialModal).not.toBeVisible({ timeout: 10000}); + await expect(tutorialModal).not.toBeVisible({ timeout: 10_000}); // sort by FP ascending const FPColumn = page.getByText('FP'); @@ -55,14 +59,13 @@ test.describe('specific viewport block', () => { await FPColumn.click(); // expect url to be correct - expect(page.url()).toBe('http://localhost:8080/genes/comparison?sortField=FP&sortOrder=1'); + expect(page.url()).toBe(`${ baseURL }${ URL_RNA }sortField=FP&sortOrder=1`); // change category to Protein - await page.locator('p-dropdown').filter({ hasText: 'RNA - Differential Expression' }).getByLabel('dropdown trigger').click(); - await page.getByText('Protein - Differential Expression').click(); + await changeGctCategory(page, GCT_CATEGORIES.RNA, GCT_CATEGORIES.PROTEIN); // expect url to be correct - expect(page.url()).toBe('http://localhost:8080/genes/comparison?category=Protein+-+Differential+Expression'); + expect(page.url()).toBe(`${ baseURL }${ URL_PROTEIN }`); // expect sort arrow to be descending await expect(