Skip to content

Commit

Permalink
[FE] dev-fe 에서 dev 로 최종 프로젝트를 업로드한다. (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
healim01 authored Oct 23, 2024
2 parents d11098a + 4f8ac6b commit 6d008a7
Show file tree
Hide file tree
Showing 263 changed files with 5,309 additions and 2,847 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Playwright Tests
on:
pull_request:
branches: [main, dev-fe]
paths:
- 'frontend/**'
push:
branches: [main, dev-fe]
paths:
- 'frontend/**'
jobs:
test:
timeout-minutes: 10
runs-on: ubuntu-latest
environment: frontend-msw
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
cd frontend
yarn install --frozen-lockfile
- name: Install Playwright Browsers
run: |
cd frontend
yarn playwright install --with-deps
- name: Create .env File
run: |
cd frontend
echo "CLIENT_ID=${{ secrets.CLIENT_ID }}" >> .env
echo "GA_ID=${{ secrets.GA_ID }}" >> .env
echo "COOKIE=${{ secrets.COOKIE }}" >> .env
echo "KAKAO_MAP_KEY=${{ secrets.KAKAO_MAP_KEY }}" >> .env
echo "SENTRY_DSN_TOKEN=${{ secrets.SENTRY_DSN_TOKEN }}" >> .env
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> .env
echo "SENTRY_ORG=${{ secrets.SENTRY_ORG }}" >> .env
echo "SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }}" >> .env
echo "ANALYZE_BUNDLE=${{ secrets.ANALYZE_BUNDLE }}" >> .env
echo "CI=${{ secrets.CI }}" >> .env
echo "API_ENV=${{ secrets.API_ENV }}" >> .env
echo "API_URL=${{ secrets.API_URL }}" >> .env
echo "REDIRECT_URI=${{ secrets.REDIRECT_URI }}" >> .env
echo "AMPLITUDE_API_KEY=${{ secrets.AMPLITUDE_API_KEY }}" >> .env
- name: Run Playwright tests
run: |
cd frontend
yarn e2e:mock
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30
2 changes: 1 addition & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"eqeqeq": "error",
"dot-notation": "warn",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "_" }],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
Expand Down
10 changes: 9 additions & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
logs
**/*.backup.*
**/*.back.*
user.json

node_modules
dist
Expand All @@ -23,4 +24,11 @@ stories
.env.sentry-build-plugin


private*
private*
test-results/
playwright-report/
blob-report/
playwright/.auth/*
playwright/.cache/
*/.auth

4 changes: 3 additions & 1 deletion frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const decorator = Story => (
<Global
styles={css`
${normalize}
font-size: 10px;
html {
font-size: 62.5%;
}
`}
/>
<ThemeProvider theme={theme}>
Expand Down
2 changes: 1 addition & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ npm run build

or

```
```a
yarn build
```

Expand Down
1 change: 1 addition & 0 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ module.exports = {
'\\.svg': '<rootDir>/src/mocks/svg.ts',
},
testEnvironment: 'jest-environment-jsdom',
testPathIgnorePatterns: ['\\.spec\\.ts$'],
};
8 changes: 8 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test": "concurrently --names ,[TYPE] --prefix {name} \"jest\" \"tsc --noEmit\"",
"e2e:mock": "playwright test --config=playwright.mock.config.ts",
"e2e:mock-ui": "playwright test --config=playwright.mock.config.ts --ui",
"e2e:api": "playwright test --config=playwright.api.config.ts",
"e2e:api-ui": "playwright test --config=playwright.api.config.ts --ui",
"postinstall": "cd .. && husky frontend/.husky",
"format": "prettier --cache --write .",
"lint": "eslint --cache .",
"lint:styled": "stylelint --cache --fix ./*"
},
"dependencies": {
"@amplitude/analytics-browser": "^2.11.8",
"@babel/cli": "^7.25.6",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
Expand All @@ -37,13 +42,15 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-draggable": "^4.4.6",
"react-error-boundary": "^4.0.13",
"react-ga4": "^2.1.0",
"react-router-dom": "^6.24.1",
"zustand": "^4.5.4"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.1",
"@eslint/js": "^8.6.0",
"@playwright/test": "^1.47.2",
"@sentry/webpack-plugin": "^2.22.4",
"@storybook/addon-docs": "^8.3.0",
"@storybook/addon-essentials": "^8.2.4",
Expand All @@ -62,6 +69,7 @@
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.0",
"@types/jest": "^29.5.12",
"@types/node": "^22.7.4",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@webpack-cli/generators": "^3.0.7",
Expand Down
83 changes: 83 additions & 0 deletions frontend/playwright.api.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.development') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright/tests/api',
/* 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://localhost:3000',

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

/* Configure projects for major browsers */
projects: [
{ name: 'setup', testMatch: /.*\.setup\.ts/ },
{
name: 'chromium',
use: { ...devices['Desktop Chrome'], storageState: 'playwright/.auth/user.json' },
dependencies: ['setup'],
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'], storageState: 'playwright/.auth/user.json' },
dependencies: ['setup'],
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'], storageState: 'playwright/.auth/user.json' },
dependencies: ['setup'],
},

/* 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: 'yarn dev -- --no-open',
url: 'http://localhost:3000/',
reuseExistingServer: !process.env.CI,
},
});
78 changes: 78 additions & 0 deletions frontend/playwright.mock.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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.msw') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright/tests/mock',
/* 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: {
baseURL: 'http://localhost:3000',

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

/* Configure projects for major browsers */
projects: [
{
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: 'yarn msw -- --no-open',
url: 'http://localhost:3000/',
reuseExistingServer: !process.env.CI,
},
});
16 changes: 16 additions & 0 deletions frontend/playwright/tests/api/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { test as setup } from '@playwright/test';
import path from 'path';

const authFile = path.join(__dirname, '../../../playwright/.auth/user.json');

setup('authenticate', async ({ page }) => {
const username = process.env.EMAIL || '';
const password = process.env.PASSWORD || '';

await page.goto('/sign-in');
await page.locator('input[name="email"]').fill(username);
await page.locator('input[name="password"]').fill(password);
await page.getByRole('button', { name: '로그인 하기' }).click();
await page.waitForURL('/home');
await page.context().storageState({ path: authFile });
});
Loading

0 comments on commit 6d008a7

Please sign in to comment.