Skip to content

Commit 2181154

Browse files
feat: abort slow requests when testing with playwright (#2542)
* feat: abort slow requests when testing with playwright * fix: override default behavior in campaign test to load data from api. * feat: New test use test fixture * chore: swithc to using a non relative import * fix: increase timeout of auth setup * fix: remove @ from test imports * feat: mock everything related to user auth instead of logging in * chore: break out some duplicated code * chore: add default data option to function * chore: bump up timeout for now for auth test * feat: use other fixture as base * fix: add mission override to other campaign test * chore: split up network aborts in tests * fix: mission_list not getting caught * fix: allow localhost requests to go though * fix: Increase timeout in expects to 30s * fix: Add back js and css --------- Co-authored-by: tcchase <[email protected]>
1 parent 7190711 commit 2181154

55 files changed

Lines changed: 207 additions & 77 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

e2e/auth.setup.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,37 @@ import dotenv from 'dotenv';
33
import { overrideUserCookieHeaders } from 'e2e/helpers';
44

55
async function globalSetup() {
6-
// const { baseURL } = config.projects[0].use;
76
const browser = await chromium.launch();
87
const page = await browser.newPage();
98
console.log('Running auth setup function');
109
dotenv.config({ quiet: true });
1110

1211
await page.goto('https://search.asf.alaska.edu');
13-
const popupPromise = page.waitForEvent('popup');
12+
1413
if (!process.env['PLAYWRIGHT_USERNAME']) {
1514
console.log('No credentials defined: Some tests may fail');
1615
return;
1716
}
17+
1818
console.log('Signing in');
19+
const popupPromise = page.waitForEvent('popup');
1920
await page.getByRole('button', { name: 'Sign In' }).click();
2021
const popup = await popupPromise;
22+
2123
await popup.getByLabel('username').fill(process.env['PLAYWRIGHT_USERNAME']);
2224
await popup.getByLabel('password').fill(process.env['PLAYWRIGHT_PASSWORD']);
2325
await overrideUserCookieHeaders(page);
24-
await popup.getByRole('button', { name: 'Log in' }).click();
25-
await expect(page.getByRole('button', { name: 'Sign In' })).toHaveCount(0);
26+
27+
await popup
28+
.getByRole('button', { name: 'Log in' })
29+
.click({ timeout: 10_000 });
30+
31+
await popup.waitForEvent('close', { timeout: 15_000 });
32+
33+
await expect(page.getByRole('button', { name: 'Sign In' })).toHaveCount(0, {
34+
timeout: 15_000,
35+
});
36+
2637
console.log('Sign in successful');
2738
await page.context().storageState({ path: 'playwright/.auth/user.json' });
2839
await browser.close();

e2e/baseline/download.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22

33
test('Add files to Download Queue', async ({ page }) => {
44
await page.goto('/');
@@ -21,15 +21,19 @@ test('Add files to Download Queue', async ({ page }) => {
2121
name: /Add \d+ Files to downloads/,
2222
});
2323
const menuText = (await addToDownloadsMenuItem.textContent()) ?? '';
24-
const fileCount = Number(menuText.match(/Add (\d+) Files to downloads/i)?.[1] ?? 0);
24+
const fileCount = Number(
25+
menuText.match(/Add (\d+) Files to downloads/i)?.[1] ?? 0,
26+
);
2527

2628
expect(fileCount).toBeGreaterThan(0);
2729

2830
await addToDownloadsMenuItem.click();
2931
await page.getByRole('button', { name: 'Downloads' }).click();
3032

31-
await expect(page.locator('.dl-subtitle')).toContainText(`${fileCount} Files`);
32-
await expect(page.locator('.dl-mat-dialog-content mat-list-item')).toHaveCount(
33-
fileCount,
33+
await expect(page.locator('.dl-subtitle')).toContainText(
34+
`${fileCount} Files`,
3435
);
36+
await expect(
37+
page.locator('.dl-mat-dialog-content mat-list-item'),
38+
).toHaveCount(fileCount);
3539
});

e2e/baseline/export.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22
import * as fs from 'fs';
33
import { parse } from 'csv-parse/sync';
44

e2e/baseline/filters.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22

33
test('Baseline Start & End Date Filters', async ({ page }) => {
44
await page.goto('/');

e2e/baseline/sentinel-scene-from-geo.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22
import { waitForASFAPIResponse } from 'e2e/helpers';
33

44
test('Baseline: Search for a Sentinel Scene from Geo Search (SLC File)', async ({

e2e/baseline/zoom.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22

33
test('Baseline zoom to results', async ({ page }) => {
44
const getMapInfoText = async () =>

e2e/displacement/map.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22

33
test('Click on displacement map', async ({ page }) => {
44
await page.goto('/');

e2e/events/active-inactive-event-filter.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22

33
test('Active/Inactive Event Filter', async ({ page }) => {
44
await page.goto('/');

e2e/events/browse-viewer-download-or-add-to-download-queue.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22

33
test('Browse Viewer: Download or Add to Download Queue', async ({ page }) => {
44
await page.goto('/');

e2e/events/clear-search.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect } from 'e2e/fixtures';
22

33
test('Clear Search', async ({ page }) => {
44
await page.goto('/');

0 commit comments

Comments
 (0)