Skip to content

Commit df44ed5

Browse files
authored
feat: vitest and playwright setup
* chore: update test dependencies * chore: update testing to use tsconfig * chore: compiling test * chore: fix component testing Temp patch for this to get it working, will need some redesign to make something scalable for the future and other components that we are wanting to test. * chore: readd polyfill script to tsconfig * chore: add canvas package * chore: add code coverage support * chore: initial e2e test setup * chore: remove vitest browser mode test * fix: ngx-translate updates * Merge branch 'test' into tyler/vitest * feat: playwright github action * chore(deps): update package-lock * feat: authenticated testing framework * fix: auth action pathing * fix: action pathing * fix: directory pathing * fix: directory structure first * fix: use base64 creds for better parsing * feat: some example tests * feat: add ng test github action * chore: cleanup old screenshots * chore: remove test branch from action, set permissions explicitly * fix: explicit product scene list click * fix: specify timezoneId for tests * fix: bypassCSP for map based interaction setup * feat: aoi parsing test This shows an example of how to get info form a material input. The automated tool doesn't work for them out of the box. * chore: codefactor fix
1 parent 6d98203 commit df44ed5

31 files changed

Lines changed: 9031 additions & 10367 deletions

.github/workflows/e2etest.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches:
5+
- test
6+
pull_request:
7+
branches:
8+
- test
9+
- prod
10+
permissions:
11+
contents: read
12+
jobs:
13+
test:
14+
timeout-minutes: 60
15+
runs-on: ubuntu-latest
16+
environment: playwright
17+
permissions:
18+
contents: read
19+
steps:
20+
- uses: actions/checkout@v5
21+
- uses: actions/setup-node@v5
22+
with:
23+
node-version: lts/*
24+
- name: Install dependencies
25+
run: npm ci
26+
- name: Setup credentials
27+
run: mkdir -p playwright/.auth
28+
- name: Import Credentials
29+
run: echo "${{ secrets.TEST_ACCOUNT_CREDS }}" | base64 --decode > playwright/.auth/creds.json
30+
- name: Install Playwright Browsers
31+
run: npx playwright install --with-deps
32+
- name: Run Playwright tests
33+
run: npm run e2e
34+
- uses: actions/upload-artifact@v4
35+
if: ${{ !cancelled() }}
36+
with:
37+
name: playwright-report
38+
path: playwright-report/
39+
retention-days: 30

.github/workflows/unit-test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Unit Tests
2+
on:
3+
push:
4+
permissions:
5+
contents: read
6+
jobs:
7+
test:
8+
timeout-minutes: 60
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v5
12+
- uses: actions/setup-node@v5
13+
with:
14+
node-version: lts/*
15+
- name: Install dependencies
16+
run: npm ci
17+
- name: Run Unit tests
18+
run: npm run test -- --watch=false

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,14 @@ local-serve.sh
4747
CLAUDE.md
4848
TRANSLATIONS_SCRATCH.md
4949
docs/
50+
51+
# Playwright
52+
/test-results/
53+
/playwright-report/
54+
/playwright/.cache/
55+
56+
# Playwright
57+
/test-results/
58+
/playwright-report/
59+
/playwright/.cache/
60+
playwright/

angular.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,14 @@
124124
}
125125
},
126126
"test": {
127-
"builder": "@angular/build:karma",
127+
"builder": "@angular/build:unit-test",
128128
"options": {
129-
"main": "src/test.ts",
130-
"polyfills": "src/polyfills.ts",
131-
"tsConfig": "src/tsconfig.spec.json",
132-
"karmaConfig": "src/karma.conf.js",
133-
"styles": [
134-
"src/styles.scss"
129+
"buildTarget": "search-ui:build:local",
130+
"tsConfig": "tsconfig.spec.json",
131+
"coverageExclude": [
132+
"src/app/models"
135133
],
136-
"stylePreprocessorOptions": {
137-
"includePaths": [
138-
"src/styles"
139-
]
140-
},
141-
"scripts": [],
142-
"assets": [
143-
"src/favicon.ico",
144-
"src/assets"
145-
]
134+
"runnerConfig": true
146135
}
147136
},
148137
"lint": {
@@ -153,6 +142,17 @@
153142
"src/**/*.html"
154143
]
155144
}
145+
},
146+
"e2e": {
147+
"builder": "playwright-ng-schematics:playwright",
148+
"options": {
149+
"devServerTarget": "search-ui:serve"
150+
},
151+
"configurations": {
152+
"production": {
153+
"devServerTarget": "search-ui:serve:production"
154+
}
155+
}
156156
}
157157
}
158158
}

e2e/.gitlab-ci.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

e2e/=3.1.1

Whitespace-only changes.

e2e/=3.3

Lines changed: 0 additions & 4 deletions
This file was deleted.

e2e/auth.setup.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect, test as setup } from '@playwright/test';
2+
import path from 'path';
3+
import fs from 'fs';
4+
5+
// import { username, password } from '../playwright/.auth/creds.json';
6+
const authFile = path.join(__dirname, '../playwright/.auth/user.json');
7+
const credsFile = path.join(__dirname, '../playwright/.auth/creds.json');
8+
setup('authenticate', async ({ page }) => {
9+
let userData = {};
10+
try {
11+
const data = fs.readFileSync(credsFile, 'utf8');
12+
userData = JSON.parse(data);
13+
} catch (_e) {
14+
console.error('Error reading or parsing auth JSON file.');
15+
return;
16+
}
17+
await page.goto('https://search.asf.alaska.edu');
18+
const popupPromise = page.waitForEvent('popup');
19+
20+
await page.getByRole('button', { name: 'Sign In' }).click();
21+
const popup = await popupPromise;
22+
await popup.getByLabel('username').fill(userData['username']);
23+
await popup.getByLabel('password').fill(userData['password']);
24+
await popup.getByRole('button', { name: 'Log in' }).click();
25+
await expect(page.getByRole('button', { name: 'Sign In' })).toHaveCount(0);
26+
27+
await page.context().storageState({ path: authFile });
28+
});

e2e/geographic/aoi-parse.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import test, { expect } from '@playwright/test';
2+
3+
test('Area of interest should parse polygon coordinate strings', async ({
4+
page,
5+
}) => {
6+
await page.goto('/');
7+
await page.getByRole('button', { name: 'Filters', exact: true }).click();
8+
await page
9+
.getByRole('region', { name: 'Area of Interest Options' })
10+
.getByLabel('Area of Interest • WKT')
11+
.click();
12+
await page
13+
.getByRole('region', { name: 'Area of Interest Options' })
14+
.getByLabel('Area of Interest • WKT')
15+
.fill(
16+
'-53.26,64.81,-48.1,60.33,-42.58,59.93,-40.94,63.63,-37.18,65.91,-31.29,67.17,-26.02,68.68,- 21.97,70.57,-18.28,75.06,-17.05,77.04,-19.78,78.79,-10.72,81.55,-20.83,82.4,-25.44,83.13,-31.82,83.63,- 43.95,83.23,-61.17,81.84,-66.58,80.39,-66.2,79.47,-74.09,78.37,-69.26,76.12,-61.08,76.1,-54.71,72.83,- 55.04,71.55,-53.26,64.81',
17+
);
18+
await page
19+
.locator('#mat-button-toggle-6-button')
20+
.getByRole('button', { name: 'SEARCH' })
21+
.click();
22+
await page.getByRole('button', { name: 'Filters', exact: true }).click();
23+
const value = await page
24+
.getByLabel('Area of Interest Options')
25+
.getByLabel('Area of Interest • WKT')
26+
.inputValue();
27+
await expect(value).toContain(
28+
'POLYGON((-53.26 64.81,-48.1 60.33,-42.58 59.93,-40.94 63.63,-37.18 65.91,-31.29 67.17,-26.02 68.68,-21.97 70.57,-18.28 75.06,-17.05 77.04,-19.78 78.79,-10.72 81.55,-20.83 82.4,-25.44 83.13,-31.82 83.63,-43.95 83.23,-61.17 81.84,-66.58 80.39,-66.2 79.47,-74.09 78.37,-69.26 76.12,-61.08 76.1,-54.71 72.83,-55.04 71.55,-53.26 64.81))',
29+
);
30+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
// made using the playwright test generator
4+
// loads up a browser and listens to what you click on
5+
// https://playwright.dev/docs/codegen
6+
test('test', async ({ page }) => {
7+
await page.goto('/');
8+
9+
await page.getByRole('button', { name: 'Sentinel-' }).click();
10+
await page
11+
.getByRole('menuitem', { name: 'ALOS AVNIR-2 Advanced Visible' })
12+
.click();
13+
await page
14+
.locator('#mat-button-toggle-8-button')
15+
.getByRole('button', { name: 'SEARCH' })
16+
.click();
17+
await page.getByRole('button', { name: 'ALAV2A279162270 April 21,' }).click();
18+
await expect(page.locator('mat-card-title')).toContainText('ALAV2A279162270');
19+
});

0 commit comments

Comments
 (0)