ci: add quality-gate workflow, ESLint and Playwright smoke test

This commit is contained in:
soubarna
2026-10-05 17:29:03 +05:30
parent b6cf46b883
commit 9ba00045c9
9 changed files with 1625 additions and 3 deletions
+69
View File
@@ -0,0 +1,69 @@
import { expect, test, type Page } from "@playwright/test";
// The app talks to its Rust backend through Tauri's `invoke`, which does not exist in a plain
// browser. These smoke tests cover the web build in both situations: without the backend (the app
// must fail gracefully) and with a minimal stubbed backend (the app shell must render).
const SETTINGS = {
vendorName: "Smoke Test Studio",
vendorAddress: "1 Test Street",
vendorEmail: "smoke@example.com",
vendorPhone: "",
vendorPan: "",
vendorGstin: "",
vendorStateCode: "",
logoPath: null,
signaturePath: null,
defaultBankId: null,
defaultTaxRate: 0,
defaultTaxType: "none",
paymentTermsDays: 15,
currency: "INR",
onboarded: true,
theme: "g10",
gstRegistration: "unregistered",
defaultHsnSac: "",
signatoryName: "",
signatoryDesignation: "",
renderPrefs: "",
logoOriginalPath: null,
logoKnockoutPath: null,
logoMeta: "",
logoIncludesName: "auto",
};
function collectPageErrors(page: Page): string[] {
const errors: string[] = [];
page.on("pageerror", (err) => errors.push(err.message));
return errors;
}
test("web build loads without a backend and fails gracefully", async ({ page }) => {
const errors = collectPageErrors(page);
await page.goto("/");
await expect(page).toHaveTitle("Voiced");
await expect(page.getByText("Could not start Voiced")).toBeVisible();
expect(errors).toEqual([]);
});
test("app shell renders with a stubbed backend", async ({ page }) => {
const errors = collectPageErrors(page);
await page.addInitScript((settings) => {
const w = window as unknown as { __TAURI_INTERNALS__: unknown };
w.__TAURI_INTERNALS__ = {
transformCallback: () => 0,
invoke: async (cmd: string) => {
if (cmd === "get_settings") return settings;
if (cmd.startsWith("list_")) return [];
return null;
},
};
}, SETTINGS);
await page.goto("/");
const nav = page.getByRole("navigation", { name: "Voiced navigation" });
await expect(nav).toBeVisible();
for (const label of ["Clients", "Settings"]) {
await expect(nav.getByText(label, { exact: true })).toBeVisible();
}
expect(errors).toEqual([]);
});