import { test, expect } from "@playwright/test" import { backup, setupBackups } from "./fixtures/backups" test("Бэкапы URL: поиск, тип, вкладка, reload и Back/Forward", async ({ page }) => { await setupBackups(page); await page.goto("/backups?kind=manual&q=live&keep=1#context") await expect(page.getByPlaceholder("Поиск по файлу, серверу, заметке…")).toHaveValue("live"); await expect(page.getByText(backup.filename, { exact: true })).toBeVisible() await page.getByRole("tab", { name: "Настройки", exact: true }).click(); await expect(page).toHaveURL(/tab=settings/); await expect(page).toHaveURL(/keep=1/); await expect(page).toHaveURL(/#context$/) await page.reload(); await expect(page.getByRole("tab", { name: "Настройки", exact: true })).toHaveAttribute("aria-selected", "true") await page.goBack(); await expect(page.getByRole("tab", { name: "История бэкапов", exact: true })).toHaveAttribute("aria-selected", "true"); await expect(page.getByPlaceholder("Поиск по файлу, серверу, заметке…")).toHaveValue("live") await page.goForward(); await expect(page.getByRole("tab", { name: "Настройки", exact: true })).toHaveAttribute("aria-selected", "true") }) test("Бэкапы URL: advanced Filters из ссылки сохраняют срез после reload", async ({ page }) => { await setupBackups(page); await page.route("**/api/backups", r => r.fulfill({ json: [backup, { ...backup, id: "other", filename: "other.rsc", storage: "s3" }] })) const filters = JSON.stringify({ v: 1, query: { id: "root", type: "group", combinator: "and", rules: [{ id: "rule-1", type: "rule", path: ["storage"], operator: "is", value: "s3" }] } }) await page.goto("/backups?filters=" + encodeURIComponent(filters)); await expect(page.getByText("other.rsc", { exact: true })).toBeVisible(); await expect(page.getByText(backup.filename, { exact: true })).toHaveCount(0) await page.reload(); await expect(page.getByText("other.rsc", { exact: true })).toBeVisible(); await expect(page.getByText(backup.filename, { exact: true })).toHaveCount(0) }) for (const raw of ["kind=bad", "filters=bad", "tab=settings&tab=history"]) test("Бэкапы URL: ошибочный контекст/" + raw, async ({ page }) => { await setupBackups(page); await page.goto("/backups?keep=1&" + raw) await expect(page.getByRole("alert", { name: "Контекст резервных копий", exact: true })).toBeVisible(); await expect(page.getByText(backup.filename, { exact: true })).toHaveCount(0) await page.getByRole("button", { name: "Сбросить контекст", exact: true }).click(); await expect(page.getByText(backup.filename, { exact: true })).toBeVisible(); await expect(page).toHaveURL(/keep=1/) })