109 lines
4.5 KiB
JavaScript
109 lines
4.5 KiB
JavaScript
// @ts-check
|
|
const { test, expect } = require('@playwright/test');
|
|
const { login } = require('./helpers/auth');
|
|
|
|
/** Super Admin 로그인 + 지자체 선택 */
|
|
async function loginAsAdmin(page) {
|
|
await login(page, 'admin');
|
|
const radio = page.locator('input[name="lg_idx"]').first();
|
|
await radio.check();
|
|
await page.click('button[type="submit"]');
|
|
await page.waitForURL(url => !url.pathname.includes('select-local-government'), { timeout: 30000 });
|
|
}
|
|
|
|
test.describe('P2-01: 기본코드 종류 관리', () => {
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAsAdmin(page);
|
|
});
|
|
|
|
test('코드 종류 목록 접근 (/bag/code-kinds)', async ({ page }) => {
|
|
await page.goto('/bag/code-kinds');
|
|
await expect(page).toHaveURL(/\/bag\/code-kinds/);
|
|
await expect(page.locator('td:has-text("도/특별시/광역시 구분")').first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('코드 종류 등록 폼 표시', async ({ page }) => {
|
|
await page.goto('/admin/code-kinds/create');
|
|
await expect(page).toHaveURL(/\/admin\/code-kinds\/create/);
|
|
await expect(page.locator('input[name="ck_code"]')).toBeVisible();
|
|
await expect(page.locator('input[name="ck_name"]')).toBeVisible();
|
|
});
|
|
|
|
test('코드 종류 수정', async ({ page }) => {
|
|
await page.goto('/admin/code-kinds/edit/1');
|
|
await expect(page).toHaveURL(/\/admin\/code-kinds\/edit\/1/);
|
|
await expect(page.locator('input[name="ck_name"]')).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('P2-02: 세부코드 관리', () => {
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAsAdmin(page);
|
|
});
|
|
|
|
test('세부코드 목록 접근 (봉투구분 E, /bag/code-details)', async ({ page }) => {
|
|
await page.goto('/bag/code-details/5');
|
|
await expect(page).toHaveURL(/\/bag\/code-details\/5/);
|
|
await expect(page.locator('td:has-text("일반용")').first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('옛 /admin/code-details 목록 URL은 /bag으로 리다이렉트', async ({ page }) => {
|
|
await page.goto('/admin/code-details/5');
|
|
await expect(page).toHaveURL(/\/bag\/code-details\/5/);
|
|
});
|
|
|
|
test('세부코드 등록 폼 표시', async ({ page }) => {
|
|
await page.goto('/admin/code-details/5/create');
|
|
await expect(page).toHaveURL(/\/admin\/code-details\/5\/create/);
|
|
await expect(page.locator('input[name="cd_code"]')).toBeVisible();
|
|
await expect(page.locator('input[name="cd_name"]')).toBeVisible();
|
|
});
|
|
|
|
test('세부코드 수정 폼', async ({ page }) => {
|
|
await page.goto('/admin/code-details/edit/35');
|
|
await expect(page.locator('input[name="cd_name"]')).toBeVisible();
|
|
});
|
|
|
|
test('기본코드 종류에서 세부코드 링크 이동', async ({ page }) => {
|
|
await page.goto('/bag/code-kinds');
|
|
await page.locator('a[href*="/bag/code-details/"]').first().click();
|
|
await expect(page).toHaveURL(/\/bag\/code-details\/\d+/);
|
|
});
|
|
});
|
|
|
|
test.describe('기본코드: 지자체관리자는 코드 종류 CRUD 불가', () => {
|
|
test('지자체관리자가 /admin/code-kinds/create 접근 시 차단', async ({ page }) => {
|
|
await login(page, 'local');
|
|
await page.goto('/admin/code-kinds/create');
|
|
await expect(page).not.toHaveURL(/\/admin\/code-kinds\/create/);
|
|
});
|
|
});
|
|
|
|
test.describe('기본코드: 시민·판매소 조회 (/bag/code-kinds)', () => {
|
|
test('지정판매소는 bag 목록·테이블만, 등록 버튼 없음', async ({ page }) => {
|
|
await login(page, 'shop');
|
|
await page.goto('/bag/code-kinds');
|
|
await expect(page).toHaveURL(/\/bag\/code-kinds/);
|
|
await expect(page.locator('h3:has-text("기본코드 종류")')).toBeVisible();
|
|
await expect(page.locator('a:has-text("코드 종류 등록")')).toHaveCount(0);
|
|
await expect(page.locator('td:has-text("도/특별시/광역시 구분")').first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('지정판매소는 코드 종류 등록 URL 차단', async ({ page }) => {
|
|
await login(page, 'shop');
|
|
await page.goto('/admin/code-kinds/create');
|
|
await expect(page).not.toHaveURL(/\/admin\/code-kinds\/create/);
|
|
});
|
|
|
|
test('세부코드 목록은 조회만 (등록 버튼 없음)', async ({ page }) => {
|
|
await login(page, 'shop');
|
|
await page.goto('/bag/code-details/5');
|
|
await expect(page).toHaveURL(/\/bag\/code-details\/5/);
|
|
await expect(page.locator('text=세부코드 조회')).toBeVisible();
|
|
await expect(page.locator('a:has-text("세부코드 등록")')).toHaveCount(0);
|
|
await expect(page.locator('td:has-text("일반용")').first()).toBeVisible({ timeout: 10000 });
|
|
});
|
|
});
|