fix(core,admin_basic,board,ecommerce,page,gdpr,verification): 설정 미러·자동 정리·탈퇴 원자성·일괄 선택 범위 정비
공개이슈 ··· 및 그 전수 해소분. - 설정 저장·복원·초기화가 상주 프로세스 미러를 갱신하도록 단일 소유자화 - 만료 데이터 자동 정리 예약 12종 신설, 파기는 기본키 배치로 분할 - 회원 탈퇴를 전 경로 원자화하고 관리자 상태변경 경로를 정식 탈퇴로 통일 - 일괄 처리 목록의 선택을 화면에 보이는 행으로 한정(selectionScope) - 비밀번호 정책 문구를 도메인 중립 라벨로 정정 - 정적 검사 2종·검증 스킬 설계 정합성 축 신설
This commit is contained in:
1 parent
49c155509e
commit
4e1ec6e001
136 files changed
+7016
-504
No files matched your search
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* E2E: 일괄 처리 목록의 선택 범위 (selectionScope)
|
||||
*
|
||||
* 체크박스 선택은 화면 밖(전역 상태)에 저장되므로, 검색으로 그 행이 목록에서 빠져도
|
||||
* 선택은 남는다. 그 상태에서 일괄 처리를 누르면 **운영자가 보고 있지도, 체크하지도 않은
|
||||
* 행이 대상**이 된다. 확인 창은 건수만 말하고("N명의 사용자를 탈퇴 처리합니다") 대상을
|
||||
* 부르지 않으므로 실행 전에 알아챌 방법이 없고, 서버는 정상 처리하므로 오류도 남지 않는다.
|
||||
*
|
||||
* 관측 가능한 결과는 **나가는 요청의 ids** 다 — 화면만 봐서는 구분되지 않으므로 여기서
|
||||
* 잠근다. 단위 테스트(DataGrid.test.tsx)는 컴포넌트가 정리를 수행하는지를 보고, 이 spec 은
|
||||
* 그 정리가 실제 화면·실제 전역 상태·실제 요청까지 도달하는지를 본다.
|
||||
*
|
||||
* // @scenario surface=admin_user_list, transition=search_filter_change, scope=page
|
||||
* // @effects hidden_row_selection_dropped, bulk_button_disabled_when_selection_empties, bulk_request_carries_only_visible_checked_rows
|
||||
*/
|
||||
import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth';
|
||||
|
||||
const ADMIN_PERMISSIONS = ['core.users.read', 'core.users.update', 'core.users.create'];
|
||||
|
||||
/** 이 실행에서만 쓰는 접두사 — 검색으로 한 명씩 고립시키기 위해 필요하다. */
|
||||
const RUN_TAG = `e2esel${Date.now().toString(36)}`;
|
||||
|
||||
/**
|
||||
* 테스트용 회원을 만들고 uuid 를 돌려줍니다.
|
||||
*
|
||||
* @param page Playwright 페이지
|
||||
* @param token 관리자 토큰
|
||||
* @param slug 이메일 로컬파트 구분자
|
||||
* @return 생성된 회원 uuid
|
||||
*/
|
||||
async function createTestUser(page: any, token: string, slug: string): Promise<string> {
|
||||
const headers = { Authorization: `Bearer ${token}`, Accept: 'application/json' };
|
||||
|
||||
const rolesResponse = await page.request.get('/api/admin/roles/active', { headers });
|
||||
const roles = (await rolesResponse.json())?.data?.data ?? [];
|
||||
const roleId = (roles.find((role: any) => role.identifier === 'user') ?? roles[roles.length - 1])?.id;
|
||||
|
||||
expect(roleId, '일반 사용자 역할을 찾지 못했습니다').toBeTruthy();
|
||||
|
||||
const response = await page.request.post('/api/admin/users', {
|
||||
headers,
|
||||
data: {
|
||||
name: `E2E선택범위 ${slug}`,
|
||||
email: `${RUN_TAG}${slug}@example.com`,
|
||||
password: 'Password!234',
|
||||
password_confirmation: 'Password!234',
|
||||
status: 'active',
|
||||
role_ids: [roleId],
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status(), `테스트 회원 생성 실패: ${await response.text()}`).toBeLessThan(300);
|
||||
|
||||
return (await response.json())?.data?.uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 화면의 검색창으로 목록을 걸러냅니다.
|
||||
*
|
||||
* `page.goto` 로 URL 을 갈아끼우면 전체 페이지가 다시 로드되면서 전역 상태가 통째로
|
||||
* 비워진다 — 그러면 선택이 사라진 이유가 "컴포넌트가 정리해서" 인지 "페이지가 새로
|
||||
* 뜨면서" 인지 구분되지 않고, 수정이 없어도 통과하는 테스트가 된다. 결함이 실제로
|
||||
* 관측된 경로는 앱이 떠 있는 채로 목록만 다시 부르는 화면 내 검색이므로 그 경로를 쓴다.
|
||||
*
|
||||
* @param page Playwright 페이지
|
||||
* @param keyword 검색어
|
||||
* @return void
|
||||
*/
|
||||
async function searchUserList(page: any, keyword: string): Promise<void> {
|
||||
const searchInput = page.locator('#search_input');
|
||||
await searchInput.waitFor({ state: 'visible', timeout: 20_000 });
|
||||
await searchInput.fill(keyword);
|
||||
await searchInput.press('Enter');
|
||||
|
||||
await expect(page.locator('#users_data_grid__body tbody tr')).toHaveCount(1, { timeout: 20_000 });
|
||||
await expect(page.locator('#users_data_grid__body tbody tr').first()).toContainText(keyword, {
|
||||
timeout: 20_000,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 행 체크박스를 켜고 실제로 켜졌는지 확인합니다.
|
||||
*
|
||||
* `check()` 는 클릭 직후 상태를 확인하는데, 이 체크박스는 전역 상태를 거쳐 다시 내려오는
|
||||
* 제어 컴포넌트라 그 시점에 아직 false 다 (실측). 클릭과 확인을 분리한다.
|
||||
*
|
||||
* @param page Playwright 페이지
|
||||
* @return void
|
||||
*/
|
||||
async function checkFirstRow(page: any): Promise<void> {
|
||||
const checkbox = page.locator('#users_data_grid__body tbody tr input[type="checkbox"]').first();
|
||||
await checkbox.click();
|
||||
await expect(checkbox).toBeChecked({ timeout: 10_000 });
|
||||
}
|
||||
|
||||
test('@smoke 회원 목록: 검색으로 사라진 행은 선택이 풀리고 일괄 처리 대상에서도 빠진다', async ({ page }) => {
|
||||
const token = issueToken(...ADMIN_PERMISSIONS);
|
||||
await authenticatePage(page, token);
|
||||
|
||||
const hiddenUserUuid = await createTestUser(page, token, 'hidden');
|
||||
const visibleUserUuid = await createTestUser(page, token, 'visible');
|
||||
|
||||
// 1) hidden 만 보이는 목록에서 그 행을 체크한다.
|
||||
await page.goto('/admin/users');
|
||||
await searchUserList(page, `${RUN_TAG}hidden`);
|
||||
await checkFirstRow(page);
|
||||
|
||||
const bulkWithdraw = page.locator('#bulk_withdraw');
|
||||
await expect(bulkWithdraw).toBeEnabled({ timeout: 10_000 });
|
||||
|
||||
// 2) 앱이 떠 있는 채로 검색만 바꾼다 — hidden 은 화면에서 사라지지만 전역 상태는 살아 있다.
|
||||
await searchUserList(page, `${RUN_TAG}visible`);
|
||||
|
||||
// 사라진 행의 선택이 남아 있으면 버튼이 살아 있다. 그 상태가 결함이다.
|
||||
await expect(bulkWithdraw).toBeDisabled({ timeout: 20_000 });
|
||||
|
||||
// 3) 보이는 행만 체크하고 일괄 탈퇴를 실행한다.
|
||||
await checkFirstRow(page);
|
||||
await expect(bulkWithdraw).toBeEnabled({ timeout: 10_000 });
|
||||
|
||||
const bulkRequest = page.waitForRequest(
|
||||
(request: any) => request.url().includes('/api/admin/users/bulk-status') && request.method() === 'PATCH'
|
||||
);
|
||||
|
||||
await bulkWithdraw.click();
|
||||
|
||||
// 확인 모달의 실행 버튼은 "확인"(공통 문구)이다 — 모달이 뜬 뒤에 누른다.
|
||||
const confirmButton = page.getByRole('button', { name: /^(확인|Confirm)$/ }).last();
|
||||
await expect(confirmButton).toBeVisible({ timeout: 10_000 });
|
||||
await confirmButton.click();
|
||||
|
||||
const sentIds = (await (await bulkRequest).postDataJSON())?.ids ?? [];
|
||||
|
||||
expect(sentIds, '화면에 보이던 행이 대상에서 빠졌습니다').toContain(visibleUserUuid);
|
||||
expect(sentIds, '화면에서 사라진 행이 일괄 처리 대상에 실렸습니다').not.toContain(hiddenUserUuid);
|
||||
});
|
||||
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* 관리자 회원 수정 폼 — 상태 '탈퇴' 저장 확인 절차 (공개이슈 #112)
|
||||
*
|
||||
* 서버에서 관리자 상태 변경 경로가 정식 탈퇴(비가역 익명화)로 통일되었으므로,
|
||||
* 이 폼의 저장이 경고 없이 회원 정보를 파기하지 않아야 한다.
|
||||
*
|
||||
* // @scenario entry_point=admin_form_ui, target_account=normal, confirm_action=cancel, confirm_action=submit
|
||||
* // @effects admin_form_shows_confirm_dialog_before_destructive_save, admin_form_cancel_leaves_user_untouched, admin_form_non_withdraw_status_saves_without_dialog
|
||||
*/
|
||||
import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth';
|
||||
|
||||
const ADMIN_PERMISSIONS = ['core.users.read', 'core.users.update', 'core.users.create'];
|
||||
|
||||
/** 테스트용 회원을 생성하고 uuid 를 돌려준다. */
|
||||
async function createTestUser(page: any, token: string, email: string): Promise<string> {
|
||||
const headers = { Authorization: `Bearer ${token}`, Accept: 'application/json' };
|
||||
|
||||
// 역할은 필수 입력이다. 관리자 역할을 붙이면 탈퇴 자체가 차단 대상이 되므로
|
||||
// 일반 사용자 역할을 고른다 (목록 첫 항목은 admin 이다).
|
||||
const rolesResponse = await page.request.get('/api/admin/roles/active', { headers });
|
||||
const roles = (await rolesResponse.json())?.data?.data ?? [];
|
||||
const roleId = (roles.find((role: any) => role.identifier === 'user') ?? roles[roles.length - 1])?.id;
|
||||
|
||||
expect(roleId, '일반 사용자 역할을 찾지 못했습니다').toBeTruthy();
|
||||
|
||||
const response = await page.request.post('/api/admin/users', {
|
||||
headers,
|
||||
data: {
|
||||
name: 'E2E 탈퇴확인',
|
||||
email,
|
||||
password: 'Password!234',
|
||||
password_confirmation: 'Password!234',
|
||||
status: 'active',
|
||||
role_ids: [roleId],
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status(), `테스트 회원 생성 실패: ${await response.text()}`).toBeLessThan(300);
|
||||
|
||||
const body = await response.json();
|
||||
|
||||
return body?.data?.uuid ?? body?.data?.id;
|
||||
}
|
||||
|
||||
|
||||
/** 상태 드롭다운에서 라벨을 고르고, 선택이 폼에 반영될 때까지 기다린다. */
|
||||
async function selectStatus(page: any, label: RegExp): Promise<void> {
|
||||
const statusSelect = page.locator('[name="status"][aria-haspopup], [name="status"]').first();
|
||||
await statusSelect.waitFor({ state: 'visible', timeout: 20_000 });
|
||||
|
||||
// 폼이 API 응답으로 시드될 때까지 기다린다 — 시드 전에 저장하면 필수 항목이 빠져 422 가 된다.
|
||||
await expect(page.locator('[name="email"]')).not.toHaveValue('', { timeout: 20_000 });
|
||||
|
||||
await statusSelect.click();
|
||||
await page.getByRole('option', { name: label }).first().click();
|
||||
await expect(statusSelect).toContainText(label, { timeout: 10_000 });
|
||||
}
|
||||
|
||||
test('@smoke 관리자 회원 수정 폼: 상태 탈퇴 저장은 확인을 거치고, 취소하면 회원 정보가 그대로 남는다', async ({ page }) => {
|
||||
const token = issueToken(...ADMIN_PERMISSIONS);
|
||||
await authenticatePage(page, token);
|
||||
|
||||
const email = `g7fix112.e2e.${Date.now()}@example.com`;
|
||||
const uuid = await createTestUser(page, token, email);
|
||||
|
||||
await page.goto(`/admin/users/${uuid}/edit`);
|
||||
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
|
||||
expect(page.url(), '로그인으로 리다이렉트되었습니다').not.toMatch(/\/admin\/login/);
|
||||
|
||||
await selectStatus(page, /탈퇴|Withdraw/i);
|
||||
|
||||
// 저장 → 확인 다이얼로그가 먼저 뜨고, 저장 요청은 나가지 않는다.
|
||||
let saveRequests = 0;
|
||||
page.on('request', (req) => {
|
||||
if (req.url().includes(`/api/admin/users/${uuid}`) && req.method() === 'PUT') {
|
||||
saveRequests += 1;
|
||||
}
|
||||
});
|
||||
|
||||
await page.locator('#footer_save_button').click();
|
||||
|
||||
const dialog = page.getByRole('dialog');
|
||||
await dialog.waitFor({ state: 'visible', timeout: 10_000 });
|
||||
|
||||
// 문구가 비가역성과 파기 대상을 알린다
|
||||
await expect(dialog).toContainText(/되돌릴 수 없|cannot be undone/i);
|
||||
await expect(dialog).toContainText(/익명화|anonymiz/i);
|
||||
|
||||
expect(saveRequests, '확인 전에 저장 요청이 나갔습니다').toBe(0);
|
||||
|
||||
// 취소 → 회원 정보 불변
|
||||
await dialog.getByRole('button').first().click();
|
||||
await expect(page.getByRole('dialog')).toHaveCount(0, { timeout: 10_000 });
|
||||
expect(saveRequests, '취소했는데 저장 요청이 나갔습니다').toBe(0);
|
||||
|
||||
const stillOriginal = await page.request.get(`/api/admin/users/${uuid}`, {
|
||||
headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' },
|
||||
});
|
||||
const stillBody = await stillOriginal.json();
|
||||
expect(stillBody?.data?.email, '취소했는데 이메일이 바뀌었습니다').toBe(email);
|
||||
|
||||
// 재시도 후 확인 → 저장되고 익명화가 반영된다
|
||||
// 다이얼로그 언마운트 직후의 재클릭은 낡은 폼 스냅샷으로 제출될 수 있어 렌더가 가라앉기를 기다린다
|
||||
await page.waitForTimeout(1500);
|
||||
await page.locator('#footer_save_button').click();
|
||||
await expect(page.getByRole('dialog')).toHaveCount(1, { timeout: 15_000 });
|
||||
|
||||
const reopened = page.getByRole('dialog');
|
||||
|
||||
const savePromise = page.waitForResponse(
|
||||
(res) => res.url().includes(`/api/admin/users/${uuid}`) && res.request().method() === 'PUT',
|
||||
{ timeout: 20_000 },
|
||||
);
|
||||
await reopened.getByRole('button').last().click();
|
||||
const saveResponse = await savePromise;
|
||||
|
||||
expect(saveResponse.status(), '탈퇴 저장이 실패했습니다').toBe(200);
|
||||
|
||||
const after = await page.request.get(`/api/admin/users/${uuid}`, {
|
||||
headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' },
|
||||
});
|
||||
const afterBody = await after.json();
|
||||
|
||||
expect(afterBody?.data?.status).toBe('withdrawn');
|
||||
expect(afterBody?.data?.email, '탈퇴했는데 이메일이 익명화되지 않았습니다').not.toBe(email);
|
||||
expect(String(afterBody?.data?.email)).toContain('_deleted_');
|
||||
});
|
||||
|
||||
test('관리자 회원 수정 폼: 탈퇴 외 상태 저장은 확인 없이 즉시 저장된다', async ({ page }) => {
|
||||
const token = issueToken(...ADMIN_PERMISSIONS);
|
||||
await authenticatePage(page, token);
|
||||
|
||||
const email = `g7fix112.e2e.keep.${Date.now()}@example.com`;
|
||||
const uuid = await createTestUser(page, token, email);
|
||||
|
||||
await page.goto(`/admin/users/${uuid}/edit`);
|
||||
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
|
||||
|
||||
await selectStatus(page, /비활성|Inactive/i);
|
||||
|
||||
const savePromise = page.waitForResponse(
|
||||
(res) => res.url().includes(`/api/admin/users/${uuid}`) && res.request().method() === 'PUT',
|
||||
{ timeout: 20_000 },
|
||||
);
|
||||
await page.locator('#footer_save_button').click();
|
||||
const saveResponse = await savePromise;
|
||||
|
||||
expect(saveResponse.status()).toBe(200);
|
||||
|
||||
// 저장이 확정된 뒤에 다이얼로그 부재를 단언한다 (부재 단언은 렌더 전에도 통과한다)
|
||||
await expect(page.getByRole('dialog')).toBeHidden();
|
||||
|
||||
const after = await page.request.get(`/api/admin/users/${uuid}`, {
|
||||
headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' },
|
||||
});
|
||||
const afterBody = await after.json();
|
||||
|
||||
expect(afterBody?.data?.status).toBe('inactive');
|
||||
expect(afterBody?.data?.email, '탈퇴가 아닌데 이메일이 익명화되었습니다').toBe(email);
|
||||
});
|
||||
|
||||
test('관리자 회원 수정 폼: 회원 정보가 채워지기 전에는 저장할 수 없다', async ({ page }) => {
|
||||
const token = issueToken(...ADMIN_PERMISSIONS);
|
||||
await authenticatePage(page, token);
|
||||
|
||||
const email = `g7fix112.e2e.seed.${Date.now()}@example.com`;
|
||||
const uuid = await createTestUser(page, token, email);
|
||||
|
||||
const saveRequests: string[] = [];
|
||||
page.on('request', (req) => {
|
||||
if (req.method() === 'PUT' && req.url().includes(`/api/admin/users/${uuid}`)) {
|
||||
saveRequests.push(String(req.postData()).slice(0, 80));
|
||||
}
|
||||
});
|
||||
|
||||
await page.goto(`/admin/users/${uuid}/edit`);
|
||||
|
||||
// 버튼이 보이자마자 누른다 — 폼이 API 응답으로 채워지기 전 시점이다.
|
||||
const save = page.locator('#footer_save_button');
|
||||
await save.waitFor({ state: 'visible', timeout: 20_000 });
|
||||
await save.click({ force: true }).catch(() => undefined);
|
||||
await page.waitForTimeout(2_000);
|
||||
|
||||
// 빈 본문 저장이 나가면 화면에는 값이 보이는데 "이름은 필수입니다" 로 거절된다.
|
||||
expect(saveRequests, `시드 전에 저장 요청이 나갔습니다: ${saveRequests.join(' | ')}`).toHaveLength(0);
|
||||
|
||||
// 시드가 끝나면 정상적으로 저장할 수 있다 (버튼이 영구 비활성으로 굳지 않는다).
|
||||
await expect(page.locator('[name="email"]')).toHaveValue(email, { timeout: 20_000 });
|
||||
await expect(save).toBeEnabled({ timeout: 10_000 });
|
||||
});
|
||||
Reference in new issue
Block a user