const __vite_ssr_import_0__ = await __vite_ssr_import__("/web/node_modules/@tanstack/react-query/build/modern/index.js", {"importedNames":["QueryClient","QueryClientProvider"]});
const __vite_ssr_import_1__ = await __vite_ssr_import__("/web/node_modules/@tanstack/react-router/dist/esm/index.dev.js", {"importedNames":["createMemoryHistory","createRootRoute","createRoute","createRouter","RouterProvider"]});
const __vite_ssr_import_2__ = await __vite_ssr_import__("/web/node_modules/@testing-library/react/dist/index.js", {"importedNames":["fireEvent","render","screen","within"]});
const __vite_ssr_import_3__ = await __vite_ssr_import__("/web/node_modules/msw/lib/core/index.mjs", {"importedNames":["http","HttpResponse"]});
const __vite_ssr_import_4__ = await __vite_ssr_import__("/web/node_modules/msw/lib/node/index.mjs", {"importedNames":["setupServer"]});
const __vite_ssr_import_5__ = await __vite_ssr_import__("/@fs/C:/Users/Admin/AppData/Local/npm-cache/_npx/69c381f8ad94b576/node_modules/vitest/dist/index.js", {"importedNames":["afterAll","afterEach","beforeAll","describe","expect","it"]});
const __vite_ssr_import_6__ = await __vite_ssr_import__("@/shared/i18n");
const __vite_ssr_import_7__ = await __vite_ssr_import__("/web/src/pages/jobs/JobsPage.tsx", {"importedNames":["JobsPage"]});
const __vite_ssr_import_8__ = await __vite_ssr_import__("/web/node_modules/react/jsx-dev-runtime.js", {"importedNames":["jsxDEV"]});








var _jsxFileName = "D:/GitHub/ViceCut/web/src/pages/jobs/JobsPage.test.tsx";

const NOW = new Date().toISOString();
const base = {
	id: "a",
	kind: "scan_vod",
	status: "succeeded",
	progress: 1,
	step: "",
	error: null,
	result_ref: "3 clips from 9 moments",
	params: {},
	created_at: NOW,
	updated_at: NOW,
	detail: null
};
const running = {
	...base,
	id: "b",
	kind: "rehook_clip",
	status: "running",
	progress: .4,
	result_ref: null,
	step: "Rendering",
	detail: {
		stages: [{
			key: "hook",
			status: "done",
			weight: 2,
			fraction: 1,
			detail: "",
			items_done: 0,
			items_total: null,
			metrics: {},
			error: null
		}, {
			key: "rendering",
			status: "running",
			weight: 6,
			fraction: .2,
			detail: "Rendering the clip with the new hook",
			items_done: 0,
			items_total: null,
			metrics: {
				seconds_done: 9,
				seconds_total: 45,
				speed_x: 2.4
			},
			error: null
		}],
		current_stage: "rendering",
		overall: .4,
		eta_s: null,
		started_at: NOW,
		updated_at: NOW,
		items: []
	}
};
const state = { jobs: [] };
const server = (0,__vite_ssr_import_4__.setupServer)(__vite_ssr_import_3__.http.get(/\/api\/v1\/jobs$/, () => __vite_ssr_import_3__.HttpResponse.json(state.jobs)), __vite_ssr_import_3__.http.get(/\/api\/v1\/jobs\/[abc]\/events$/, () => __vite_ssr_import_3__.HttpResponse.json([])));
(0,__vite_ssr_import_5__.beforeAll)(() => server.listen({ onUnhandledRequest: "error" }));
(0,__vite_ssr_import_5__.afterEach)(() => {
	state.jobs = [];
});
(0,__vite_ssr_import_5__.afterAll)(() => server.close());
function show(at = "/") {
	const rootRoute = (0,__vite_ssr_import_1__.createRootRoute)();
	const route = (0,__vite_ssr_import_1__.createRoute)({
		getParentRoute: () => rootRoute,
		path: "/",
		component: __vite_ssr_import_7__.JobsPage
	});
	const router = (0,__vite_ssr_import_1__.createRouter)({
		routeTree: rootRoute.addChildren([route]),
		history: (0,__vite_ssr_import_1__.createMemoryHistory)({ initialEntries: [at] })
	});
	(0,__vite_ssr_import_2__.render)(/* @__PURE__ */ (0,__vite_ssr_import_8__.jsxDEV)((0,__vite_ssr_import_0__.QueryClientProvider), {
		client: new __vite_ssr_import_0__.QueryClient(),
		children: /* @__PURE__ */ (0,__vite_ssr_import_8__.jsxDEV)((0,__vite_ssr_import_1__.RouterProvider), { router }, void 0, false, {
			fileName: _jsxFileName,
			lineNumber: 79,
			columnNumber: 7
		}, this)
	}, void 0, false, {
		fileName: _jsxFileName,
		lineNumber: 78,
		columnNumber: 5
	}, this));
}
(0,__vite_ssr_import_5__.describe)("JobsPage", () => {
	(0,__vite_ssr_import_5__.it)("says so when there are no jobs", async () => {
		show();
		(0,__vite_ssr_import_5__.expect)(await __vite_ssr_import_2__.screen.findByText("No jobs yet.")).toBeInTheDocument();
	});
	(0,__vite_ssr_import_5__.it)("puts what the running job is doing in its row and opens its panel by default", async () => {
		state.jobs = [base, running];
		show();
		const panel = await __vite_ssr_import_2__.screen.findByRole("region", { name: "Details of Rewrite hook" });
		(0,__vite_ssr_import_5__.expect)((0,__vite_ssr_import_2__.within)(panel).getByText("Rendering the clip with the new hook")).toBeInTheDocument();
		(0,__vite_ssr_import_5__.expect)((0,__vite_ssr_import_2__.within)(panel).getByText(/9:00|09 of video|00:09 \/ 00:45 of video/)).toBeInTheDocument();
		const list = __vite_ssr_import_2__.screen.getByRole("list", { name: "Jobs" });
		(0,__vite_ssr_import_5__.expect)((0,__vite_ssr_import_2__.within)(list).getByText(/40% · Rendering the clip with the new hook/)).toBeInTheDocument();
		(0,__vite_ssr_import_5__.expect)((0,__vite_ssr_import_2__.within)(list).getByText("3 clips from 9 moments")).toBeInTheDocument();
	});
	(0,__vite_ssr_import_5__.it)("switches the panel to the job you pick and names the video it scans", async () => {
		state.jobs = [{
			...base,
			params: {
				url: "https://youtu.be/abcdefghijk",
				title: "GTA VI #6"
			}
		}, running];
		show();
		await __vite_ssr_import_2__.screen.findByRole("region", { name: "Details of Rewrite hook" });
		const pick = (0,__vite_ssr_import_2__.within)(__vite_ssr_import_2__.screen.getByRole("list", { name: "Jobs" })).getByRole("button", { name: /Scan video · GTA VI #6/ });
		__vite_ssr_import_2__.fireEvent.click(pick);
		const panel = await __vite_ssr_import_2__.screen.findByRole("region", { name: "Details of Scan video" });
		(0,__vite_ssr_import_5__.expect)((0,__vite_ssr_import_2__.within)(panel).getByText("GTA VI #6")).toBeInTheDocument();
		(0,__vite_ssr_import_5__.expect)(pick).toHaveAttribute("aria-pressed", "true");
	});
	(0,__vite_ssr_import_5__.it)("shows the clip jobs first and the searches and checks under All jobs", async () => {
		state.jobs = [base, {
			...base,
			id: "c",
			kind: "find_videos",
			result_ref: "4 new videos"
		}];
		show();
		const list = await __vite_ssr_import_2__.screen.findByRole("list", { name: "Jobs" });
		(0,__vite_ssr_import_5__.expect)((0,__vite_ssr_import_2__.within)(list).queryByText("4 new videos")).not.toBeInTheDocument();
		__vite_ssr_import_2__.fireEvent.mouseDown(__vite_ssr_import_2__.screen.getByRole("tab", { name: "All jobs" }));
		(0,__vite_ssr_import_5__.expect)(await (0,__vite_ssr_import_2__.within)(__vite_ssr_import_2__.screen.getByRole("list", { name: "Jobs" })).findByText("4 new videos")).toBeInTheDocument();
	});
	(0,__vite_ssr_import_5__.it)("opens the job an Open job link names, even a search", async () => {
		state.jobs = [running, {
			...base,
			id: "c",
			kind: "find_videos",
			result_ref: "4 new videos"
		}];
		show("/?job=c");
		(0,__vite_ssr_import_5__.expect)(await __vite_ssr_import_2__.screen.findByRole("region", { name: "Details of Find GTA VI videos" })).toBeInTheDocument();
	});
});

//# vitestCache=W3siZmlsZSI6IjEiLCJpZCI6IjEiLCJpbXBvcnRzIjoiMiIsIm1hcHBpbmdzIjpmYWxzZSwiZGVwcyI6IjMiLCJkeW5hbWljRGVwcyI6IjQiLCJzdGF0aWNNb2NrcyI6bnVsbCwiaGFzQ292ZXJhZ2VEYXRhIjpmYWxzZX0sIkQ6L0dpdEh1Yi9WaWNlQ3V0L3dlYi9zcmMvcGFnZXMvam9icy9Kb2JzUGFnZS50ZXN0LnRzeCIseyJ1cmxzIjoiNSIsImlkcyI6IjYifSxbIjciLCI4IiwiOSIsIjEwIiwiMTEiLCIxMiIsIjEzIiwiMTQiLCIxNSJdLFtdLFsiNyIsIjgiLCI5IiwiMTAiLCIxMSIsIjEyIiwiMTMiLCIxNCIsIjE1Il0se30sIi93ZWIvbm9kZV9tb2R1bGVzL0B0YW5zdGFjay9yZWFjdC1xdWVyeS9idWlsZC9tb2Rlcm4vaW5kZXguanMiLCIvd2ViL25vZGVfbW9kdWxlcy9AdGFuc3RhY2svcmVhY3Qtcm91dGVyL2Rpc3QvZXNtL2luZGV4LmRldi5qcyIsIi93ZWIvbm9kZV9tb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,WAAW,cAAc,CAAC,CAAC,CAAC,kBAAkB;CAChH,CAAC;CAED,6BAAG,uDAAuD,YAAY;EACpE,MAAM,OAAO,CAAC,SAAS;GAAE,GAAG;GAAM,IAAI;GAAK,MAAM;GAAe,YAAY;EAAe,CAAC;EAC5F,KAAK,SAAS;EACd,iCAAO,MAAM,6BAAO,WAAW,UAAU,EAAE,MAAM,gCAAgC,CAAC,CAAC,CAAC,CAAC,kBAAkB;CACzG,CAAC;AACH,CAAC","names":[],"ignoreList":[],"sources":["JobsPage.test.tsx"],"sourcesContent":["import { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { createMemoryHistory, createRootRoute, createRoute, createRouter, RouterProvider } from \"@tanstack/react-router\";\nimport { fireEvent, render, screen, within } from \"@testing-library/react\";\nimport { http, HttpResponse } from \"msw\";\nimport { setupServer } from \"msw/node\";\nimport { afterAll, afterEach, beforeAll, describe, expect, it } from \"vitest\";\n\nimport type { Job } from \"@/entities/job\";\nimport \"@/shared/i18n\";\n\nimport { JobsPage } from \"./JobsPage\";\n\nconst NOW = new Date().toISOString();\nconst base: Job = {\n  id: \"a\",\n  kind: \"scan_vod\",\n  status: \"succeeded\",\n  progress: 1,\n  step: \"\",\n  error: null,\n  result_ref: \"3 clips from 9 moments\",\n  params: {},\n  created_at: NOW,\n  updated_at: NOW,\n  detail: null,\n};\nconst running: Job = {\n  ...base,\n  id: \"b\",\n  kind: \"rehook_clip\",\n  status: \"running\",\n  progress: 0.4,\n  result_ref: null,\n  step: \"Rendering\",\n  detail: {\n    stages: [\n      { key: \"hook\", status: \"done\", weight: 2, fraction: 1, detail: \"\", items_done: 0, items_total: null, metrics: {}, error: null },\n      {\n        key: \"rendering\",\n        status: \"running\",\n        weight: 6,\n        fraction: 0.2,\n        detail: \"Rendering the clip with the new hook\",\n        items_done: 0,\n        items_total: null,\n        metrics: { seconds_done: 9, seconds_total: 45, speed_x: 2.4 },\n        error: null,\n      },\n    ],\n    current_stage: \"rendering\",\n    overall: 0.4,\n    eta_s: null,\n    started_at: NOW,\n    updated_at: NOW,\n    items: [],\n  },\n};\n\nconst state: { jobs: Job[] } = { jobs: [] };\nconst server = setupServer(\n  http.get(/\\/api\\/v1\\/jobs$/, () => HttpResponse.json(state.jobs)),\n  http.get(/\\/api\\/v1\\/jobs\\/[abc]\\/events$/, () => HttpResponse.json([])),\n);\nbeforeAll(() => server.listen({ onUnhandledRequest: \"error\" }));\nafterEach(() => {\n  state.jobs = [];\n});\nafterAll(() => server.close());\n\nfunction show(at = \"/\") {\n  const rootRoute = createRootRoute();\n  const route = createRoute({ getParentRoute: () => rootRoute, path: \"/\", component: JobsPage });\n  const router = createRouter({\n    routeTree: rootRoute.addChildren([route]),\n    history: createMemoryHistory({ initialEntries: [at] }),\n  });\n  render(\n    <QueryClientProvider client={new QueryClient()}>\n      <RouterProvider router={router} />\n    </QueryClientProvider>,\n  );\n}\n\ndescribe(\"JobsPage\", () => {\n  it(\"says so when there are no jobs\", async () => {\n    show();\n    expect(await screen.findByText(\"No jobs yet.\")).toBeInTheDocument();\n  });\n\n  it(\"puts what the running job is doing in its row and opens its panel by default\", async () => {\n    state.jobs = [base, running];\n    show();\n    const panel = await screen.findByRole(\"region\", { name: \"Details of Rewrite hook\" });\n    expect(within(panel).getByText(\"Rendering the clip with the new hook\")).toBeInTheDocument();\n    expect(within(panel).getByText(/9:00|09 of video|00:09 \\/ 00:45 of video/)).toBeInTheDocument();\n    const list = screen.getByRole(\"list\", { name: \"Jobs\" });\n    expect(within(list).getByText(/40% · Rendering the clip with the new hook/)).toBeInTheDocument();\n    expect(within(list).getByText(\"3 clips from 9 moments\")).toBeInTheDocument();\n  });\n\n  it(\"switches the panel to the job you pick and names the video it scans\", async () => {\n    state.jobs = [{ ...base, params: { url: \"https://youtu.be/abcdefghijk\", title: \"GTA VI #6\" } }, running];\n    show();\n    await screen.findByRole(\"region\", { name: \"Details of Rewrite hook\" });\n    const pick = within(screen.getByRole(\"list\", { name: \"Jobs\" })).getByRole(\"button\", { name: /Scan video · GTA VI #6/ });\n    fireEvent.click(pick);\n    const panel = await screen.findByRole(\"region\", { name: \"Details of Scan video\" });\n    expect(within(panel).getByText(\"GTA VI #6\")).toBeInTheDocument();\n    expect(pick).toHaveAttribute(\"aria-pressed\", \"true\");\n  });\n\n  it(\"shows the clip jobs first and the searches and checks under All jobs\", async () => {\n    state.jobs = [base, { ...base, id: \"c\", kind: \"find_videos\", result_ref: \"4 new videos\" }];\n    show();\n    const list = await screen.findByRole(\"list\", { name: \"Jobs\" });\n    expect(within(list).queryByText(\"4 new videos\")).not.toBeInTheDocument();\n    fireEvent.mouseDown(screen.getByRole(\"tab\", { name: \"All jobs\" }));\n    expect(await within(screen.getByRole(\"list\", { name: \"Jobs\" })).findByText(\"4 new videos\")).toBeInTheDocument();\n  });\n\n  it(\"opens the job an Open job link names, even a search\", async () => {\n    state.jobs = [running, { ...base, id: \"c\", kind: \"find_videos\", result_ref: \"4 new videos\" }];\n    show(\"/?job=c\");\n    expect(await screen.findByRole(\"region\", { name: \"Details of Find GTA VI videos\" })).toBeInTheDocument();\n  });\n});\n"],"file":"/web/src/pages/jobs/JobsPage.test.tsx"}