-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal-setup.ts
More file actions
38 lines (29 loc) · 1.26 KB
/
Copy pathglobal-setup.ts
File metadata and controls
38 lines (29 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { chromium, type FullConfig } from "@playwright/test";
async function globalSetup(config: FullConfig) {
const { storageState } = config.projects[0].use;
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto("https://af.tt02.altinn.no/?mock=true");
if (!process.env.HEIR_SSN || !process.env.HEIR_NAME) {
throw new Error("SSN and HEIR environment variables must be set");
}
// Select the high level test ID
await page.getByRole("link", { name: "TestID på nivå høyt" }).click();
// Fill in the SSN and authenticate
await page
.getByRole("textbox", { name: "Personidentifikator" })
.fill(process.env.HEIR_SSN);
await page.getByRole("button", { name: "Autentiser" }).click();
// Open the Altinn message and click on the link to access Digitalt dødsbo
await page
.getByRole("link", { name: "Tilgang til Digitalt dødsbo" })
.first()
.click();
await page.getByRole("link", { name: "Åpne Digitalt dødsbo" }).click();
// Save the base URL and storage state
process.env.BASE_URL = page.url();
console.log(`Base URL set to: ${process.env.BASE_URL}`);
await page.context().storageState({ path: storageState as string });
await browser.close();
}
export default globalSetup;