Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: 메인 헤더 테스트 #475

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@ volumes/
/backend/static/

## frontend SPA ignore
/frontend/index.html
/frontend/index.html
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
105 changes: 105 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "ft_transcendence",
"version": "1.0.0",
"description": "![리드밍](https://img.buzzfeed.com/store-an-image-prod-us-east-1/EdGE5ilDZ.gif)",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.42.1",
"@types/node": "^20.11.26"
},
"dependencies": {
"dotenv": "^16.4.5"
}
}
78 changes: 78 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// @ts-check
const { defineConfig, devices } = require("@playwright/test");

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
require("dotenv").config();

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.BASE_URL || "http://localhost:3000",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},

/* Configure projects for major browsers */
projects: [
{
name: "Google Chrome",
use: { ...devices["Desktop Chrome"], channel: "chrome" }, // or 'chrome-beta'
},

{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},

{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
35 changes: 35 additions & 0 deletions tests/header/mainHeader/mainHeader.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test, expect } from "@playwright/test";

test.use({
ignoreHTTPSErrors: true,
viewport: { width: 1920, height: 1080 },
javaScriptEnabled: true,
});

test.beforeEach(async ({ page, context, browser }) => {
await context.addCookies([
{
name: "jwt",
value: process.env.JWT_TOKEN,
domain: "localhost",
path: "/",
httpOnly: true,
},
]);
await page.goto("/game-mode");
});

test.describe("Main Header", () => {
test("should render main header", async ({ page }) => {
const userInfoButton = page.getByRole("button", {
name: "예나 아바타",
});
await userInfoButton.waitFor({ state: "visible" });
await expect(userInfoButton).toHaveText("예나");
// await page.getByText("사십 이 초-월").click();
// await page.getByRole("img", { name: "뒤로가기" }).click();
// await page.getByRole("img", { name: "친구 목록" }).click();
// await page.getByRole("img", { name: "친구 목록" }).click();
// await page.getByText("떠나기").click();
});
});
Loading