-
Notifications
You must be signed in to change notification settings - Fork 5
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: 예시 통합 테스트 추가 #449
Open
scarf005
wants to merge
7
commits into
develop
Choose a base branch
from
437-통합-테스트-추가
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "437-\uD1B5\uD569-\uD14C\uC2A4\uD2B8-\uCD94\uAC00"
Open
test: 예시 통합 테스트 추가 #449
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
21c9d75
build: 도커파일 추가
scarf005 9045f47
test: playwright 설정
scarf005 eb9cbc6
test: 설정 파일 정리
scarf005 a63f473
test: 예시 테스트 추가
scarf005 fd057e7
test: 인증 및 서버에 부하를 주는 행동 생략
scarf005 a55c838
ci: 개발 서버를 사용해 테스트
scarf005 b9bb1f9
refactor: 통합 테스트 관련 파일을 폴더로 정리
scarf005 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Ignore node_modules | ||
node_modules | ||
|
||
# Ignore build output | ||
build | ||
dist | ||
|
||
# Ignore development files | ||
# src/**/*.test.js | ||
# src/**/*.spec.js | ||
# src/**/*.stories.js | ||
|
||
# Ignore miscellaneous files | ||
.DS_Store | ||
npm-debug.log | ||
yarn-debug.log | ||
yarn-error.log |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: 테스트 | ||
on: | ||
push: | ||
branches: [develop] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
e2e: | ||
environment: test | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
- uses: pnpm/action-setup@v2 | ||
name: Install pnpm | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
shell: bash | ||
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: ${{ runner.os }}-pnpm-store- | ||
|
||
- name: install dependencies | ||
run: | | ||
pnpm install --frozen-lockfile | ||
|
||
- name: Build app | ||
run: pnpm run build | ||
|
||
- name: Install Playwright Browsers | ||
run: pnpm exec playwright install --with-deps | ||
|
||
- name: Run Playwright tests | ||
run: pnpm exec playwright test | ||
env: | ||
REACT_APP_API: ${{ secrets.REACT_APP_API }} | ||
PORT: ${{ vars.PORT }} | ||
REACT_APP_WISH: ${{ vars.REACT_APP_WISH }} | ||
REACT_APP_SUGGESTION: ${{ vars.REACT_APP_SUGGESTION }} | ||
REACT_APP_E_BOOK_LIBRARY: ${{ vars.REACT_APP_E_BOOK_LIBRARY }} | ||
|
||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,6 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM node:20-alpine | ||
|
||
RUN npm install -g [email protected] | ||
|
||
WORKDIR /app | ||
|
||
# Copy the necessary file into image | ||
COPY package.json pnpm-lock.yaml ./ | ||
|
||
# Install | ||
RUN pnpm install --frozen-lockfile | ||
|
||
RUN echo "pnpm version: $(pnpm --version)" | ||
|
||
CMD ["pnpm", "dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
services: | ||
playwright: | ||
build: | ||
context: .. | ||
dockerfile: e2e/dockerfile | ||
command: pnpm e2e # ls -al e2e # pnpm e2e | ||
environment: | ||
DISPLAY: ${DISPLAY} | ||
env_file: ../.env | ||
volumes: | ||
- /tmp/.X11-unix:/tmp/.X11-unix | ||
- ../src:/app/src:ro | ||
- ../vite.config.ts:/app/vite.config.ts:ro | ||
- ../package.json:/app/package.json:ro | ||
- ../e2e:/app/e2e:ro | ||
- ../test-results.docker:/app/test-results | ||
- ../playwright-report.docker:/app/playwright-report.docker | ||
ports: | ||
- 9323:9323 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM mcr.microsoft.com/playwright:v1.37.1-jammy | ||
|
||
WORKDIR /app | ||
|
||
# Corepack으로 pnpm 설치 | ||
RUN corepack enable && corepack prepare pnpm@latest --activate | ||
|
||
# 브라우저 의존성 설치 | ||
RUN pnpm dlx playwright install-deps | ||
|
||
COPY package.json pnpm-lock.yaml /app/ | ||
RUN pnpm install --frozen-lockfile | ||
|
||
ENV IS_DOCKER=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { devices } from "@playwright/test"; | ||
import os from "node:os"; | ||
|
||
// https://github.com/microsoft/playwright/issues/23296 | ||
const disableWebkit = | ||
os.platform() === "linux" && !process.env.CI && !process.env.IS_DOCKER; | ||
|
||
export const nonLTSLinuxBrowsers = [ | ||
{ name: "chromium", use: { ...devices["Desktop Chrome"] } }, | ||
{ name: "firefox", use: { ...devices["Desktop Firefox"] } }, | ||
]; | ||
|
||
const macBrowser = { name: "webkit", use: { ...devices["Desktop Safari"] } }; | ||
|
||
export const majorBrowsers = disableWebkit | ||
? nonLTSLinuxBrowsers | ||
: [...nonLTSLinuxBrowsers, macBrowser]; | ||
|
||
/* Test against mobile viewports. */ | ||
const mobileViewports = [ | ||
{ name: "Mobile Chrome", use: { ...devices["Pixel 5"] } }, | ||
{ name: "Mobile Safari", use: { ...devices["iPhone 12"] } }, | ||
]; | ||
|
||
/* Test against branded browsers. */ | ||
const brandedBrowsers = [ | ||
{ | ||
name: "Microsoft Edge", | ||
use: { ...devices["Desktop Edge"], channel: "msedge" }, | ||
}, | ||
{ | ||
name: "Google Chrome", | ||
use: { ...devices["Desktop Chrome"], channel: "chrome" }, | ||
}, | ||
]; | ||
|
||
/** List of all browsers to test against. */ | ||
export const projects = majorBrowsers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { defineConfig } from "@playwright/test"; | ||
import { projects } from "./playwright.browsers"; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
const baseURL = `http://127.0.0.1:${process.env.PORT || 4242}`; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
/* 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: [ | ||
["list"], | ||
[ | ||
"html", | ||
process.env.IS_DOCKER | ||
? { open: "never", host: "0.0.0.0" } | ||
: { open: "on-failure" }, | ||
], | ||
], | ||
/* 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, | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: "on-first-retry", | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects, | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: "pnpm dev", | ||
url: baseURL, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.skip('42 로그인 페이지 이동', async ({ page }) => { | ||
await page.goto('http://localhost:4242/'); | ||
await page.getByRole('link', { name: 'login 로그인' }).click(); | ||
await page.getByRole('link', { name: '42 intra 로그인' }).click(); | ||
await page.getByRole('link', { name: 'Sign in as student' }).click(); | ||
await page.getByPlaceholder('Login or email').click(); | ||
await page.locator('body').click(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('has title', async ({ page }) => { | ||
await page.goto('https://playwright.dev/'); | ||
|
||
// Expect a title "to contain" a substring. | ||
await expect(page).toHaveTitle(/Playwright/); | ||
}); | ||
|
||
test('get started link', async ({ page }) => { | ||
await page.goto('https://playwright.dev/'); | ||
|
||
// Click the get started link. | ||
await page.getByRole('link', { name: 'Get started' }).click(); | ||
|
||
// Expects the URL to contain intro. | ||
await expect(page).toHaveURL(/.*intro/); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test("집현전 로고가 보임", async ({ page }) => { | ||
await page.goto("http://localhost:4242/"); | ||
|
||
// Expect a title "to contain" a substring. | ||
await expect(page).toHaveTitle(/집현전/); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { test } from "@playwright/test"; | ||
|
||
test("전체 도서 목록 열람", async ({ page }) => { | ||
await page.goto("http://localhost:4242/"); | ||
await page.getByRole("link", { name: "도서목록" }).click(); | ||
await page.getByRole("button", { name: "IT 일반" }).click(); | ||
await page.getByRole("button", { name: "nextCategory" }).click(); | ||
await page.getByRole("button", { name: "preCategory" }).click(); | ||
await page.getByRole("button", { name: "순수과학" }).click(); | ||
}); | ||
|
||
test("러닝 리액트 도서 검색", async ({ page }) => { | ||
await page.goto("http://localhost:4242/"); | ||
await page.getByRole("textbox").click(); | ||
await page.getByRole("textbox").fill("리액트"); | ||
await page.getByRole("textbox").press("Enter"); | ||
await page | ||
.getByRole("link") | ||
.filter({ | ||
hasText: "러닝 리액트 러닝 리액트 알렉스 뱅크스 | 한빛미디어", | ||
}) | ||
.click(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firefox와 chromium과 달리 webkit에서는
<a href>
태그의 aria-role이 적용이 되지 않아 테스트가 실패하는 것으로 보입니다.