Skip to content

Commit 14d2749

Browse files
committed
Uploaded activate test; Test supports 3 browsers by testing with a browser suffix
1 parent 7f6cf9c commit 14d2749

3 files changed

Lines changed: 103 additions & 0 deletions

File tree

client/tests/e2e/1-user-account/2.2-read-get-all.login.spec.ts renamed to client/tests/e2e/1-user-account/2.2-read-get-all.spec.ts

File renamed without changes.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { expect, Page, test } from "@playwright/test";
2+
import { navigateTo, suffixForProject } from "../utils/helpers";
3+
import { loginAsServerAdmin } from "../utils/authenticate";
4+
5+
const userLastName = "testinactive";
6+
const userUUID = "seb-inst-admin-inactive";
7+
8+
async function setupUserAccountsPage(page: Page, suffix: string) {
9+
await expect(page.getByTestId("userAccounts-list-container")).toBeVisible();
10+
11+
const searchFieldLocator = page
12+
.getByTestId("userAccounts-search-input")
13+
.getByRole("textbox");
14+
const searchButtonLocator = page.getByTestId(
15+
"userAccounts-searchIcon-button",
16+
);
17+
18+
//this needs suffix
19+
const activateButtonLocator = page.getByTestId(
20+
`userAccounts-status-chip-seb-inst-admin-inactive-${suffix}`,
21+
);
22+
const statusDialogLocator = page.getByTestId("userAccounts-status-dialog");
23+
const statusDialogActivateButtonLocator = page.getByTestId(
24+
"userAccounts-status-confirm-button",
25+
);
26+
27+
return {
28+
searchFieldLocator,
29+
searchButtonLocator,
30+
activateButtonLocator,
31+
statusDialogLocator,
32+
statusDialogActivateButtonLocator,
33+
};
34+
}
35+
36+
test.describe("1.3.2 User Accounts - UPDATE Activate", () => {
37+
test.beforeEach(async ({ page }) => {
38+
await loginAsServerAdmin(page);
39+
await navigateTo(page, "/user-accounts");
40+
});
41+
42+
test("A Success", async ({ page }, testInfo) => {
43+
const browserSuffix = suffixForProject(testInfo.project.name);
44+
const userLastNameWithBrowserSuffix =
45+
userLastName + "-" + browserSuffix;
46+
const userUUIDWithBrowserSuffix = userUUID + "-" + browserSuffix;
47+
const activateRegex = new RegExp(
48+
`/useraccount/${userUUIDWithBrowserSuffix}/active(?:\\?|$)`,
49+
"i",
50+
);
51+
52+
const {
53+
searchFieldLocator,
54+
searchButtonLocator,
55+
activateButtonLocator,
56+
statusDialogLocator,
57+
statusDialogActivateButtonLocator,
58+
} = await setupUserAccountsPage(page, browserSuffix);
59+
60+
await searchFieldLocator.fill(userLastNameWithBrowserSuffix);
61+
62+
await searchButtonLocator.click();
63+
64+
await expect(activateButtonLocator).toBeVisible();
65+
await expect(activateButtonLocator).toHaveText("Inactive");
66+
67+
await activateButtonLocator.click();
68+
69+
await expect(statusDialogLocator).toBeVisible();
70+
71+
await expect(statusDialogActivateButtonLocator).toHaveText("Activate");
72+
73+
const activateRequestPromise = page.waitForRequest(
74+
(req) => req.method() === "POST" && activateRegex.test(req.url()),
75+
);
76+
77+
const activateResponsePromise = page.waitForResponse(
78+
(resp) =>
79+
resp.request().method() === "POST" &&
80+
activateRegex.test(resp.url()),
81+
);
82+
83+
await statusDialogActivateButtonLocator.click();
84+
85+
const activateRequest = await activateRequestPromise;
86+
const activateResponse = await activateResponsePromise;
87+
88+
//this needs suffix
89+
expect(activateRequest.method()).toBe("POST");
90+
expect(activateRequest.url()).toMatch(activateRegex);
91+
92+
expect(activateResponse.url()).toMatch(activateRegex);
93+
expect(activateResponse.status()).toBe(200);
94+
expect(activateResponse.ok()).toBeTruthy();
95+
96+
// 8. verify the v-chip text is now "Active"
97+
await expect(activateButtonLocator).toHaveText("Active");
98+
});
99+
});

client/tests/e2e/utils/helpers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,7 @@ export async function expectToHaveUrl(page: Page, path: string) {
8484
timeout: 10_000,
8585
});
8686
}
87+
88+
export function suffixForProject(projectName: string) {
89+
return projectName.toLowerCase();
90+
}

0 commit comments

Comments
 (0)