Files
SnapOtter/tests/e2e-landing/subpages.spec.ts
SnapOtterandGitHub 1e1efbdfb3 test(landing): fix six stale e2e specs and wire the suite into CI (#572)
The landing Playwright suite ran in no CI workflow, so six specs had drifted red on main. Five subpages navigation tests asserted bare paths while the site emits trailing-slash URLs (format: directory), and one asserted a localized tool-detail page that is English-only by design. Fix the assertions and rewrite the tool test to the real invariant, then add a test-e2e-landing job gated on a new landing path filter so the suite runs on landing-relevant PRs and can't silently rot again.
2026-07-18 12:28:25 +08:00

154 lines
5.5 KiB
TypeScript

import { expect, test } from "@playwright/test";
test.describe("Contact Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/contact");
});
test("renders the page heading", async ({ page }) => {
await expect(page.getByText("Get in touch")).toBeVisible();
});
test("renders all form fields", async ({ page }) => {
await expect(page.getByLabel(/Name/)).toBeVisible();
await expect(page.getByLabel(/Email/)).toBeVisible();
await expect(page.getByLabel(/Company/)).toBeVisible();
await expect(page.getByLabel(/Subject/)).toBeVisible();
await expect(page.getByLabel(/Message/)).toBeVisible();
await expect(page.getByText("Send Message")).toBeVisible();
});
test("renders benefit cards", async ({ page }) => {
await expect(page.getByText("Live Demo")).toBeVisible();
await expect(page.getByText("Deployment Support")).toBeVisible();
});
test("renders email fallback", async ({ page }) => {
const emailLink = page.getByRole("link", { name: "contact@snapotter.com" });
await expect(emailLink).toBeVisible();
await expect(emailLink).toHaveAttribute("href", "mailto:contact@snapotter.com");
});
});
test.describe("Privacy Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/privacy");
});
test("renders the page heading", async ({ page }) => {
await expect(page.getByRole("heading", { name: "Privacy Policy" })).toBeVisible();
});
test("renders all section headings", async ({ page }) => {
const headings = [
"Data Controller",
"Overview",
"Website (snapotter.com)",
"Self-Hosted Software",
"Analytics",
"Contact Form",
"Open Source",
"Changes",
"Contact",
];
for (const heading of headings) {
await expect(page.getByRole("heading", { name: heading, exact: true })).toBeVisible();
}
});
test("renders the contact email", async ({ page }) => {
const emailLink = page.getByRole("link", { name: "contact@snapotter.com" });
await expect(emailLink).toBeVisible();
});
});
test.describe("Terms Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/terms");
});
test("renders the page heading", async ({ page }) => {
await expect(page.getByRole("heading", { name: "Terms and Conditions" })).toBeVisible();
});
test("renders all section headings", async ({ page }) => {
const headings = [
"Who We Are",
"Overview",
"Software License",
"Website Use",
"Self-Hosted Software",
"Intellectual Property",
"Limitation of Liability",
"Changes",
"Contact",
];
for (const heading of headings) {
await expect(page.getByRole("heading", { name: heading, exact: true })).toBeVisible();
}
});
test("mentions AGPL-3.0 license", async ({ page }) => {
await expect(page.getByText(/AGPL-3.0/).first()).toBeVisible();
});
});
test.describe("Cross-Page Navigation", () => {
// Astro's `format: "directory"` emits trailing-slash URLs, and localizeHref
// builds hrefs the same way, so navigation lands on "/privacy/" not "/privacy".
// This matches the sitemap and canonical URLs.
test("footer Privacy link navigates to /privacy/", async ({ page }) => {
await page.goto("/");
await page.locator("footer").getByRole("link", { name: "Privacy" }).click();
await expect(page).toHaveURL("/privacy/");
await expect(page.getByText("Privacy Policy").first()).toBeVisible();
});
test("footer Terms link navigates to /terms/", async ({ page }) => {
await page.goto("/");
await page.locator("footer").getByRole("link", { name: "Terms" }).click();
await expect(page).toHaveURL("/terms/");
await expect(page.getByText("Terms and Conditions").first()).toBeVisible();
});
test("footer FAQ link navigates to /faq/", async ({ page }) => {
await page.goto("/");
await page.getByRole("link", { name: "FAQ" }).click();
await expect(page).toHaveURL("/faq/");
await expect(page.getByText("Frequently Asked Questions")).toBeVisible();
});
test("navbar Talk to a human link navigates to /contact/", async ({ page }) => {
await page.goto("/");
await page.getByRole("link", { name: "Talk to a human" }).first().click();
await expect(page).toHaveURL("/contact/");
await expect(page.getByText("Get in touch")).toBeVisible();
});
test("pricing enterprise CTA links to /contact/", async ({ page }) => {
await page.goto("/");
const enterpriseCta = page.getByRole("link", { name: /Let.s talk/ }).first();
await expect(enterpriseCta).toHaveAttribute("href", "/contact/");
});
test("navbar Pricing link scrolls to the pricing section", async ({ page }) => {
await page.goto("/");
await page.waitForLoadState("networkidle");
const pricingLink = page.locator("nav").getByRole("link", { name: "Pricing" });
await expect(pricingLink).toHaveAttribute("href", "/#pricing");
await pricingLink.click();
await expect(page).toHaveURL(/\/#pricing$/);
await expect(page.locator("#pricing")).toBeInViewport();
});
test("navbar Enterprise link scrolls to the enterprise section", async ({ page }) => {
await page.goto("/");
await page.waitForLoadState("networkidle");
const enterpriseLink = page.locator("nav").getByRole("link", { name: "Enterprise" });
await expect(enterpriseLink).toHaveAttribute("href", "/#enterprise");
await enterpriseLink.click();
await expect(page).toHaveURL(/\/#enterprise$/);
await expect(page.locator("#enterprise")).toBeInViewport();
});
});