test: cover external staging queue UI
This commit is contained in:
@@ -62,4 +62,28 @@ for (const viewport of [{ name: "desktop", width: 1280, height: 900 }, { name: "
|
||||
const dimensions = await page.evaluate(() => ({ width: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth }));
|
||||
expect(dimensions.scroll).toBeLessThanOrEqual(dimensions.width);
|
||||
});
|
||||
|
||||
test(`external staging queue is safe on ${viewport.name}`, async ({ page }) => {
|
||||
await page.setViewportSize(viewport);
|
||||
let mutations = 0;
|
||||
await page.route("**/api/v1/**", async route => {
|
||||
const request = route.request();
|
||||
if (request.method() !== "GET") mutations += 1;
|
||||
const path = new URL(request.url()).pathname;
|
||||
if (path.endsWith("/fishes")) return route.fulfill({ json: [{ slug: "pike", name_ru: "Щука" }] });
|
||||
if (path.endsWith("/waterbodies")) return route.fulfill({ json: [{ slug: "kuori", name_ru: "Куори" }] });
|
||||
if (path.endsWith("/admin/external-observations")) return route.fulfill({ json: [{ id: "10000000-0000-0000-0000-000000000001", source_system: "rf4db", source_external_id: "fixture-1", source_url: "https://rf4db.com/fixture-1", fish_name: "Pike", waterbody_name: "Kuori", x: 72, y: 84, weight_g: null, status: "staged", fish_slug: null, waterbody_slug: null, review_note: null }] });
|
||||
return route.fulfill({ status: 404 });
|
||||
});
|
||||
await page.goto("/admin/external-sources");
|
||||
await page.getByLabel("Административный токен").fill("test-token-not-sent");
|
||||
await page.getByRole("button", { name: "Открыть очередь" }).click();
|
||||
const card = page.locator(".moderation-card");
|
||||
await expect(card).toContainText("rf4db");
|
||||
await expect(card.getByLabel("Каноническая рыба")).toContainText("Щука");
|
||||
await expect(card.getByRole("button", { name: "Опубликовать" })).toBeDisabled();
|
||||
expect(mutations).toBe(0);
|
||||
const dimensions = await page.evaluate(() => ({ width: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth }));
|
||||
expect(dimensions.scroll).toBeLessThanOrEqual(dimensions.width);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user