Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.
TypeScript fintechinvoiceinvoice-generatorinvoice-pdfinvoice-templateinvoicesnextjsopen-sourcequotesreactreact-pdf-rendererself-hostedshadcn-uitailwindcsstypescript
test: enhance URL verification in e2e tests for various pages (#174)
Vlad Sazonauc81eafd34bf4
diff --git a/e2e/about.test.ts b/e2e/about.test.tsindex 9ef65a1..5dfc9b2 100644--- a/e2e/about.test.ts+++ b/e2e/about.test.ts@@ -352,6 +352,7 @@ test.describe("About page", () => {page,}) => {await page.goto("/en/about");+ await expect(page).toHaveURL("/en/about");// Click the Go to App button in headerconst header = page.getByRole("banner");diff --git a/e2e/changelog.test.ts b/e2e/changelog.test.tsindex 28d755a..9f34d31 100644--- a/e2e/changelog.test.ts+++ b/e2e/changelog.test.ts@@ -32,6 +32,7 @@ test.describe("Changelog page", () => {test("should navigate to individual changelog entry", async ({ page }) => {await page.goto("/changelog");+ await expect(page).toHaveURL("/changelog");// Find and click on the first changelog entry title link// Find first changelog entry link and get its href@@ -58,6 +59,7 @@ test.describe("Changelog page", () => {}) => {// Navigate to changelog and then to first entryawait page.goto("/changelog");+ await expect(page).toHaveURL("/changelog");// Find and click on the first changelog entry title link// Find first changelog entry link and get its href@@ -114,6 +116,8 @@ test.describe("Changelog page", () => {}) => {// Navigate to an individual entryawait page.goto("/changelog");+ await expect(page).toHaveURL("/changelog");+const firstEntryLink = page.getByRole("link").filter({ has: page.getByRole("heading", { level: 2 }) })@@ -143,11 +147,14 @@ test.describe("Changelog page", () => {// Try to navigate directly to a changelog entry// First get the slug from the main pageawait page.goto("/changelog");+ await expect(page).toHaveURL("/changelog");+const firstEntryLink = page.locator('a[href^="/changelog/"]').first();const href = await firstEntryLink.getAttribute("href");// Navigate directly to the entryawait page.goto(href!);+ await expect(page).toHaveURL(href!);// Verify the page loads correctlyawait expect(diff --git a/e2e/default-invoice-template/default-invoice-template.test.ts b/e2e/default-invoice-template/default-invoice-template.test.tsindex dd5aee0..06dbd0c 100644--- a/e2e/default-invoice-template/default-invoice-template.test.ts+++ b/e2e/default-invoice-template/default-invoice-template.test.ts@@ -15,7 +15,8 @@ test.describe("Default Invoice Template", () => {// we set the system time to a fixed date, so that the invoice number and other dates are consistent across testsawait page.clock.setSystemTime(new Date("2025-12-17T00:00:00Z"));- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");+ await expect(page).toHaveURL("/?template=default");});test("downloads PDF in English and verifies content", async ({@@ -72,7 +73,8 @@ test.describe("Default Invoice Template", () => {);// navigate back to the previous page- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");+ await expect(page).toHaveURL("/?template=default");/*** Switch to Stripe template and download PDF in English with Stripe template@@ -297,7 +299,8 @@ test.describe("Default Invoice Template", () => {);// navigate back to the previous page- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");+ await expect(page).toHaveURL("/?template=default");/*** Switch to Stripe template and download PDF in Polish with Stripe template@@ -551,7 +554,8 @@ test.describe("Default Invoice Template", () => {);// navigate back to the previous page- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");+ await expect(page).toHaveURL("/?template=default");// Wait for the download button to be ready after navigationconst newDownloadPdfButton = page.getByRole("link", {@@ -786,7 +790,8 @@ test.describe("Default Invoice Template", () => {);// Navigate back to the previous page- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");+ await expect(page).toHaveURL("/?template=default");// Set mobile viewport againawait page.setViewportSize({ width: 375, height: 667 });@@ -1114,7 +1119,8 @@ test.describe("Default Invoice Template", () => {);// navigate back to the previous page- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");+ await expect(page).toHaveURL("/?template=default");/*** Switch to Stripe template and download PDF in English with Stripe template@@ -1298,7 +1304,8 @@ test.describe("Default Invoice Template", () => {*/// navigate back to the previous page- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");+ await expect(page).toHaveURL("/?template=default");// verify that we are on the default templateawait expect(page).toHaveURL("/?template=default");diff --git a/e2e/invoice-form.test.ts b/e2e/invoice-form.test.tsindex e7a6066..8c154d1 100644--- a/e2e/invoice-form.test.ts+++ b/e2e/invoice-form.test.ts@@ -22,7 +22,10 @@ test.describe("Invoice Generator Page", () => {});test("should redirect from /:locale/app to /", async ({ page }) => {- await page.goto("/en/app", { waitUntil: "commit" });+ // old url structure+ await page.goto("/en/app");++ await expect(page).toHaveURL("/?template=default");// wait for the app page to loadconst downloadPDFButton = page.getByRole("link", {@@ -39,7 +42,6 @@ test.describe("Invoice Generator Page", () => {}) => {// Navigate to default templateawait page.goto("/?template=default");-await expect(page).toHaveURL("/?template=default");const templateCombobox = page.getByRole("combobox", {@@ -1215,6 +1217,7 @@ test.describe("Invoice Generator Page", () => {// Navigate to the pageawait page.goto("/?template=default");+ await expect(page).toHaveURL("/?template=default");// Get the general information sectionconst generalInfoSection = page.getByRole("region", {diff --git a/e2e/not-found-page.test.ts b/e2e/not-found-page.test.tsindex 76f136c..6e5c019 100644--- a/e2e/not-found-page.test.ts+++ b/e2e/not-found-page.test.ts@@ -5,7 +5,6 @@ test.describe("Not Found page", () => {page,}) => {await page.goto("/non-existent-page");-// Verify URL is correctawait expect(page).toHaveURL("/non-existent-page");@@ -27,7 +26,6 @@ test.describe("Not Found page", () => {page,}) => {await page.goto("/es/non-existent-page");-// Verify URL is correctawait expect(page).toHaveURL("/es/non-existent-page");diff --git a/e2e/seller.test.ts b/e2e/seller.test.tsindex 0393c5e..952d0f8 100644--- a/e2e/seller.test.ts+++ b/e2e/seller.test.ts@@ -6,6 +6,8 @@ import { expect, test } from "@playwright/test";test.describe("Seller management", () => {test.beforeEach(async ({ page }) => {await page.goto("/");++ await expect(page).toHaveURL("/?template=default");});test("create/edit seller", async ({ page }) => {diff --git a/e2e/static-assets.test.ts b/e2e/static-assets.test.tsindex ac3639e..a09db39 100644--- a/e2e/static-assets.test.ts+++ b/e2e/static-assets.test.ts@@ -63,6 +63,7 @@ test.describe("Static assets (fonts, images, videos) should be accessible", () =});await page.goto("/");+ await expect(page).toHaveURL("/?template=default");expect(failed).toEqual([]);});@@ -78,6 +79,7 @@ test.describe("Static assets (fonts, images, videos) should be accessible", () =});await page.goto("/en/about");+ await expect(page).toHaveURL("/en/about");expect(failed).toEqual([]);});diff --git a/e2e/stripe-invoice-template/share-logic.test.ts b/e2e/stripe-invoice-template/share-logic.test.tsindex 5c7f571..632fdb0 100644--- a/e2e/stripe-invoice-template/share-logic.test.ts+++ b/e2e/stripe-invoice-template/share-logic.test.ts@@ -100,6 +100,9 @@ test.describe("Stripe Invoice Sharing Logic", () => {test("cannot share invoice with Stripe template and *WITH* logo", async ({page,}) => {+ // Verify default template is selected by default+ await expect(page).toHaveURL("/?template=default");+// Switch to Stripe templateawait page.getByRole("combobox", { name: "Invoice Template" })@@ -136,6 +139,9 @@ test.describe("Stripe Invoice Sharing Logic", () => {test("share button becomes enabled again after removing logo", async ({page,}) => {+ // Verify default template is selected by default+ await expect(page).toHaveURL("/?template=default");+// Switch to Stripe template and upload logoawait page.getByRole("combobox", { name: "Invoice Template" })@@ -175,16 +181,6 @@ test.describe("Stripe Invoice Sharing Logic", () => {// Test that sharing worksawait shareButton.click();- await page.waitForURL((url) => url.searchParams.has("data"));-- const url = page.url();- expect(url).toContain(`?template=stripe&data=`);-- // Verify data parameter is not empty- const urlObj = new URL(url);- const dataParam = urlObj.searchParams.get("data");- expect(dataParam).toBeTruthy();- expect(dataParam).not.toBe("");// Verify the share invoice link description toast appears after generating the linkconst toast = page.getByTestId("share-invoice-link-description-toast");@@ -195,11 +191,25 @@ test.describe("Stripe Invoice Sharing Logic", () => {"Share this link to let others view and edit this invoice",),).toBeVisible();++ await page.waitForURL((url) => url.searchParams.has("data"));++ const url = page.url();+ expect(url).toContain(`?template=stripe&data=`);++ // Verify data parameter is not empty+ const urlObj = new URL(url);+ const dataParam = urlObj.searchParams.get("data");+ expect(dataParam).toBeTruthy();+ expect(dataParam).not.toBe("");});test("share button becomes disabled when switching to Stripe template with existing logo", async ({page,}) => {+ // Verify default template is selected by default+ await expect(page).toHaveURL("/?template=default");+// Start with default template and verify share button is enabledconst shareButton = page.getByRole("button", {name: "Generate a link to invoice",@@ -228,6 +238,9 @@ test.describe("Stripe Invoice Sharing Logic", () => {});test("preserves sharing state after page reload", async ({ page }) => {+ // Verify default template is selected by default+ await expect(page).toHaveURL("/?template=default");+// Switch to Stripe template and upload logoawait page.getByRole("combobox", { name: "Invoice Template" })@@ -288,6 +301,9 @@ test.describe("Stripe Invoice Sharing Logic", () => {test("sharing functionality works correctly in mobile view (mobile UI is a bit different)", async ({page,}) => {+ // Verify default template is selected by default+ await expect(page).toHaveURL("/?template=default");+// Set mobile viewportawait page.setViewportSize({ width: 375, height: 667 });@@ -337,6 +353,9 @@ test.describe("Stripe Invoice Sharing Logic", () => {test("shows error toast when form has validation errors and generates link after fixing", async ({page,}) => {+ // Verify default template is selected by default+ await expect(page).toHaveURL("/?template=default");+// Switch to Stripe templateawait page.getByRole("combobox", { name: "Invoice Template" })diff --git a/e2e/stripe-invoice-template/stripe-invoice-template.test.ts b/e2e/stripe-invoice-template/stripe-invoice-template.test.tsindex 488b2ab..ddf5904 100644--- a/e2e/stripe-invoice-template/stripe-invoice-template.test.ts+++ b/e2e/stripe-invoice-template/stripe-invoice-template.test.ts@@ -21,15 +21,14 @@ test.describe("Stripe Invoice Template", () => {// we set the system time to a fixed date, so that the invoice number and other dates are consistent across testsawait page.clock.setSystemTime(new Date("2025-12-17T00:00:00Z"));- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");});test("displays correct OG meta tags for Stripe template", async ({page,}) => {// Navigate to Stripe template- await page.goto("/?template=stripe", { waitUntil: "commit" });-+ await page.goto("/?template=stripe");await expect(page).toHaveURL("/?template=stripe");const templateCombobox = page.getByRole("combobox", {@@ -838,7 +837,8 @@ test.describe("Stripe Invoice Template", () => {);// navigate back to the previous page- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");+ await expect(page).toHaveURL("/?template=stripe");// verify that the stripe template is selectedconst templateCombobox = page.getByRole("combobox", {@@ -846,7 +846,9 @@ test.describe("Stripe Invoice Template", () => {});await expect(templateCombobox).toHaveValue("stripe");- // Switch back to default template+ /**+ * Switch back to default template+ */await page.getByRole("combobox", { name: "Invoice Template" }).selectOption("default");@@ -1097,7 +1099,7 @@ test.describe("Stripe Invoice Template", () => {*/// navigate back to the previous page- await page.goto("/", { waitUntil: "commit" });+ await page.goto("/");// verify that we are on the STRIPE templateawait expect(page).toHaveURL("/?template=stripe");