Skip to content

Commit

Permalink
feat: 대안으로 beforeEach 도입. settingRouterTester 적용 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
selfishAltruism committed Feb 4, 2024
1 parent 44a91f0 commit 7fc6987
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ dist-ssr
/playwright/.cache/

# test
account.ts
/playwright/.auth
account.ts
6 changes: 0 additions & 6 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,23 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
trace: 'on-first-retry',
storageState: 'playwright/.auth/user.json',
headless: false,
},

projects: [
{ name: 'setup', testMatch: /.*\.setup\.ts/ },

{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
dependencies: ['setup'],
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
dependencies: ['setup'],
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
dependencies: ['setup'],
},

/* Test against mobile viewports. */
Expand Down
4 changes: 0 additions & 4 deletions playwright/.auth/user.json

This file was deleted.

19 changes: 0 additions & 19 deletions tests/auth.setup.ts

This file was deleted.

6 changes: 4 additions & 2 deletions tests/test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { test } from '@playwright/test';

import { settingTester } from './tester/settingTester';
import { settingRouterTester } from './tester/settingTester';
import { signinTester } from './tester/signinTester';

test('setting', settingTester);
test.beforeEach(signinTester);
test('setting', settingRouterTester);
11 changes: 8 additions & 3 deletions tests/tester/settingTester.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { expect } from '@playwright/test';

export const settingTester = async ({ page }) => {
await page.goto('http://localhost:3000/home');
export const settingRouterTester = async ({ page }) => {
await page.click('#root > div > nav > a:nth-child(5)');
await page.waitForURL('http://localhost:3000/setting');

await expect(page.getByText('동문 네트워크')).toBeVisible();
await page.click('#root > div > main > div > section:nth-child(2) > a:nth-child(2)');
await page.waitForURL('http://localhost:3000/setting/profile');

await page.click('#root > div > header > div.css-wzsu05-Left.e1i83gr13 > a > svg > g > path');
await page.waitForURL('http://localhost:3000/setting');
};
5 changes: 3 additions & 2 deletions tests/tester/signinTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export const signinTester = async ({ page }) => {

await page.getByPlaceholder('아이디').fill(ADMIN.ID);
await page.getByPlaceholder('비밀번호').fill(ADMIN.PW);

await page.click('#root > div > div > form > button');

await expect(page.url() === 'http://localhost:3000/home');
await page.waitForURL('http://localhost:3000/home');

await expect(page.getByText('동문 네트워크')).toBeVisible();
};

0 comments on commit 7fc6987

Please sign in to comment.