mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-09-19 09:40:13 +00:00
fix: migrate tables to TanStack React Table v9
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { expect } from "@playwright/test"
|
||||
|
||||
import { test } from "./fixtures"
|
||||
|
||||
type AgentServer = {
|
||||
host?: { platform?: string }
|
||||
id: number
|
||||
last_active?: string
|
||||
name: string
|
||||
uuid: string
|
||||
}
|
||||
|
||||
test("a real agent reports to the dashboard and is selectable in the server table", async ({
|
||||
adminPage: page,
|
||||
}) => {
|
||||
const agentUUID = process.env.E2E_AGENT_UUID
|
||||
expect(agentUUID, "E2E_AGENT_UUID must identify the Agent started by CI").toBeTruthy()
|
||||
|
||||
let agentServer: AgentServer | undefined
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const response = await page.request.get("/api/v1/server")
|
||||
if (!response.ok()) return false
|
||||
|
||||
const body = (await response.json()) as { data?: AgentServer[] }
|
||||
agentServer = body.data?.find((server) => server.uuid === agentUUID)
|
||||
if (!agentServer?.last_active || !agentServer.host?.platform) return false
|
||||
|
||||
return new Date(agentServer.last_active).getTime() > 0
|
||||
},
|
||||
{
|
||||
message: "the real Agent must register and report live host state",
|
||||
timeout: 30_000,
|
||||
},
|
||||
)
|
||||
.toBe(true)
|
||||
|
||||
await page.goto("/dashboard")
|
||||
|
||||
const row = page.getByRole("row").filter({
|
||||
has: page.getByText(agentServer!.name, { exact: true }),
|
||||
})
|
||||
await expect(row).toHaveCount(1)
|
||||
|
||||
const selection = row.getByRole("checkbox", { name: "Select row" })
|
||||
await expect(selection).not.toBeChecked()
|
||||
await selection.click()
|
||||
await expect(selection).toBeChecked()
|
||||
})
|
||||
@@ -1,12 +1,11 @@
|
||||
import { expect } from "@playwright/test"
|
||||
|
||||
import { csrfHeaders, test } from "./fixtures"
|
||||
import { csrfRequest, test } from "./fixtures"
|
||||
|
||||
test("manual cron trigger goes through POST, not GET", async ({ adminPage: page }) => {
|
||||
const created = await page.request.post("/api/v1/cron", {
|
||||
headers: await csrfHeaders(page),
|
||||
const created = await csrfRequest(page, "post", "/api/v1/cron", {
|
||||
data: {
|
||||
name: "e2e-cron-csrf",
|
||||
name: `e2e-cron-csrf-${Date.now().toString(36)}`,
|
||||
task_type: 0,
|
||||
scheduler: "@every 1h",
|
||||
command: "true",
|
||||
@@ -29,15 +28,12 @@ test("manual cron trigger goes through POST, not GET", async ({ adminPage: page
|
||||
`GET must no longer be routable (got ${getResp.status()})`,
|
||||
).toBeTruthy()
|
||||
|
||||
const postResp = await page.request.post(`/api/v1/cron/${cronID}/manual`, {
|
||||
headers: await csrfHeaders(page),
|
||||
})
|
||||
const postResp = await csrfRequest(page, "post", `/api/v1/cron/${cronID}/manual`)
|
||||
expect(postResp.ok(), `POST must succeed (got ${postResp.status()})`).toBeTruthy()
|
||||
const body = await postResp.json()
|
||||
expect(body.success).toBe(true)
|
||||
} finally {
|
||||
await page.request.post("/api/v1/batch-delete/cron", {
|
||||
headers: await csrfHeaders(page),
|
||||
await csrfRequest(page, "post", "/api/v1/batch-delete/cron", {
|
||||
data: [cronID],
|
||||
})
|
||||
}
|
||||
|
||||
+13
-10
@@ -1,8 +1,10 @@
|
||||
import { expect } from "@playwright/test"
|
||||
|
||||
import { csrfHeaders, test } from "./fixtures"
|
||||
import { csrfRequest, test } from "./fixtures"
|
||||
|
||||
test("file manager creation only accepts POST", async ({ adminPage: page }) => {
|
||||
test("file manager creation only accepts POST and reaches the connected Agent", async ({
|
||||
adminPage: page,
|
||||
}) => {
|
||||
const getResp = await page.request.get("/api/v1/file?id=1", {
|
||||
failOnStatusCode: false,
|
||||
})
|
||||
@@ -11,15 +13,16 @@ test("file manager creation only accepts POST", async ({ adminPage: page }) => {
|
||||
`GET /api/v1/file must no longer be routable (got ${getResp.status()})`,
|
||||
).toBeTruthy()
|
||||
|
||||
const postResp = await page.request.post("/api/v1/file?id=1", {
|
||||
const postResp = await csrfRequest(page, "post", "/api/v1/file?id=1", {
|
||||
failOnStatusCode: false,
|
||||
headers: await csrfHeaders(page),
|
||||
})
|
||||
expect(postResp.status()).toBe(200)
|
||||
const body = await postResp.json()
|
||||
expect(
|
||||
body.success,
|
||||
"without a connected agent server the POST surfaces a Service error, but the route is reachable",
|
||||
).not.toBe(true)
|
||||
expect(body.error).toBeTruthy()
|
||||
const body = (await postResp.json()) as {
|
||||
data?: { session_id?: string }
|
||||
success?: boolean
|
||||
}
|
||||
expect(body.success, "POST must create a file-manager session through the real Agent").toBe(
|
||||
true,
|
||||
)
|
||||
expect(body.data?.session_id).toBeTruthy()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user