Skip to content

Commit 5c262bc

Browse files
committed
added test for practice
1 parent f48bcca commit 5c262bc

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

playwright/practice.spec.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,59 @@ test("Application should have correct initial state", async ({ page }) => {
7070
await expect(link.locator("p")).toHaveText(examParagraphs[index++]);
7171
}
7272
});
73+
74+
test("Practice should work properly", async ({ page }) => {
75+
await page.goto("");
76+
await page.getByRole("link", { name: "AWS Certified ANS-C01 AWS" }).click();
77+
78+
await expect(
79+
page.getByRole("heading", { name: "AWS Certified ANS-C01" }),
80+
).toBeVisible();
81+
await expect(
82+
page.locator("main").getByRole("link").first().locator("h2"),
83+
).toHaveText("Practice mode");
84+
await expect(
85+
page.locator("main").getByRole("link").last().locator("h2"),
86+
).toHaveText("Exam mode");
87+
expect(await page.locator("main").getByRole("link").all()).toHaveLength(2);
88+
89+
await page.locator("main").getByRole("link").last().click();
90+
await expect(page.locator("main").locator("h1")).toContainText(
91+
"PRACTICE EXAM",
92+
);
93+
await expect(
94+
page.locator("main").locator("p", { hasText: "15:00" }),
95+
).toBeVisible();
96+
97+
const startButton = page.getByRole("button", { name: "Begin exam" });
98+
await expect(startButton).toBeEnabled();
99+
await startButton.click();
100+
101+
await expect(
102+
page.locator("button").filter({ hasText: "Next Question" }),
103+
).not.toBeEnabled();
104+
105+
const skipQuestion = page
106+
.locator("button")
107+
.filter({ hasText: "Skip Question" });
108+
await expect(skipQuestion).toBeEnabled();
109+
await skipQuestion.click();
110+
111+
await page.getByRole("button").first().click();
112+
113+
await page.getByRole("link", { name: "AWS Certified CLF-C02 AWS" }).click();
114+
await page.getByRole("link", { name: "Practice mode Learn and" }).click();
115+
116+
await expect(page.locator("input[type=number]")).toHaveValue("1");
117+
await expect(page.getByText("597")).toBeVisible();
118+
expect(await page.locator("label").all()).toHaveLength(4);
119+
await page.locator("label").first().click();
120+
await page.getByRole("button", { name: "Reveal Answer" }).click();
121+
await expect(page.locator("main ul")).toHaveScreenshot({ threshold: 0.02 });
122+
123+
await page.getByRole("button", { name: "Next Question" }).click();
124+
await expect(page.locator("input[type=number]")).toHaveValue("2");
125+
await page.locator("label").last().click();
126+
await page.getByRole("button", { name: "Reveal Answer" }).click();
127+
await expect(page.locator("main ul")).toHaveScreenshot({ threshold: 0.02 });
128+
});
12.5 KB
Loading
30.5 KB
Loading

0 commit comments

Comments
 (0)