Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions __mocks__/permissionMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const permissionAvailableMock = {
url: "https://linkedoutapp.com/api/admin-info/my",
apiResponse: {
status: 200,
contentType: "application/json",
body: JSON.stringify({
data: {
id: 0,
email: "test@example.com",
name: "테스트",
profileImage: null,
activated: true,
info: null,
},
}),
},
};
216 changes: 28 additions & 188 deletions __mocks__/reportMock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const reportListMock = {
url: "https://linkedoutapp.com/api/admin-task/reports?sort=most&page=1&limit=10",
url: "https://linkedoutapp.com/api/admin-task/reports?page=1&limit=10",
apiResponse: {
status: 200,
contentType: "application/json",
Expand All @@ -12,211 +12,51 @@ export const reportListMock = {
reports: [
{
id: 1,
title: "Unauthorized Access",
content: "This content violates terms.",
linkedOutGauge: 20,
createdDate: "2024-12-09T16:21:20.569Z",
updatedDate: "2024-12-10T10:05:30.000Z",
thumbnail: "image1.png",
bookmarks: true,
views: 150,
status: "Pending",
deviceOS: "iOS",
deviceType: "Smartphone",
deviceModel: "iPhone 14",
authorId: 101,
reports: [
{
id: 1,
reason: "Hate speech",
processed: false,
processedDate: null,
createdDate: "2024-12-09T16:30:20.000Z",
reporterId: 301,
},
],
essayTitle: "Unauthorized Access",
reportCount: 20,
oldestReportDate: "2024-12-09T16:21:20.569Z",
},
{
id: 2,
title: "Spam Content",
content: "Buy this now!",
linkedOutGauge: 50,
createdDate: "2024-12-08T14:15:00.000Z",
updatedDate: "2024-12-09T08:10:45.000Z",
thumbnail: "image2.png",
bookmarks: false,
views: 80,
status: "Reviewed",
deviceOS: "Android",
deviceType: "Tablet",
deviceModel: "Galaxy Tab S7",
authorId: 102,
reports: [
{
id: 2,
reason: "Spam",
processed: true,
processedDate: "2024-12-09T10:30:00.000Z",
createdDate: "2024-12-08T14:30:00.000Z",
reporterId: 302,
},
],
essayTitle: "Spam Content",
reportCount: 50,
oldestReportDate: "2024-12-08T14:15:00.000Z",
},
{
id: 3,
title: "Offensive Language",
content: "This post contains offensive words.",
linkedOutGauge: 10,
createdDate: "2024-12-07T18:00:00.000Z",
updatedDate: "2024-12-08T09:00:00.000Z",
thumbnail: "image3.png",
bookmarks: true,
views: 95,
status: "Pending",
deviceOS: "Windows",
deviceType: "Desktop",
deviceModel: "HP Pavilion",
authorId: 103,
reports: [
{
id: 3,
reason: "Offensive Language",
processed: false,
processedDate: null,
createdDate: "2024-12-07T18:15:00.000Z",
reporterId: 303,
},
],
essayTitle: "Offensive Language",
reportCount: 10,
oldestReportDate: "2024-12-07T18:00:00.000Z",
},
{
id: 4,
title: "Misinformation",
content: "False information about current events.",
linkedOutGauge: 5,
createdDate: "2024-12-06T12:00:00.000Z",
updatedDate: "2024-12-07T15:00:00.000Z",
thumbnail: "image4.png",
bookmarks: false,
views: 120,
status: "Reviewed",
deviceOS: "MacOS",
deviceType: "Laptop",
deviceModel: "MacBook Pro",
authorId: 104,
reports: [
{
id: 4,
reason: "Misinformation",
processed: true,
processedDate: "2024-12-07T16:00:00.000Z",
createdDate: "2024-12-06T12:15:00.000Z",
reporterId: 304,
},
],
essayTitle: "Misinformation",
reportCount: 5,
oldestReportDate: "2024-12-06T12:00:00.000Z",
},
{
id: 5,
title: "Copyright Infringement",
content: "Unauthorized use of copyrighted material.",
linkedOutGauge: 15,
createdDate: "2024-12-05T10:00:00.000Z",
updatedDate: "2024-12-06T11:00:00.000Z",
thumbnail: "image5.png",
bookmarks: true,
views: 65,
status: "Pending",
deviceOS: "Linux",
deviceType: "Server",
deviceModel: "Dell PowerEdge",
authorId: 105,
reports: [
{
id: 5,
reason: "Copyright Violation",
processed: false,
processedDate: null,
createdDate: "2024-12-05T10:15:00.000Z",
reporterId: 305,
},
],
essayTitle: "Copyright Infringement",
reportCount: 15,
oldestReportDate: "2024-12-05T10:00:00.000Z",
},
{
id: 47,
title: "Harassment",
content: "Targeted harassment of an individual.",
linkedOutGauge: 30,
createdDate: "2024-12-04T16:00:00.000Z",
updatedDate: "2024-12-05T17:00:00.000Z",
thumbnail: "image6.png",
bookmarks: false,
views: 200,
status: "Reviewed",
deviceOS: "Android",
deviceType: "Smartphone",
deviceModel: "Pixel 7",
authorId: 106,
reports: [
{
id: 6,
reason: "Harassment",
processed: true,
processedDate: "2024-12-05T18:00:00.000Z",
createdDate: "2024-12-04T16:15:00.000Z",
reporterId: 306,
},
],
essayTitle: "Harassment",
reportCount: 30,
oldestReportDate: "2024-12-04T16:00:00.000Z",
},
{
id: 7,
title: "Malicious Link",
content: "This post contains harmful links.",
linkedOutGauge: 45,
createdDate: "2024-12-03T08:00:00.000Z",
updatedDate: "2024-12-04T09:00:00.000Z",
thumbnail: "image7.png",
bookmarks: true,
views: 175,
status: "Pending",
deviceOS: "Windows",
deviceType: "Desktop",
deviceModel: "Lenovo ThinkPad",
authorId: 107,
reports: [
{
id: 7,
reason: "Malicious Content",
processed: false,
processedDate: null,
createdDate: "2024-12-03T08:15:00.000Z",
reporterId: 307,
},
],
essayTitle: "Malicious Link",
reportCount: 45,
oldestReportDate: "2024-12-03T08:00:00.000Z",
},
{
id: 8,
title: "Fake Account",
content: "Suspected fake account activity.",
linkedOutGauge: 0,
createdDate: "2024-12-02T20:00:00.000Z",
updatedDate: "2024-12-03T21:00:00.000Z",
thumbnail: "image8.png",
bookmarks: false,
views: 50,
status: "Reviewed",
deviceOS: "iOS",
deviceType: "Smartphone",
deviceModel: "iPhone SE",
authorId: 108,
reports: [
{
id: 8,
reason: "Impersonation",
processed: true,
processedDate: "2024-12-03T22:00:00.000Z",
createdDate: "2024-12-02T20:15:00.000Z",
reporterId: 308,
},
],
essayTitle: "Fake Account",
reportCount: 0,
oldestReportDate: "2024-12-02T20:00:00.000Z",
},
],
},
Expand All @@ -232,10 +72,10 @@ export const reportDetailMock = {
body: JSON.stringify({
data: {
id: 11,
title: "제목 없음",
essayTitle: "제목 없음",
content: "<p>제목없음</p>",
linkedOutGauge: 0,
createdDate: "2024-11-01T16:04:18.145+09:00",
reportCount: 0,
oldestReportDate: "2024-11-01T16:04:18.145+09:00",
updatedDate: "2024-11-01T16:29:24.215+09:00",
thumbnail: null,
views: 0,
Expand Down
25 changes: 8 additions & 17 deletions __tests__/dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,20 @@ import {
} from "../__mocks__/dashboard";
import { expect, test } from "@playwright/test";

import { permissionAvailableMock } from "../__mocks__/permissionMock";

test.describe("대시보드 페이지", () => {
test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ context, page }) => {
await page.addInitScript(() => {
localStorage.setItem("accessToken", "token");
});
await page.goto("http://localhost:5173/dashboard");

await page.route("https://linkedoutapp.com/api/admin-info/my", (route) =>
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
data: {
id: 0,
email: "test@example.com",
name: "테스트",
profileImage: null,
activated: true,
info: null,
},
}),
})
await context.route(permissionAvailableMock.url, (route) =>
route.fulfill(permissionAvailableMock.apiResponse)
);

await page.goto("http://localhost:5173/dashboard");

await page.route(dashboardGraphData.url, (route) =>
route.fulfill(dashboardGraphData.apiResponse)
);
Expand Down
8 changes: 7 additions & 1 deletion __tests__/essay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import { essayDetailMock, essayListMock } from "../__mocks__/essayMock";
import { expect, test } from "@chromatic-com/playwright";

import { authMock } from "../__mocks__/authMock";
import { permissionAvailableMock } from "../__mocks__/permissionMock";
import { reportDetailMock } from "../__mocks__/reportMock";

test.describe("에세이 리스트 페이지", () => {
test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ context, page }) => {
await page.addInitScript(() => {
localStorage.setItem("accessToken", "token");
});

await context.route(permissionAvailableMock.url, (route) =>
route.fulfill(permissionAvailableMock.apiResponse)
);

await page.goto("http://localhost:5173/essays");

await page.route(essayListMock.url, (route) =>
Expand Down
8 changes: 7 additions & 1 deletion __tests__/geulroquis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ import {
geulroquisListMock,
} from "../__mocks__/geulroquis";

import { permissionAvailableMock } from "../__mocks__/permissionMock";

test.describe("글로키 리스트 페이지", () => {
test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ context, page }) => {
await page.addInitScript(() => {
localStorage.setItem("accessToken", "token");
});

await context.route(permissionAvailableMock.url, (route) =>
route.fulfill(permissionAvailableMock.apiResponse)
);

await page.goto("http://localhost:5173/geulroquis");

await page.route(geulroquisListMock.url, (route) =>
Expand Down
6 changes: 4 additions & 2 deletions __tests__/load.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ test.describe("페이지 접근 리다이렉트 테스트", () => {
localStorage.setItem("accessToken", "token");
});

await page.goto("http://localhost:5173/");

await page.route("https://linkedoutapp.com/api/admin-info/my", (route) => {
route.fulfill({
status: 401,
contentType: "application/json",
body: JSON.stringify({ error: "Unauthorized" }),
});
});

await page.goto("http://localhost:5173/");

await expect(page).toHaveURL("http://localhost:5173/auth/login");
});
});
Loading
Loading