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: update navigation wait strategy in e2e tests for improved reliability (#175)
Vlad Sazonau2c2a684d834e
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex 450eefe..5ddc60b 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -101,7 +101,7 @@ jobs:Result: ${{ steps.playwright.outcome == 'success' && '✅ Passed' || '❌ Failed' }}Playwright Browser Binaries Installation Time: ${{ steps.playwright-install.outputs.duration_formatted }}- ${{ steps.playwright.outcome == 'success' && format('Playwright Tests Duration: {0}', steps.playwright.outputs.duration_formatted) }}+ ${{ steps.playwright.outputs.duration_formatted && format('Playwright Tests Duration: {0}', steps.playwright.outputs.duration_formatted) || '' }}For more details, please check:- GitHub Actions run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}diff --git a/README.md b/README.mdindex 8e294a6..5c7eb76 100644--- a/README.md+++ b/README.md@@ -105,6 +105,10 @@ Watch a quick demo of EasyInvoicePDF in action to see how easy it is to create phttps://github.com/user-attachments/assets/d46c6e4e-b78a-4aa1-ab44-d20d6485b682+## 🌟 Star History++[](https://repostars.dev/?repos=VladSez%2Feasy-invoice-pdf&theme=dark)+## 👨💻 Made ByBuilt by [Vlad Sazonau](https://x.com/vladsazonau)diff --git a/e2e/generate-invoice-link.test.ts b/e2e/generate-invoice-link.test.tsindex 4213cab..93a4c30 100644--- a/e2e/generate-invoice-link.test.ts+++ b/e2e/generate-invoice-link.test.ts@@ -38,6 +38,8 @@ const TEST_BUYER_DATA = {test.describe("Generate Invoice Link", () => {test.beforeEach(async ({ page }) => {await page.goto("/");++ await expect(page).toHaveURL("/?template=default");});test("can share invoice and data is persisted in new tab", async ({@@ -311,7 +313,7 @@ test.describe("Generate Invoice Link", () => {page,}) => {// Navigate to page with invalid data parameter- await page.goto("/?data=invalid-data-string");+ await page.goto("/?data=invalid-data-string", { waitUntil: "commit" });await expect(page).toHaveURL("/?data=invalid-data-string&template=default");@@ -369,7 +371,7 @@ test.describe("Generate Invoice Link", () => {page,}) => {// Navigate to page with invalid data parameter- await page.goto("/?data=corrupted-url");+ await page.goto("/?data=corrupted-url", { waitUntil: "commit" });await expect(page).toHaveURL("/?data=corrupted-url&template=default");@@ -448,7 +450,7 @@ test.describe("Generate Invoice Link", () => {"N4IgNghgdg5grhGBTEAuEAHMIA0IAmEALkgGID2ATgLbFogCyTDABACI4sCaPXuIAYziVKSKAICe9AKoBlNvxLUsxFOgDORSgEsMKPGHIxy9ftqgA3ctoFIAcnGoAjJJQDyTgFZIBRNKEgXbHRSCABrImEIFihKdDwLCDA4NRAARgB6AAYADgBaACYsgoBWEABfPEISNwAzAEl1dRT6ItK83Ly0sqrVOtlXCxtUtpKO-IBmNLNLa1sAFQk9egAlJAtXdSQWAGEACwhKZBmrYcW9Um0kMHxGgDVtdW0nMDUtFLwtsFfKfxBtfD0NIAdgALFkAGw5UElCagiZZHogKAQaipABS5D2UHY5H0IAg+Hwoia9AAMuQoPhKZxpABpfiJIh2EzoNIFOElCGM4gsy7XW7qB5PF5vSgfEBIWjaYIgTxYqAAAWlYAAdAJyNR+BABBq4FBmY4XL82RyYdy8Dq9QaHM5XPybvdHs9Xmh3khPgB3bS1IgAIRsQLNXP46m9voDAgdguFLrFEqg5BI6noyb8eETyejTpFrtQtSSW0qICccAkrj+AKBwNhoIhWRhJWBDf4KLR9AAggI0bsTJaiSSU+g7EhPdwqGFOHYuLTZB2eczWelgxaQEy+VdHULnaK3eKPZKVfQdWjlRAZerNa2k0ghyBr1nNzGd3n3cXtEohwBtUDmU62eolFtY0czjPcE1RVJZHIX1PUObY2HWa5yAwNEDVbSDs23XN4wPIgliQOoAHF5mkUw8HwvRiNIrDY13fNCwPVFyH1PxUDSS1qBYg1aJfXC8H1D96C2SghlsfhBKIXicPAg8oCQIgAAUdHE9iSiyDSMwU5ThmksDUHdBI6GHRSFz0+jDORBSOy41i0G6DSsi0ogbO4qSn1Aiz9yMlzbPQ1AnLXYhXNY8zX28zBRHmCAAA8Qv8hzNMipBorivz3IFTzwpScoAF0KKTJJ7PUpKmWi0VZEcWhKAkLL+MwCAJDQogGAUvZyEBdBvVEFgtGgdRagrPAMEa5rWqIdr8DC+qRqasQiDYFp0FGcZClBUMtF0JBFMatwoDAcwkGkShZQfW9ViQygthYAQDiOfFM1vabZOGzZKQ7OAJqobQAC8kHweZyDWWxtA2Z6DIivQrvez72p0P6AfIRpmjIDzsP0t8gA";// Navigate to old uncompressed URL- await page.goto(`/?data=${OLD_UNCOMPRESSED_URL}`);+ await page.goto(`/?data=${OLD_UNCOMPRESSED_URL}`, { waitUntil: "commit" });// Verify the page loads without errorawait expect(page).toHaveURL(@@ -509,7 +511,7 @@ test.describe("Generate Invoice Link", () => {const newCompressedUrl ="/?template=stripe&data=N4IghiBcIA4DYgDQgEZRAWSxgBAEURwE0SikQBjdAVQGU9yATdAZwBcAnASxgFNz+0cgDMooAB7oAYmADWbAK4cwOAHYdoyAJ7oAjAHoADAA4AtACZD5gKwgAvsgDm6SzdMnTu28gAWLq9buZgDMuuRc6ABKvABuvBwsvDgAwj5gHI78yABWUJwKvMiyYiAAXnoA7AAshgBsxlXWwVXBht4gAILoAFIA9j6q+L1ZIABC6AAyvaqM04TUANLkyXrmzda15AyQ+YUgAKLo2f2qAAIAtmBccAB0FL3n5FKr65vIAOJ5HAXIABIvjTeIAAkl8fiA2Og2Lx2OQFFBhGA4IkHCAEJBQOVoLoKk0qrVDI1rBVCeQutAOhRzklkr1yONoAA5XgAd2IvQ4skIjKI81oXWQK2xa0BWzBe0O0DAVN4Fyut3uj2QkKEyHhO2+vFRj0gAG1QIZxchukbOuhaL1hGwWekknhYrw4L0YNTVJDkEsNeCJuhyBgEUjEshGVBdMgAPKmgAKrHiMS4FBGAEVTZFQ9ZDJnkLRTQAVdCMmPIaimgBq6czhmQAHVTQANKBVkBkL17ABaFczdgAushVJ2m3TW8gYOgWVwOElOGBVCxhPFyABHU0cfxuDzmKrkFi+5VRB0JJIUNIZEbq3bIGKmlniuxAA";- await page.goto(newCompressedUrl);+ await page.goto(newCompressedUrl, { waitUntil: "commit" });// Verify the page loads without errorawait expect(page).toHaveURL(newCompressedUrl);@@ -635,9 +637,6 @@ test.describe("Generate Invoice Link", () => {.getByRole("button", { name: "Generate a link to invoice" }).click();- // Wait for URL to update with share data- await page.waitForURL((url) => url.searchParams.has("data"));-// Verify the share invoice link description toast appears after generating the linkconst toast = page.getByTestId("share-invoice-link-description-toast");await expect(toast).toBeVisible();@@ -648,6 +647,9 @@ test.describe("Generate Invoice Link", () => {),).toBeVisible();+ // Wait for URL to update with share data+ await page.waitForURL((url) => url.searchParams.has("data"));+// Get the current URL which should now contain the share dataconst sharedUrl = page.url();expect(sharedUrl).toContain("?template=default&data=");diff --git a/e2e/invoice-form.test.ts b/e2e/invoice-form.test.tsindex 8c154d1..e21a6ad 100644--- a/e2e/invoice-form.test.ts+++ b/e2e/invoice-form.test.ts@@ -23,7 +23,7 @@ test.describe("Invoice Generator Page", () => {test("should redirect from /:locale/app to /", async ({ page }) => {// old url structure- await page.goto("/en/app");+ await page.goto("/en/app", { waitUntil: "commit" });await expect(page).toHaveURL("/?template=default");diff --git a/e2e/stripe-invoice-template/share-logic.test.ts b/e2e/stripe-invoice-template/share-logic.test.tsindex 632fdb0..aecabfc 100644--- a/e2e/stripe-invoice-template/share-logic.test.ts+++ b/e2e/stripe-invoice-template/share-logic.test.ts@@ -192,6 +192,7 @@ test.describe("Stripe Invoice Sharing Logic", () => {),).toBeVisible();+ // verify URL contains data parameterawait page.waitForURL((url) => url.searchParams.has("data"));const url = page.url();@@ -361,7 +362,7 @@ test.describe("Stripe Invoice Sharing Logic", () => {.getByRole("combobox", { name: "Invoice Template" }).selectOption("stripe");- await page.waitForURL("/?template=stripe");+ await expect(page).toHaveURL("/?template=stripe");// Locate the Net Price input for the first invoice itemconst netPriceInput = page.locator("#itemNetPrice0");@@ -398,6 +399,16 @@ test.describe("Stripe Invoice Sharing Logic", () => {// Click share button again — should succeed this timeawait shareButton.click();+ // Verify the share invoice link description toast appears after generating the link+ const toast = page.getByTestId("share-invoice-link-description-toast");+ await expect(toast).toBeVisible();++ await expect(+ page.getByText(+ "Share this link to let others view and edit this invoice",+ ),+ ).toBeVisible();+// Verify link was generated: URL should contain data paramawait page.waitForURL((url) => url.searchParams.has("data"));const url = page.url();@@ -408,15 +419,5 @@ test.describe("Stripe Invoice Sharing Logic", () => {const dataParam = urlObj.searchParams.get("data");expect(dataParam).toBeTruthy();expect(dataParam).not.toBe("");-- // Verify the share invoice link description toast appears after generating the link- const toast = page.getByTestId("share-invoice-link-description-toast");- await expect(toast).toBeVisible();-- await expect(- page.getByText(- "Share this link to let others view and edit this invoice",- ),- ).toBeVisible();});});diff --git a/playwright.config.ts b/playwright.config.tsindex c606659..24727b1 100644--- a/playwright.config.ts+++ b/playwright.config.ts@@ -55,6 +55,9 @@ export default defineConfig({/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */trace: "retain-on-failure",++ // set timezone to Europe/Warsaw by default for consistent date handling across local machines and CI+ timezoneId: "Europe/Warsaw",},/* Configure projects for major browsers */diff --git a/src/app/(app)/page.client.tsx b/src/app/(app)/page.client.tsxindex cc07bd7..73e49b6 100644--- a/src/app/(app)/page.client.tsx+++ b/src/app/(app)/page.client.tsx@@ -560,11 +560,11 @@ export function AppPageClient({// Construct full URL with locale and compressed dataconst newGeneratedLinkFullUrl = `${window.location.origin}/?${currentParams.toString()}`;- // Copy to clipboard+ // allow sharing invoice via navigator.share (on mobile and tablet) or copy to clipboard (on desktop)if (!isUADesktop && navigator?.share) {// MOBILE + TABLETtry {- toast.success("Invoice link generated - Share invoice", {+ toast.success("Your invoice link is ready. Share it now.", {id: "invoice-link-generated-share-invoice-success-toast",description: (<p data-testid="share-invoice-link-description-toast">@@ -577,7 +577,7 @@ export function AppPageClient({await navigator?.share({- title: "Invoice link generated - Share invoice",+ title: "Your invoice link is ready. Share it now.",url: newGeneratedLinkFullUrl,}).then(() => {@@ -588,10 +588,15 @@ export function AppPageClient({invoiceSharedCount: (current?.invoiceSharedCount ?? 0) + 1,}));- // show CTA toast after x seconds (after invoice link notification is shown)+ // dismiss other toasts when navigator.share is successful (for better UX)+ setTimeout(() => {+ toast.dismiss();+ }, 1000);++ // show CTA toast after x secondssetTimeout(() => {showRandomCTAToast();- }, 5_500);+ }, 2_500);}).catch((err) => {console.error(@@ -629,7 +634,7 @@ export function AppPageClient({await navigator?.clipboard?.writeText(newGeneratedLinkFullUrl).then(() => {- toast.success("Invoice link copied to clipboard!", {+ toast.success("Invoice link generated and copied to clipboard!", {id: "invoice-link-copied-to-clipboard-success-toast",description: (<p data-testid="share-invoice-link-description-toast">diff --git a/src/app/layout.tsx b/src/app/layout.tsxindex f259311..be74c73 100644--- a/src/app/layout.tsx+++ b/src/app/layout.tsx@@ -101,7 +101,9 @@ export default async function RootLayout({{/* should only be enabled in production */}{process.env.VERCEL_ENV === "production" && (<>- <SpeedInsights />+ <SpeedInsights+ sampleRate={0.3} // send only x% of the requests to Speed Insights (for cost-saving)+ />{/* https://eu.umami.is/dashboard */}<Script// we proxy umami check next.config.mjs rewrites