summaryrefslogtreecommitdiff
path: root/tests/index.spec.ts
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2025-06-06 14:18:07 -0700
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2025-06-06 14:18:07 -0700
commit108f26a3874e5f8649bf4d128aa07c9b35aa6a10 (patch)
treed7f1e145ecca9d6e5e450bdf38353edd93aefe3f /tests/index.spec.ts
parent774b221be12316230019b90fb597b4590ec37a01 (diff)
downloadanshulg-com-108f26a3874e5f8649bf4d128aa07c9b35aa6a10.tar.gz
anshulg-com-108f26a3874e5f8649bf4d128aa07c9b35aa6a10.tar.zst
anshulg-com-108f26a3874e5f8649bf4d128aa07c9b35aa6a10.zip
Add playwright tests
Diffstat (limited to '')
-rw-r--r--tests/index.spec.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/index.spec.ts b/tests/index.spec.ts
new file mode 100644
index 0000000..b804a2a
--- /dev/null
+++ b/tests/index.spec.ts
@@ -0,0 +1,48 @@
+import {
+ test,
+ expect,
+ type Locator,
+ type BrowserContext,
+} from "@playwright/test";
+
+test.beforeEach(async ({ page }) => {
+ await page.goto("/");
+});
+
+test("has title", async ({ page }) => {
+ await expect(page).toHaveTitle("Anshul Gupta");
+});
+
+test("has header", async ({ page }) => {
+ let header = page.locator("header");
+ await expect(header).toBeVisible();
+ await expect(header.locator("div").first()).toHaveText("ANSHUL GUPTA (7)");
+ await expect(header.locator("div").last()).toHaveText("ANSHUL GUPTA (7)");
+ await expect(header.locator("h1")).toHaveText(
+ "Miscellaneous Information Manual",
+ );
+});
+
+test("has Email link", async ({ page }) => {
+ let emailLink = page.getByRole("link", { name: "ansg191@anshulg.com" });
+ await expect(emailLink).toBeVisible();
+ await expect(emailLink).toHaveText("ansg191@anshulg.com");
+ await expect(emailLink).toHaveAttribute("href", "mailto:ansg191@anshulg.com");
+});
+
+test("has GitHub link", async ({ page, context }) => {
+ let ghLink = page.getByRole("link", { name: "ansg191" }).nth(1);
+ await checkLinkNewTab(context, ghLink, "https://github.com/ansg191");
+});
+
+async function checkLinkNewTab(
+ ctx: BrowserContext,
+ link: Locator,
+ expUrl: string,
+) {
+ const pagePromise = ctx.waitForEvent("page");
+ await expect(link).toBeVisible();
+ await link.click();
+ const newPage = await pagePromise;
+ await expect(newPage).toHaveURL(expUrl);
+}