From 9bcedf6650dd27a57ff818eaf10f4be652cd6ac4 Mon Sep 17 00:00:00 2001 From: Anderson Shindy Oki Date: Fri, 24 Jan 2025 14:19:59 +0900 Subject: [PATCH] chore: move test files --- .../src/pages/History/Movies/index.test.tsx | 33 +++++ .../src/pages/History/Series/index.test.tsx | 21 ++++ .../History/Statistics/HistoryStats.test.tsx | 39 ++++++ frontend/src/pages/History/history.test.tsx | 63 ---------- .../pages/System/Announcements/index.test.tsx | 21 ++++ .../src/pages/System/Backups/index.test.tsx | 21 ++++ frontend/src/pages/System/Logs/index.test.tsx | 21 ++++ .../src/pages/System/Providers/index.test.tsx | 21 ++++ .../src/pages/System/Releases/index.test.tsx | 21 ++++ .../src/pages/System/Status/index.test.tsx | 29 +++++ .../src/pages/System/Tasks/index.test.tsx | 21 ++++ frontend/src/pages/System/system.test.tsx | 114 ------------------ .../src/pages/Wanted/Movies/index.test.tsx | 21 ++++ .../src/pages/Wanted/Series/index.test.tsx | 21 ++++ frontend/src/pages/Wanted/wanted.test.tsx | 37 ------ 15 files changed, 290 insertions(+), 214 deletions(-) create mode 100644 frontend/src/pages/History/Movies/index.test.tsx create mode 100644 frontend/src/pages/History/Series/index.test.tsx create mode 100644 frontend/src/pages/History/Statistics/HistoryStats.test.tsx delete mode 100644 frontend/src/pages/History/history.test.tsx create mode 100644 frontend/src/pages/System/Announcements/index.test.tsx create mode 100644 frontend/src/pages/System/Backups/index.test.tsx create mode 100644 frontend/src/pages/System/Logs/index.test.tsx create mode 100644 frontend/src/pages/System/Providers/index.test.tsx create mode 100644 frontend/src/pages/System/Releases/index.test.tsx create mode 100644 frontend/src/pages/System/Status/index.test.tsx create mode 100644 frontend/src/pages/System/Tasks/index.test.tsx delete mode 100644 frontend/src/pages/System/system.test.tsx create mode 100644 frontend/src/pages/Wanted/Movies/index.test.tsx create mode 100644 frontend/src/pages/Wanted/Series/index.test.tsx delete mode 100644 frontend/src/pages/Wanted/wanted.test.tsx diff --git a/frontend/src/pages/History/Movies/index.test.tsx b/frontend/src/pages/History/Movies/index.test.tsx new file mode 100644 index 000000000..f31c093bc --- /dev/null +++ b/frontend/src/pages/History/Movies/index.test.tsx @@ -0,0 +1,33 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import MoviesHistoryView from "."; + +describe("History Movies", () => { + it("should render with movies", async () => { + server.use( + http.get("/api/movies/history", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + server.use( + http.get("/api/providers", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + server.use( + http.get("/api/system/languages", () => { + return HttpResponse.json({}); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/History/Series/index.test.tsx b/frontend/src/pages/History/Series/index.test.tsx new file mode 100644 index 000000000..b60cb5e9e --- /dev/null +++ b/frontend/src/pages/History/Series/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import SeriesHistoryView from "."; + +describe("History Series", () => { + it("should render with series", async () => { + server.use( + http.get("/api/episodes/history", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/History/Statistics/HistoryStats.test.tsx b/frontend/src/pages/History/Statistics/HistoryStats.test.tsx new file mode 100644 index 000000000..10bcfe732 --- /dev/null +++ b/frontend/src/pages/History/Statistics/HistoryStats.test.tsx @@ -0,0 +1,39 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import HistoryStats from "./HistoryStats"; + +describe("History Stats", () => { + it("should render with stats", async () => { + server.use( + http.get("/api/providers", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + server.use( + http.get("/api/system/languages", () => { + return HttpResponse.json({}); + }), + ); + server.use( + http.get("/api/history/stats", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + server.use( + http.get("/api/system/providers", () => { + return HttpResponse.json({}); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/History/history.test.tsx b/frontend/src/pages/History/history.test.tsx deleted file mode 100644 index 054f72e81..000000000 --- a/frontend/src/pages/History/history.test.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { http } from "msw"; -import { HttpResponse } from "msw"; -import server from "@/tests/mocks/node"; -import { renderTest, RenderTestCase } from "@/tests/render"; -import HistoryStats from "./Statistics/HistoryStats"; -import MoviesHistoryView from "./Movies"; -import SeriesHistoryView from "./Series"; - -const cases: RenderTestCase[] = [ - { - name: "movie page", - ui: MoviesHistoryView, - setupEach: () => { - server.use( - http.get("/api/movies/history", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - server.use( - http.get("/api/providers", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - server.use( - http.get("/api/system/languages", () => { - return HttpResponse.json({}); - }), - ); - }, - }, - { - name: "series page", - ui: SeriesHistoryView, - setupEach: () => { - server.use( - http.get("/api/episodes/history", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, - { - name: "statistics page", - ui: HistoryStats, - setupEach: () => { - server.use( - http.get("/api/history/stats", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, -]; - -renderTest("History", cases); diff --git a/frontend/src/pages/System/Announcements/index.test.tsx b/frontend/src/pages/System/Announcements/index.test.tsx new file mode 100644 index 000000000..cc7d18e75 --- /dev/null +++ b/frontend/src/pages/System/Announcements/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import SystemAnnouncementsView from "."; + +describe("System Announcements", () => { + it("should render with announcements", async () => { + server.use( + http.get("/api/system/announcements", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/System/Backups/index.test.tsx b/frontend/src/pages/System/Backups/index.test.tsx new file mode 100644 index 000000000..2b82177c6 --- /dev/null +++ b/frontend/src/pages/System/Backups/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import SystemBackupsView from "."; + +describe("System Backups", () => { + it("should render with backups", async () => { + server.use( + http.get("/api/system/backups", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/System/Logs/index.test.tsx b/frontend/src/pages/System/Logs/index.test.tsx new file mode 100644 index 000000000..b70336b79 --- /dev/null +++ b/frontend/src/pages/System/Logs/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import SystemLogsView from "."; + +describe("System Logs", () => { + it("should render with logs", async () => { + server.use( + http.get("/api/system/logs", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/System/Providers/index.test.tsx b/frontend/src/pages/System/Providers/index.test.tsx new file mode 100644 index 000000000..2e2f4ffdc --- /dev/null +++ b/frontend/src/pages/System/Providers/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import SystemProvidersView from "."; + +describe("System Providers", () => { + it("should render with providers", async () => { + server.use( + http.get("/api/providers", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/System/Releases/index.test.tsx b/frontend/src/pages/System/Releases/index.test.tsx new file mode 100644 index 000000000..6e8dfed27 --- /dev/null +++ b/frontend/src/pages/System/Releases/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import SystemReleasesView from "."; + +describe("System Releases", () => { + it("should render with releases", async () => { + server.use( + http.get("/api/system/releases", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/System/Status/index.test.tsx b/frontend/src/pages/System/Status/index.test.tsx new file mode 100644 index 000000000..988114d2e --- /dev/null +++ b/frontend/src/pages/System/Status/index.test.tsx @@ -0,0 +1,29 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import SystemStatusView from "."; + +describe("System Status", () => { + it("should render with status", async () => { + server.use( + http.get("/api/system/status", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + server.use( + http.get("/api/system/health", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/System/Tasks/index.test.tsx b/frontend/src/pages/System/Tasks/index.test.tsx new file mode 100644 index 000000000..b6c3710af --- /dev/null +++ b/frontend/src/pages/System/Tasks/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import SystemTasksView from "."; + +describe("System Tasks", () => { + it("should render with tasks", async () => { + server.use( + http.get("/api/system/tasks", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/System/system.test.tsx b/frontend/src/pages/System/system.test.tsx deleted file mode 100644 index 9fd684a34..000000000 --- a/frontend/src/pages/System/system.test.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import { http } from "msw"; -import { HttpResponse } from "msw"; -import SystemAnnouncementsView from "@/pages/System/Announcements"; -import server from "@/tests/mocks/node"; -import { renderTest, RenderTestCase } from "@/tests/render"; -import SystemBackupsView from "./Backups"; -import SystemLogsView from "./Logs"; -import SystemProvidersView from "./Providers"; -import SystemReleasesView from "./Releases"; -import SystemStatusView from "./Status"; -import SystemTasksView from "./Tasks"; - -const cases: RenderTestCase[] = [ - { - name: "backups page", - ui: SystemBackupsView, - setupEach: () => { - server.use( - http.get("/api/system/backups", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, - { - name: "logs page", - ui: SystemLogsView, - setupEach: () => { - server.use( - http.get("/api/system/logs", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, - { - name: "providers page", - ui: SystemProvidersView, - setupEach: () => { - server.use( - http.get("/api/providers", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, - { - name: "releases page", - ui: SystemReleasesView, - setupEach: () => { - server.use( - http.get("/api/system/releases", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, - { - name: "status page", - ui: SystemStatusView, - setupEach: () => { - server.use( - http.get("/api/system/status", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - server.use( - http.get("/api/system/health", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, - { - name: "tasks page", - ui: SystemTasksView, - setupEach: () => { - server.use( - http.get("/api/system/tasks", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, - { - name: "announcements page", - ui: SystemAnnouncementsView, - setupEach: () => { - server.use( - http.get("/api/system/announcements", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, -]; - -renderTest("System", cases); diff --git a/frontend/src/pages/Wanted/Movies/index.test.tsx b/frontend/src/pages/Wanted/Movies/index.test.tsx new file mode 100644 index 000000000..8974573a5 --- /dev/null +++ b/frontend/src/pages/Wanted/Movies/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import WantedMoviesView from "."; + +describe("Wanted Movies", () => { + it("should render with wanted movies", async () => { + server.use( + http.get("/api/movies/wanted", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/Wanted/Series/index.test.tsx b/frontend/src/pages/Wanted/Series/index.test.tsx new file mode 100644 index 000000000..8387dabb9 --- /dev/null +++ b/frontend/src/pages/Wanted/Series/index.test.tsx @@ -0,0 +1,21 @@ +import { http } from "msw"; +import { HttpResponse } from "msw"; +import { render } from "@/tests"; +import server from "@/tests/mocks/node"; +import WantedSeriesView from "."; + +describe("Wanted Series", () => { + it("should render with wanted series", async () => { + server.use( + http.get("/api/episodes/wanted", () => { + return HttpResponse.json({ + data: [], + }); + }), + ); + + render(); + + // TODO: Assert + }); +}); diff --git a/frontend/src/pages/Wanted/wanted.test.tsx b/frontend/src/pages/Wanted/wanted.test.tsx deleted file mode 100644 index 5eddad0e2..000000000 --- a/frontend/src/pages/Wanted/wanted.test.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { http } from "msw"; -import { HttpResponse } from "msw"; -import server from "@/tests/mocks/node"; -import { renderTest, RenderTestCase } from "@/tests/render"; -import WantedMoviesView from "./Movies"; -import WantedSeriesView from "./Series"; - -const cases: RenderTestCase[] = [ - { - name: "movie page", - ui: WantedMoviesView, - setupEach: () => { - server.use( - http.get("/api/movies/wanted", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, - { - name: "series page", - ui: WantedSeriesView, - setupEach: () => { - server.use( - http.get("/api/episodes/wanted", () => { - return HttpResponse.json({ - data: [], - }); - }), - ); - }, - }, -]; - -renderTest("Wanted", cases);