Skip to content

Commit

Permalink
✅ Test setup & legacy migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dohyun-ko committed Jan 8, 2025
1 parent 34d589c commit 7eabf52
Show file tree
Hide file tree
Showing 14 changed files with 743 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ yarn-error.log*
next-env.d.ts
playwright
test-results
playwright-report
playwright-report
node_modules/
/playwright-report/
/blob-report/
/playwright/.cache/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ yarn install
yarn dev
```

## Test

Playwright를 이용하여 E2E 테스트를 진행하고 있습니다.

```bash
yarn playwright test // 모든 테스트 실행
yarn playwright test --ui // 테스트 콘솔 UI 실행
```

## Misc

해당 프로젝트는 `.gitattributes` 파일에서 eol 설정을 `lf`로 하고 있습니다.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"tinymce": "^6.8.3"
},
"devDependencies": {
"@playwright/test": "^1.49.1",
"@storybook/addon-essentials": "^8.1.2",
"@storybook/addon-interactions": "^8.1.2",
"@storybook/addon-links": "^8.1.2",
Expand Down
83 changes: 83 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default 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: 'http://127.0.0.1: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: 'setups',
testMatch: /.*\.setup\.ts$/,
},
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
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,
// },
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface ContentProps {
const Content = ({ content }: ContentProps) => {
return (
<div
id={'notice-content'}
className={[
'font-normal leading-[1.4]',
'[&_p]:my-4 [&_p]:text-lg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const NoticeInfo = async ({
const session = await auth();

return (
<div className="flex flex-col gap-[18px]">
<div className="flex flex-col gap-[18px]" id={'notice-info'}>
{deadline && <Deadline deadline={dayjs(deadline).tz()} t={t} />}

<Metadata
Expand Down Expand Up @@ -59,7 +59,10 @@ const Deadline = ({ deadline, t }: PropsWithT<{ deadline: dayjs.Dayjs }>) => {
};

const Title = ({ title }: { title: string }) => (
<div className="line-clamp-3 text-[25px] font-semibold leading-[30px]">
<div
className="line-clamp-3 text-[25px] font-semibold leading-[30px]"
id={'notice-title'}
>
{title}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/shared/Zabo/Zabo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Zabo = async (props: ZaboProps & PropsWithLng) => {
const hasImage = imageUrls.length > 0;

return (
<Link href={`/${lng}/notice/${id}`}>
<Link href={`/${lng}/notice/${id}`} id={'zabo'}>
<div
className={
'flex flex-col rounded-[10px] py-[10px] text-text transition hover:bg-greyLight dark:hover:bg-dark_greyDark'
Expand Down
Loading

0 comments on commit 7eabf52

Please sign in to comment.