Skip to content

Commit 7b399c6

Browse files
authored
[Playwright] new e2e test for atcp self-consent enrollment (#2158)
* new playwright test for atcp self-consent enrollment
1 parent ace6ab2 commit 7b399c6

File tree

110 files changed

+1238
-128
lines changed

Some content is hidden

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

110 files changed

+1238
-128
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ jobs:
707707
TESTS_FILE=$(circleci tests split --split-by=timings --timings-type=classname e2e_tests.txt)
708708
echo $TESTS_FILE
709709
npm run test:ci $TESTS_FILE
710-
no_output_timeout: 3m # Default is 10m. Set shorter time to ensure CI fails faster if test hangs
710+
no_output_timeout: 5m # Default is 10m. Set shorter time to ensure CI fails faster if test hangs
711711
- store_test_results:
712712
path: playwright-e2e/junit
713713
- store_artifacts:

.circleci/export-playwright-env.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,19 @@ export lmsUser=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".da
7777
export lmsUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"lms\") | .password")
7878
echo "export LMS_USER_PASSWORD=$lmsUserPassword" >> playwright-env/envvars
7979
echo "export LMS_USER_EMAIL=$lmsUser" >> playwright-env/envvars
80+
81+
# ATCP
82+
export atcpUser=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"atcp\") | .userName")
83+
export atcpUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"atcp\") | .password")
84+
echo "export ATCP_USER_EMAIL=$atcpUser" >> playwright-env/envvars
85+
echo "export ATCP_USER_PASSWORD=$atcpUserPassword" >> playwright-env/envvars
86+
87+
# Read Auth0 ATCP client credentials
88+
export atcpDomain=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.auth0 | .[] | select(.app==\"atcp\" and .env==\"$ENV\") | .domain")
89+
export atcpAudience=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.auth0 | .[] | select(.app==\"atcp\" and .env==\"$ENV\") | .audience")
90+
export atcpClientId=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.auth0 | .[] | select(.app==\"atcp\" and .env==\"$ENV\") | .clientId")
91+
export atcpClientSecret=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.auth0 | .[] | select(.app==\"atcp\" and .env==\"$ENV\") | .clientSecret")
92+
echo "export ATCP_AUTH0_DOMAIN=$atcpDomain" >> playwright-env/envvars
93+
echo "export ATCP_AUTH0_AUDIENCE=$atcpAudience" >> playwright-env/envvars
94+
echo "export ATCP_AUTH0_CLIENT_ID=$atcpClientId" >> playwright-env/envvars
95+
echo "export ATCP_AUTH0_CLIENT_SECRET=$atcpClientSecret" >> playwright-env/envvars

playwright-e2e/.env.sample

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
SITE_PASSWORD=
44

5+
# ATCP
6+
ATCP_BASE_URL=https://atcp.dev.datadonationplatform.org
7+
ATCP_USER_EMAIL=
8+
ATCP_USER_PASSWORD=
9+
10+
# ATCP Auth0 settings required to set email validated = true
11+
ATCP_AUTH0_DOMAIN=
12+
ATCP_AUTH0_AUDIENCE=
13+
ATCP_AUTH0_CLIENT_ID=
14+
ATCP_AUTH0_CLIENT_SECRET=
15+
516
# Singular
617
SINGULAR_BASE_URL=
718
SINGULAR_USER_EMAIL=
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Page } from '@playwright/test';
2+
import AtcpRegistrationPage from 'dss/pages/atcp/atcp-registration-page';
3+
import { generateEmailAlias } from 'utils/faker-utils';
4+
5+
const { ATCP_USER_EMAIL, ATCP_USER_PASSWORD } = process.env;
6+
7+
export async function login(page: Page, opts: { email?: string; password?: string } = {}): Promise<AtcpRegistrationPage> {
8+
const { email = ATCP_USER_EMAIL, password = ATCP_USER_PASSWORD } = opts;
9+
if (!email) {
10+
throw Error('Invalid ATCP email');
11+
}
12+
if (!password) {
13+
throw Error('Invalid ATCP password');
14+
}
15+
const loginLocator = '.Header a >> text="Sign In"';
16+
await page.locator(loginLocator).click();
17+
18+
await page.locator('#login input#email').fill(email);
19+
await page.locator('#login input#password').fill(password);
20+
await page.click('button >> text="Sign In"');
21+
22+
const registrationPage = new AtcpRegistrationPage(page);
23+
await registrationPage.waitForReady();
24+
return registrationPage;
25+
}
26+
27+
export async function createAccountWithEmailAlias(
28+
page: Page,
29+
opts: { email: string | undefined; password: string | undefined }
30+
): Promise<string> {
31+
const { email, password } = opts;
32+
if (!email) {
33+
throw Error('Invalid parameters: User email is undefined or null.');
34+
}
35+
if (!password) {
36+
throw Error('Invalid parameters: User password is undefined or null.');
37+
}
38+
39+
const emailInput = page.locator('.sign-up input[name="email"][id="email"]');
40+
const passwordInput = page.locator('.sign-up input[name="password"][id="password"]');
41+
const passwordConfirmInput = page.locator('.sign-up input[name="password_confirm"][id="password_confirm"]');
42+
43+
const emailAlias = generateEmailAlias(email);
44+
await emailInput.fill(emailAlias);
45+
await passwordInput.fill(password);
46+
await passwordConfirmInput.fill(password);
47+
await page.locator('button#join-us').click();
48+
49+
return emailAlias;
50+
}

playwright-e2e/authentication/auth-base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export async function fillInEmailPassword(
1919
await emailInput.fill(email);
2020
await passwordInput.fill(password);
2121

22-
const authPromise = waitForAuth ? page.locator('.auth0-loading').first().waitFor({ state: 'visible' }) : Promise.resolve();
23-
const navigationPromise = waitForNavigation ? page.waitForNavigation({ waitUntil: 'load' }) : Promise.resolve();
22+
const authPromise = waitForAuth ? page.locator('.auth0-loading').first().waitFor({ state: 'visible', timeout: 2000 }).catch() : Promise.resolve();
23+
const navigationPromise = waitForNavigation ? page.waitForLoadState('load') : Promise.resolve();
2424
await Promise.all([authPromise, navigationPromise, page.locator('button[name="submit"]:visible, button[type="submit"]:visible').click()]);
2525
}
2626

playwright-e2e/config/.env.dev

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
SITE_PASSWORD=
44

5+
# ATCP
6+
ATCP_BASE_URL=https://atcp.dev.datadonationplatform.org
7+
ATCP_USER_EMAIL=
8+
ATCP_USER_PASSWORD=
9+
10+
# ATCP Auth0 settings required to set email validated = true
11+
ATCP_AUTH0_DOMAIN=
12+
ATCP_AUTH0_AUDIENCE=
13+
ATCP_AUTH0_CLIENT_ID=
14+
ATCP_AUTH0_CLIENT_SECRET=
15+
516
# Singular
617
SINGULAR_BASE_URL=https://singular.dev.datadonationplatform.org
718
SINGULAR_USER_EMAIL=[email protected]

playwright-e2e/config/.env.staging

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
SITE_PASSWORD=
44

5+
# ATCP
6+
ATCP_BASE_URL=https://atcp.staging.datadonationplatform.org
7+
ATCP_USER_EMAIL=
8+
ATCP_USER_PASSWORD=
9+
10+
# ATCP Auth0 settings required to set email validated = true
11+
ATCP_AUTH0_DOMAIN=
12+
ATCP_AUTH0_AUDIENCE=
13+
ATCP_AUTH0_CLIENT_ID=
14+
ATCP_AUTH0_CLIENT_SECRET=
15+
516
# Singular
617
SINGULAR_BASE_URL=https://singular.staging.datadonationplatform.org
718
SINGULAR_USER_EMAIL=[email protected]

playwright-e2e/config/.env.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
SITE_PASSWORD=
44

5+
# ATCP
6+
ATCP_BASE_URL=https://atcp.test.datadonationplatform.org
7+
ATCP_USER_EMAIL=
8+
ATCP_USER_PASSWORD=
9+
10+
# ATCP Auth0 settings required to set email validated = true
11+
ATCP_AUTH0_DOMAIN=
12+
ATCP_AUTH0_AUDIENCE=
13+
ATCP_AUTH0_CLIENT_ID=
14+
ATCP_AUTH0_CLIENT_SECRET=
15+
516
# Singular
617
SINGULAR_BASE_URL=https://singular.test.datadonationplatform.org
718
SINGULAR_USER_EMAIL=[email protected]

playwright-e2e/data/fake-user.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@
6464
"phone": "6177147000"
6565
},
6666
"secondDoctor": {
67-
"name": "John Stack",
67+
"firstName": "E2E",
68+
"middleName": "PlaywrightTest",
69+
"lastName": "Stark",
70+
"fullName": "E2E PlaywrightTest Stark",
6871
"specialty": "PRIMARY_CARE",
6972
"phone": "6187247123",
7073
"hospital": "Brigham and Women's Hospital",

playwright-e2e/dsm/pages/kitUpload-page/kitUpload-page.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {KitUploadInfo} from 'dsm/pages/kitUpload-page/models/kitUpload-model';
77
import {StudyEnum} from 'dsm/component/navigation/enums/selectStudyNav-enum';
88
import {KitUploadResponse} from 'dsm/pages/kitUpload-page/interfaces/kitUpload';
99
import {kitUploadResponseEnum} from 'dsm/pages/kitUpload-page/enums/kitUploadResponse-enum';
10+
import path from 'path';
1011

1112
export default class KitUploadPage {
1213
private readonly PAGE_TITLE = 'Kit Upload';
@@ -28,9 +29,9 @@ export default class KitUploadPage {
2829

2930
public async uploadFile(kitType: KitTypeEnum, kitInfo: KitUploadInfo[], study: StudyEnum, testResultDir?: string) {
3031
const dir = testResultDir ? testResultDir : __dirname;
31-
const path = `${dir}/${kitType}_${study}-${new Date().getTime()}.txt`;
32-
createTextFileSync(path, this.T_HEAD + this.createKitUploadBody(kitInfo));
33-
await this.fileInput.setInputFiles(path);
32+
const filePath = path.join(dir, `${kitType}_${study}-${new Date().getTime()}.txt`);
33+
createTextFileSync(dir, filePath, this.T_HEAD + this.createKitUploadBody(kitInfo));
34+
await this.fileInput.setInputFiles(filePath);
3435

3536
await expect(this.uploadKitsBtn, 'Kit Upload page - Upload Kits button is disabled').toBeEnabled();
3637

@@ -42,7 +43,7 @@ export default class KitUploadPage {
4243
.textContent(), "Kit Upload page - Couldn't upload kits - something went wrong")
4344
.toEqual('All participants were uploaded.');
4445

45-
deleteFileSync(path);
46+
deleteFileSync(filePath);
4647
}
4748

4849
/* Helper functions */

0 commit comments

Comments
 (0)