This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4k
/
home.spec.js
75 lines (63 loc) · 2.56 KB
/
home.spec.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// @ts-check
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
import { getTotalStats } from "pages/api/statistics/totals";
import { abbreviateNumber } from "@services/utils/abbreviateNumbers";
test("homepage has title", async ({ page }) => {
await page.goto("/");
await expect(page).toHaveTitle(/BioDrop/);
});
test("homepage has example link", async ({ page }) => {
await page.goto("/");
const getStarted = page.getByText("Example");
await getStarted.click();
await page.waitForLoadState("domcontentloaded");
await expect(page).toHaveURL(/eddiejaoude/);
});
test("Footer link goes to GitHub", async ({ page }) => {
await page.goto("/");
const getFooter = page.getByText("Powered by EddieHub");
await getFooter.click();
await page.waitForLoadState("domcontentloaded");
await expect(page).toHaveURL(/github/);
});
test.describe("accessibility tests (light)", () => {
test.use({ colorScheme: "light" });
test("should pass axe wcag accessibility tests (light)", async ({ page }) => {
await page.goto("/");
const accessibilityScanResults = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
});
test.describe("accessibility tests (dark)", () => {
test.use({ colorScheme: "dark" });
test("should pass axe wcag accessibility tests (dark)", async ({ page }) => {
await page.goto("/");
const accessibilityScanResults = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
});
test.describe("Data rendered correctly on home page", () => {
test("Total active rendered", async ({ page }) => {
const { stats: totalStats } = await getTotalStats();
const abbreviatedActive = abbreviateNumber(totalStats.active);
await page.goto("/");
const section = page.getByText("Active Users");
const parent = section.locator("..");
const item = parent.locator("dd div:nth-child(1)");
await expect(item).toHaveText(abbreviatedActive);
});
test("Profile views rendered", async ({ page }) => {
const { stats: totalStats } = await getTotalStats();
const abbreviatedViews = abbreviateNumber(totalStats.views);
await page.goto("/");
const section = page.getByText("Profile Views");
const parent = section.locator("..");
const item = parent.locator("dd div:nth-child(1)");
await expect(item).toHaveText(abbreviatedViews);
});
});