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

AG-1408: wait for differential expressions boxplot to finish rendering before scrolling to anchor link #1303

Merged
merged 2 commits into from
May 13, 2024
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component, Input, AfterViewInit } from '@angular/core';
import { AfterViewChecked, Component, Input, ViewChild } from '@angular/core';

import {
Gene,
MedianExpression,
RnaDifferentialExpression,
} from '../../../../models';
import { BoxPlotComponent } from '../../../charts/components';
import { GeneService } from '../../services';
import { HelperService } from '../../../../core/services';

Expand All @@ -13,7 +14,7 @@ import { HelperService } from '../../../../core/services';
templateUrl: './gene-evidence-rna.component.html',
styleUrls: ['./gene-evidence-rna.component.scss'],
})
export class GeneEvidenceRnaComponent implements AfterViewInit {
export class GeneEvidenceRnaComponent implements AfterViewChecked {
_gene: Gene | undefined;
get gene(): Gene | undefined {
return this._gene;
Expand All @@ -35,6 +36,9 @@ export class GeneEvidenceRnaComponent implements AfterViewInit {

consistencyOfChangeChartData: any | undefined;

@ViewChild(BoxPlotComponent) boxPlotComponent: BoxPlotComponent | null = null;
hasScrolled = false;

constructor(
private helperService: HelperService,
private geneService: GeneService
Expand All @@ -52,6 +56,8 @@ export class GeneEvidenceRnaComponent implements AfterViewInit {
this.differentialExpressionYAxisMax = undefined;

this.consistencyOfChangeChartData = undefined;

this.hasScrolled = false;
}
sagely1 marked this conversation as resolved.
Show resolved Hide resolved

init() {
Expand All @@ -71,13 +77,20 @@ export class GeneEvidenceRnaComponent implements AfterViewInit {
this.initConsistencyOfChange();
}

ngAfterViewInit() {
const hash = window.location.hash.substr(1);
if (hash) {
const target = document.getElementById(hash);
if (target) {
// TODO determine if there are async calls altering the offset height
window.scrollTo(0, this.helperService.getOffset(target).top - 150);
sagely1 marked this conversation as resolved.
Show resolved Hide resolved
ngAfterViewChecked() {
this.scrollToAnchorLink();
}

sagely1 marked this conversation as resolved.
Show resolved Hide resolved
scrollToAnchorLink() {
// AG-1408 - wait for differential expression box plot to finish loading before scrolling
if (this.boxPlotComponent?.isInitialized && !this.hasScrolled) {
const hash = window.location.hash.slice(1);
if (hash) {
const target = document.getElementById(hash);
if (target) {
window.scrollTo(0, this.helperService.getOffset(target).top - 150);
this.hasScrolled = true;
}
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions tests/gene-comparison-tool.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test';
import { waitForSpinnerNotVisible } from './helpers/utils';

test.describe('specific viewport block', () => {
test.slow();
Expand All @@ -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});
sagely1 marked this conversation as resolved.
Show resolved Hide resolved
await waitForSpinnerNotVisible(page);

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle('Gene Comparison | Visual comparison tool for AD genes');
Expand All @@ -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');
Expand Down
12 changes: 12 additions & 0 deletions tests/gene-details.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test';
import { waitForSpinnerNotVisible } from './helpers/utils';

test.describe('specific viewport block', () => {
test.slow();
Expand All @@ -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();
});
});
7 changes: 3 additions & 4 deletions tests/gene-resources.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test';
import { waitForSpinnerNotVisible } from './helpers/utils';

test.describe('specific viewport block', () => {
test.slow();
Expand All @@ -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');
Expand All @@ -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' });
Expand Down
7 changes: 7 additions & 0 deletions tests/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -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 });
};
Loading