-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
229 additions
and
0 deletions.
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 |
---|---|---|
|
@@ -28,3 +28,4 @@ yarn-error.log* | |
/playwright-report/ | ||
/playwright/.cache/ | ||
/tests/tests-examples/ | ||
/tests/logintest.ts |
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,64 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { getMyinfoNoGroup } from '../mock/getMyInfo'; | ||
import { mockResponse } from '../mock/mockResponse'; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.route('*/**/group', async (route) => { | ||
if (route.request().method() === 'GET') { | ||
await route.fulfill(mockResponse(getMyinfoNoGroup)); | ||
} else { | ||
await route.fulfill(mockResponse(null)); | ||
} | ||
}); | ||
}); | ||
|
||
test.describe('그룹 생성 페이지', () => { | ||
test('그룹 생성', async ({ page, baseURL }) => { | ||
await page.goto(`${baseURL}/addGroup`); | ||
expect(page.getByText('매장 등록하기')).toBeVisible(); | ||
|
||
const marketName = page.getByLabel('상호명'); | ||
const marketNumber = page.getByLabel('사업자 번호'); | ||
const address = page.getByLabel('상세 주소'); | ||
const mainAddress = page.getByLabel('주소', { exact: true }); | ||
|
||
await marketName.focus(); | ||
await marketName.fill('카카오 프렌즈샵'); | ||
|
||
await marketNumber.focus(); | ||
await marketNumber.fill('1111111111'); | ||
|
||
await address.focus(); | ||
await address.fill('11'); | ||
|
||
await mainAddress.click(); | ||
await page | ||
.frameLocator('iframe[title="우편번호서비스 레이어 프레임"]') | ||
.frameLocator('iframe[title="우편번호 검색 프레임"]') | ||
.getByText('예) 판교역로 166, 분당 주공, 백현동 532') | ||
.click(); | ||
await page | ||
.frameLocator('iframe[title="우편번호서비스 레이어 프레임"]') | ||
.frameLocator('iframe[title="우편번호 검색 프레임"]') | ||
.getByLabel('검색할 도로명/지번주소를 입력, 예시) 판교역로 166, 분당 주공, 백현동 532') | ||
.fill('성동구 서울숲길'); | ||
await page | ||
.frameLocator('iframe[title="우편번호서비스 레이어 프레임"]') | ||
.frameLocator('iframe[title="우편번호 검색 프레임"]') | ||
.getByRole('link', { name: '서울특별시 성동구 서울숲길' }) | ||
.click(); | ||
await page | ||
.frameLocator('iframe[title="우편번호서비스 레이어 프레임"]') | ||
.frameLocator('iframe[title="우편번호 검색 프레임"]') | ||
.getByRole('button', { name: '서울 성동구 서울숲길 17 (성수파크빌)' }) | ||
.click(); | ||
|
||
await page.waitForTimeout(2000); | ||
|
||
await page.getByRole('button', { name: '그룹 생성하기' }).click(); | ||
|
||
await page.getByText('매장 등록에 성공했습니다').isVisible({ timeout: 10000 }); | ||
|
||
expect(page.getByText('매장 등록에 성공했습니다')).toBeVisible({ timeout: 10000 }); | ||
}); | ||
}); |
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,21 @@ | ||
import { expect, test as setup } from '@playwright/test'; | ||
import { STORAGE_STATE } from '../../playwright.config'; | ||
import { postLoginNoUser } from '../mock/auth'; | ||
import { mockMapper, mockResponse } from '../mock/mockResponse'; | ||
import { loginTest } from './../logintest'; | ||
|
||
setup('로그인', async ({ page, baseURL }) => { | ||
await page.evaluate((val) => | ||
localStorage.setItem('login', JSON.stringify({ isLogin: true, token: 'Bearer ABC', isAdmin: true })), | ||
); | ||
|
||
await mockMapper({ page, url: 'auth/login', method: 'POST', response: postLoginNoUser }); | ||
await mockMapper({ page, url: 'auth/join', method: 'POST', response: mockResponse(null) }); | ||
|
||
await loginTest({ page: page, baseURL: baseURL, isAdmin: true }); | ||
expect(page.getByText('내 스케줄')).toBeVisible({ timeout: 10000 }); | ||
|
||
await page.waitForTimeout(3000); | ||
|
||
await page.context().storageState({ path: STORAGE_STATE }); | ||
}); |
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,33 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { getMyinfo, getMyinfoNoGroup } from '../mock/getMyInfo'; | ||
import { mockResponse } from '../mock/mockResponse'; | ||
|
||
test.describe('사이드바', () => { | ||
test('사이드바 : 그룹 있음', async ({ page, baseURL }) => { | ||
await page.route('*/**/group', async (route) => { | ||
if (route.request().method() === 'GET') { | ||
await route.fulfill(mockResponse(getMyinfo)); | ||
} | ||
}); | ||
|
||
await page.goto(`${baseURL}`); | ||
await page.getByLabel('메뉴').click(); | ||
await page.getByText('우리 매장 직원 목록').isVisible(); | ||
|
||
expect(page.getByText('우리 매장 직원 목록')).toBeVisible({ timeout: 10000 }); | ||
}); | ||
|
||
test('사이드바 : 그룹 없음', async ({ page, baseURL }) => { | ||
await page.route('*/**/group', async (route) => { | ||
if (route.request().method() === 'GET') { | ||
await route.fulfill(mockResponse(getMyinfoNoGroup)); | ||
} | ||
}); | ||
|
||
await page.goto(`${baseURL}`); | ||
await page.getByLabel('메뉴').click(); | ||
await page.waitForTimeout(3000); | ||
|
||
expect(page.getByText('우리 매장 직원 목록')).not.toBeVisible(); | ||
}); | ||
}); |
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 { expect, test as setup } from '@playwright/test'; | ||
import { STORAGE_STATE } from '../../playwright.config'; | ||
import { loginTest } from '../logintest'; | ||
|
||
setup('로그인', async ({ page, baseURL }) => { | ||
await loginTest({ page: page, baseURL: baseURL, isAdmin: false }); | ||
expect(page.getByText('내 스케줄')).toBeVisible({ timeout: 10000 }); | ||
await page.waitForTimeout(3000); | ||
await page.context().storageState({ path: STORAGE_STATE }); | ||
}); |
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,21 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test.describe('초대장', () => { | ||
test('접속', async ({ page, baseURL }) => { | ||
// 접속 | ||
await page.goto(`${baseURL}/invited/123`); | ||
|
||
const marketName = page.getByText('라이언 월드'); | ||
await marketName.isVisible(); | ||
expect(marketName).toBeVisible({ timeout: 10000 }); | ||
|
||
// 승인 | ||
|
||
await page.getByRole('button', { name: '승인하기' }).click(); | ||
|
||
const successMessage = page.getByText('그룹 가입에 성공했어요'); | ||
await successMessage.isVisible(); | ||
await page.waitForTimeout(1000); | ||
expect(successMessage).toBeVisible({ timeout: 10000 }); | ||
}); | ||
}); |
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,9 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { loginTest } from './logintest'; | ||
|
||
test.describe('온보딩 페이지', () => { | ||
test('로그인', async ({ page, baseURL }) => { | ||
await loginTest({ page: page, baseURL: baseURL, isAdmin: true }); | ||
expect(page.getByText('내 스케줄')).toBeVisible({ timeout: 30000 }); | ||
}); | ||
}); |
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,6 @@ | ||
export const postLoginNoUser = { | ||
status: 404, | ||
body: JSON.stringify({ | ||
code: -10006, | ||
}), | ||
}; |
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,31 @@ | ||
export const getMyinfoNoGroup = { | ||
userName: '라이언', | ||
groupName: null, | ||
members: [], | ||
}; | ||
|
||
export const getMyinfo = { | ||
userName: '라이언', | ||
groupName: '라이언 월드', | ||
members: [ | ||
{ name: '라이언', userId: 1 }, | ||
{ name: '라이언', userId: 2 }, | ||
{ name: '라이언', userId: 3 }, | ||
{ name: '라이언', userId: 4 }, | ||
{ name: '라이언', userId: 5 }, | ||
{ name: '라이언', userId: 6 }, | ||
{ name: '라이언', userId: 7 }, | ||
{ name: '라이언', userId: 8 }, | ||
{ name: '라이언', userId: 9 }, | ||
{ name: '라이언', userId: 10 }, | ||
{ name: '라이언', userId: 11 }, | ||
{ name: '라이언', userId: 12 }, | ||
{ name: '라이언', userId: 13 }, | ||
{ name: '라이언', userId: 14 }, | ||
{ name: '라이언', userId: 15 }, | ||
{ name: '라이언', userId: 16 }, | ||
{ name: '라이언', userId: 17 }, | ||
{ name: '라이언', userId: 18 }, | ||
{ name: '라이언', userId: 19 }, | ||
], | ||
}; |
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,33 @@ | ||
import { Page } from 'playwright-core'; | ||
|
||
export const mockResponse = (responseBody) => { | ||
if (responseBody === null) { | ||
return { status: 200 }; | ||
} | ||
return { status: 200, body: JSON.stringify(responseBody) }; | ||
}; | ||
|
||
export const mockMapper = async ({ | ||
page, | ||
response, | ||
url, | ||
method, | ||
}: { | ||
page: Page; | ||
response: Response; | ||
url: string; | ||
method: 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
}) => { | ||
await page.route(`*/**/${url}`, async (route) => { | ||
if (route.request().method() === method) { | ||
await route.fulfill(response); | ||
} else { | ||
await route.continue(); | ||
} | ||
}); | ||
}; | ||
|
||
interface Response { | ||
body?: string | Buffer | undefined; | ||
status?: number | undefined; | ||
} |