mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test(e2e): fix stale route + fixture paths in erase-object spec (#321)
The spec used the bare /erase-object route (404 under section URLs) and the old flat fixture path (test-200x150.png moved to image/valid/), so every test silently skipped. Point it at /image/erase-object and the correct fixture, and add a 404 guard so future route rot fails loudly instead of skipping.
This commit is contained in:
@@ -16,7 +16,10 @@ async function uploadFile(page: import("@playwright/test").Page, filePath: strin
|
|||||||
|
|
||||||
test.describe("Erase Object tool", () => {
|
test.describe("Erase Object tool", () => {
|
||||||
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
||||||
await page.goto("/erase-object");
|
await page.goto("/image/erase-object");
|
||||||
|
// Guard against route rot: a wrong/404 route must fail loudly, not silently skip
|
||||||
|
// (skipping on a missing submit button previously masked the route being broken).
|
||||||
|
await expect(page.getByRole("heading", { name: "404" })).toHaveCount(0);
|
||||||
try {
|
try {
|
||||||
await page.getByTestId("erase-object-submit").waitFor({ state: "visible", timeout: 15_000 });
|
await page.getByTestId("erase-object-submit").waitFor({ state: "visible", timeout: 15_000 });
|
||||||
} catch {
|
} catch {
|
||||||
@@ -48,7 +51,7 @@ test.describe("Erase Object tool", () => {
|
|||||||
loggedInPage: page,
|
loggedInPage: page,
|
||||||
}) => {
|
}) => {
|
||||||
await skipIfFeatureNotInstalled(page);
|
await skipIfFeatureNotInstalled(page);
|
||||||
await uploadFile(page, fixturePath("test-200x150.png"));
|
await uploadFile(page, fixturePath("image/valid/test-200x150.png"));
|
||||||
|
|
||||||
// Submit should still be disabled because no strokes have been painted
|
// Submit should still be disabled because no strokes have been painted
|
||||||
await expect(page.getByTestId("erase-object-submit")).toBeDisabled();
|
await expect(page.getByTestId("erase-object-submit")).toBeDisabled();
|
||||||
@@ -91,7 +94,7 @@ test.describe("Erase Object tool", () => {
|
|||||||
await skipIfFeatureNotInstalled(page);
|
await skipIfFeatureNotInstalled(page);
|
||||||
|
|
||||||
// Upload first file
|
// Upload first file
|
||||||
await uploadFile(page, fixturePath("test-200x150.png"));
|
await uploadFile(page, fixturePath("image/valid/test-200x150.png"));
|
||||||
|
|
||||||
// Paint a stroke on the first file
|
// Paint a stroke on the first file
|
||||||
const canvas = page.locator("canvas");
|
const canvas = page.locator("canvas");
|
||||||
@@ -111,7 +114,7 @@ test.describe("Erase Object tool", () => {
|
|||||||
const fileChooserPromise = page.waitForEvent("filechooser");
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
||||||
await page.getByRole("button", { name: /Add more/i }).click();
|
await page.getByRole("button", { name: /Add more/i }).click();
|
||||||
const fileChooser = await fileChooserPromise;
|
const fileChooser = await fileChooserPromise;
|
||||||
await fileChooser.setFiles(fixturePath("test-200x150.png"));
|
await fileChooser.setFiles(fixturePath("image/valid/test-200x150.png"));
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
|
|
||||||
// Switch to second file (click thumbnail or file entry)
|
// Switch to second file (click thumbnail or file entry)
|
||||||
@@ -135,7 +138,7 @@ test.describe("Erase Object tool", () => {
|
|||||||
await skipIfFeatureNotInstalled(page);
|
await skipIfFeatureNotInstalled(page);
|
||||||
|
|
||||||
// Upload first file
|
// Upload first file
|
||||||
await uploadFile(page, fixturePath("test-200x150.png"));
|
await uploadFile(page, fixturePath("image/valid/test-200x150.png"));
|
||||||
|
|
||||||
// Paint on first file
|
// Paint on first file
|
||||||
const canvas = page.locator("canvas");
|
const canvas = page.locator("canvas");
|
||||||
@@ -155,7 +158,7 @@ test.describe("Erase Object tool", () => {
|
|||||||
const fileChooserPromise = page.waitForEvent("filechooser");
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
||||||
await page.getByRole("button", { name: /Add more/i }).click();
|
await page.getByRole("button", { name: /Add more/i }).click();
|
||||||
const fileChooser = await fileChooserPromise;
|
const fileChooser = await fileChooserPromise;
|
||||||
await fileChooser.setFiles(fixturePath("test-200x150.png"));
|
await fileChooser.setFiles(fixturePath("image/valid/test-200x150.png"));
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
|
|
||||||
// Switch to second file and paint
|
// Switch to second file and paint
|
||||||
|
|||||||
Reference in New Issue
Block a user