mirror of
https://github.com/VladSez/easy-invoice-pdf
synced 2026-04-21 13:37:40 +00:00
* refactor: remove redundant toast dismissal in invoice form PDF regeneration logic * test: enhance invoice item deletion confirmation flow in e2e tests * Updated e2e tests to verify the visibility of the delete confirmation dialog and its cancel flow. * Improved checks for item presence after cancellation and confirmed deletion scenarios. * Added data-testid to the confirmation dialog for better test targeting and reliability. * feat: enhance invoice item deletion handling in InvoiceForm * Introduced a ref to manage the deletion state of invoice items, preventing toast notifications from closing during item removal. * Updated the PDF regeneration logic to conditionally dismiss toasts based on the deletion state, improving user experience during invoice updates. * feat: implement currency combobox for improved currency selection in invoice form * Replaced the native currency select with a searchable combobox component, enhancing user experience. * Updated related tests to verify the functionality of the new combobox, including currency selection and visibility of options. * Organized currencies into groups for better accessibility and usability in the combobox. * test: enhance currency selection validation in invoice form tests * Updated e2e tests for the Invoice Generator and Default Invoice Template to verify that the selected currency is correctly saved in the hidden input field. * Added checks to ensure the currency value is accurately reflected after selection in both the main and mobile currency comboboxes. * Marked test suites as focused to streamline testing during development. * feat: enhance QR code generation and mobile handling in invoice components * Updated QR code generation logic to dynamically adjust error correction level and pixel width based on input length, improving scannability. * Added prop to various components to optimize UI behavior for mobile devices, including toast message positioning. * Increased timeout for expect assertions in Playwright configuration from 25,000ms to 35,000ms for improved test reliability. * Updated snapshot images for invoice templates to reflect recent changes in QR code rendering. * feat: add validation for currency groups in schema * Implemented checks to ensure all supported currencies are unique and correctly grouped. * Added error handling for duplicate currencies within groups and for missing currencies in the supported list. * Enhanced overall currency validation logic to improve data integrity in the application.
173 lines
5.2 KiB
TypeScript
173 lines
5.2 KiB
TypeScript
import { defineConfig, devices } from "@playwright/test";
|
|
|
|
import dotenv from "dotenv";
|
|
import path from "node:path";
|
|
|
|
/**
|
|
* Read environment variables from file.
|
|
* https://github.com/motdotla/dotenv
|
|
*/
|
|
dotenv.config({ path: path.resolve(__dirname, ".env.local"), quiet: true });
|
|
|
|
// Use process.env.PORT by default and fallback to port 3000
|
|
const PORT = process.env.PORT ?? 3000;
|
|
|
|
// Set webServer.url and use.baseURL with the location of the WebServer respecting the correct set port
|
|
const BASE_URL = process.env.BASE_URL ?? `http://localhost:${PORT}`;
|
|
|
|
// @ts-expect-error - NODE_ENV is not defined in the environment variables
|
|
const isLocal = process.env.NODE_ENV === "local";
|
|
|
|
/**
|
|
* See https://playwright.dev/docs/test-configuration.
|
|
*/
|
|
export default defineConfig({
|
|
testDir: "./e2e",
|
|
/* Run tests in files in parallel */
|
|
fullyParallel: true,
|
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
forbidOnly: !!process.env.CI,
|
|
/* Retry on CI only */
|
|
retries: process.env.CI ? 2 : 0,
|
|
/* Opt out of parallel tests on CI. */
|
|
workers: process.env.CI ? 1 : undefined, // IMPORTANT: if tests are flaky locally, make `workers: 1` or `workers: 2`
|
|
/* timeout for expect assertions */
|
|
expect: {
|
|
timeout: isLocal ? 15_000 : 35_000,
|
|
},
|
|
|
|
// /* timeout for test execution */
|
|
timeout: isLocal ? 40_000 : 60_000, // i.e. 60 seconds,
|
|
|
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
reporter: [["html", { outputFolder: "playwright-output/report" }]],
|
|
|
|
/* Output directory for test artifacts */
|
|
outputDir: "playwright-output/test-results",
|
|
|
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
use: {
|
|
// Use baseURL so to make navigations relative.
|
|
// More information: https://playwright.dev/docs/api/class-testoptions#test-options-base-url
|
|
baseURL: BASE_URL,
|
|
|
|
/* 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 inside browser
|
|
timezoneId: "Europe/Warsaw",
|
|
|
|
// applies to: page.goto(), redirects, page.waitForURL(), clicking links that trigger navigation, form submits that navigate
|
|
navigationTimeout: 45_000,
|
|
// Applies to interactions: locator.click(), fill(), check(), hover(), press(), dragTo()
|
|
actionTimeout: 15_000,
|
|
},
|
|
|
|
/* Configure projects for major browsers */
|
|
projects: [
|
|
{
|
|
name: "Desktop Chrome",
|
|
use: {
|
|
...devices["Desktop Chrome"],
|
|
channel: "chromium",
|
|
permissions: ["clipboard-read", "clipboard-write"],
|
|
|
|
// Disable GPU to prevent rendering issues in headless mode
|
|
launchOptions: {
|
|
args: ["--disable-font-subpixel-positioning", "--disable-lcd-text"],
|
|
},
|
|
// Set localStorage to disable umami analytics
|
|
storageState: {
|
|
cookies: [],
|
|
origins: [
|
|
{
|
|
origin: BASE_URL,
|
|
localStorage: [
|
|
{
|
|
name: "umami.disabled",
|
|
value: "1",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
// {
|
|
// name: "webkit",
|
|
// use: { ...devices["Desktop Safari"] },
|
|
// },
|
|
|
|
// /* Test against mobile viewports. */
|
|
{
|
|
name: "Mobile Chrome",
|
|
use: {
|
|
...devices["Pixel 5"],
|
|
channel: "chromium",
|
|
permissions: ["clipboard-read", "clipboard-write"],
|
|
// Disable GPU to prevent rendering issues in headless mode
|
|
launchOptions: {
|
|
args: ["--disable-font-subpixel-positioning", "--disable-lcd-text"],
|
|
},
|
|
// Set localStorage to disable umami analytics
|
|
storageState: {
|
|
cookies: [],
|
|
origins: [
|
|
{
|
|
origin: BASE_URL,
|
|
localStorage: [
|
|
{
|
|
name: "umami.disabled",
|
|
value: "1",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Mobile Safari",
|
|
use: {
|
|
...devices["iPhone 13 Pro"],
|
|
// on iOS we don't need to grant clipboard permissions
|
|
// Disable GPU to prevent rendering issues in headless mode
|
|
launchOptions: {
|
|
args: ["--disable-font-subpixel-positioning", "--disable-lcd-text"],
|
|
},
|
|
// Set localStorage to disable umami analytics
|
|
storageState: {
|
|
cookies: [],
|
|
origins: [
|
|
{
|
|
origin: BASE_URL,
|
|
localStorage: [
|
|
{
|
|
name: "umami.disabled",
|
|
value: "1",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
|
|
/* Test against branded browsers. */
|
|
// {
|
|
// name: 'Microsoft Edge',
|
|
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
|
// },
|
|
// {
|
|
// name: 'Google Chrome',
|
|
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
|
// },
|
|
],
|
|
|
|
/* Run your local dev server before starting the tests */
|
|
// webServer: {
|
|
// command: 'npm run start',
|
|
// url: 'http://127.0.0.1:3000',
|
|
// reuseExistingServer: !process.env.CI,
|
|
// },
|
|
});
|