- gen-*.js: 시나리오 자동 생성기 12종 (CRUD, edge, a11y, perf 등) - search-*.js: 검색/버튼 감사 수집기 3종 - revert-hard-actions.js: 하드 액션 복원 유틸 - _gen_writer.py: 생성기 보조 스크립트 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
539 lines
30 KiB
JavaScript
539 lines
30 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Full CRUD 사이클 테스트 시나리오 생성기
|
|
*
|
|
* 각 페이지에서 Create → Read(상세조회) → Update(수정) → Delete 전체 흐름 + 토스트 검증.
|
|
* 기존 create-delete 패턴을 확장하여 READ(상세 진입+데이터 확인)와 UPDATE(수정+저장) 단계 추가.
|
|
*
|
|
* Usage:
|
|
* node e2e/runner/gen-full-crud.js
|
|
*
|
|
* Output:
|
|
* e2e/scenarios/full-crud-board.json
|
|
* e2e/scenarios/full-crud-acc-bills.json
|
|
* e2e/scenarios/full-crud-acc-deposit.json
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const SCENARIOS_DIR = path.resolve(__dirname, '..', 'scenarios');
|
|
|
|
// ════════════════════════════════════════════════════════════════
|
|
// COMMON HELPERS
|
|
// ════════════════════════════════════════════════════════════════
|
|
const H = [
|
|
`const w=ms=>new Promise(r=>setTimeout(r,ms));`,
|
|
`const sv=(el,v)=>{const p=el.tagName==='TEXTAREA'?HTMLTextAreaElement.prototype:HTMLInputElement.prototype;const ns=Object.getOwnPropertyDescriptor(p,'value')?.set;if(ns)ns.call(el,v);else el.value=v;el.dispatchEvent(new Event('input',{bubbles:true}));el.dispatchEvent(new Event('change',{bubbles:true}));};`,
|
|
`const ts=window.__E2E_TS__||(()=>{const n=new Date();const p=v=>v.toString().padStart(2,'0');return n.getFullYear()+p(n.getMonth()+1)+p(n.getDate())+'_'+p(n.getHours())+p(n.getMinutes())+p(n.getSeconds());})();window.__E2E_TS__=ts;`,
|
|
`const toastInfo=()=>{const ts=document.querySelectorAll('[data-sonner-toast],[role="status"],[class*="toast"],[class*="Toast"],[class*="Toaster"] [data-content]');return{count:ts.length,text:ts.length>0?Array.from(ts).pop()?.innerText?.trim().substring(0,100):''};};`,
|
|
].join('');
|
|
|
|
const BACK_TO_LIST = `(async()=>{const w=ms=>new Promise(r=>setTimeout(r,ms));const onForm=location.search.includes('mode=new')||location.search.includes('mode=edit')||location.search.includes('mode=view')||new RegExp('/(new|[0-9]+|[0-9a-f]{8,})$').test(location.pathname);if(onForm){const btn=Array.from(document.querySelectorAll('button,a')).find(b=>/목록|취소|뒤로/.test(b.innerText?.trim()));if(btn){btn.click();await w(2000);}else{history.back();await w(2000);}}return JSON.stringify({url:location.pathname+location.search});})()`;
|
|
|
|
// ════════════════════════════════════════════════════════════════
|
|
// PAGE CONFIGURATIONS
|
|
// ════════════════════════════════════════════════════════════════
|
|
const PAGES = {
|
|
// ─── 자유게시판 ─────────────────────────────────────────────
|
|
board: {
|
|
id: 'full-crud-board',
|
|
name: 'Full CRUD 테스트: 자유게시판',
|
|
menuNavigation: { level1: '게시판', level2: '자유게시판' },
|
|
|
|
createScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'CREATE',ts};`,
|
|
`const testTitle='E2E_TEST_게시글_'+ts;R.testTitle=testTitle;`,
|
|
`const btn=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='글쓰기'||/등록|작성/.test(b.innerText?.trim()));`,
|
|
`if(!btn){R.error='글쓰기 버튼 없음';return JSON.stringify(R);}`,
|
|
`btn.click();await w(2500);`,
|
|
`const titleInput=document.querySelector('input[placeholder*="제목"]')||document.querySelector('input[type="text"]');`,
|
|
`if(!titleInput){R.error='제목 입력란 없음';return JSON.stringify(R);}`,
|
|
`sv(titleInput,testTitle);await w(200);`,
|
|
`const ta=document.querySelector('textarea');`,
|
|
`if(ta){sv(ta,'E2E Full CRUD 테스트 게시글. 자동 삭제 예정.');await w(200);}`,
|
|
`const sub=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='등록');`,
|
|
`if(!sub){R.error='등록 버튼 없음';return JSON.stringify(R);}`,
|
|
`sub.click();await w(3000);`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyCreateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_CREATE'};await w(500);`,
|
|
`const rows=document.querySelectorAll('table tbody tr');R.rowCount=rows.length;`,
|
|
`const found=Array.from(rows).find(r=>r.innerText?.includes('E2E_TEST_'));`,
|
|
`R.found=!!found;R.ok=R.found;`,
|
|
`if(found)R.foundText=found.innerText?.substring(0,80);`,
|
|
`R.toast=toastInfo();`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
readScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'READ'};`,
|
|
`let row;for(let i=0;i<3;i++){const rows=Array.from(document.querySelectorAll('table tbody tr'));row=rows.find(r=>r.innerText?.includes('E2E_TEST_'));if(row)break;await w(1000);}`,
|
|
`if(!row){R.error='E2E_TEST_ 행 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`row.click();await w(2500);`,
|
|
`R.detailUrl=location.pathname+location.search;`,
|
|
`const inputs=Array.from(document.querySelectorAll('input,textarea')).filter(i=>i.offsetParent!==null);`,
|
|
`R.hasE2E=document.body.innerText.includes('E2E_TEST_')||inputs.some(i=>i.value?.includes('E2E_TEST_'));`,
|
|
`R.ok=R.hasE2E;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
readVerifyScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'READ_VERIFY'};`,
|
|
`R.url=location.pathname+location.search;`,
|
|
`const pageText=document.body.innerText;`,
|
|
`R.hasTitle=pageText.includes('E2E_TEST_게시글');`,
|
|
`R.hasContent=pageText.includes('Full CRUD 테스트');`,
|
|
`R.ok=R.hasTitle;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
updateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'UPDATE'};`,
|
|
// Click 수정 button
|
|
`const editBtn=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='수정');`,
|
|
`if(!editBtn){R.error='수정 버튼 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`editBtn.click();await w(2000);`,
|
|
`R.editUrl=location.pathname+location.search;`,
|
|
// Find title input and modify
|
|
`const titleInput=document.querySelector('input[placeholder*="제목"]')||document.querySelector('input[type="text"]');`,
|
|
`if(!titleInput){R.error='제목 입력란 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`const cur=titleInput.value;`,
|
|
`sv(titleInput,cur.replace('E2E_TEST_게시글','E2E_TEST_수정됨'));await w(200);`,
|
|
// Click save
|
|
`const saveBtn=Array.from(document.querySelectorAll('button')).find(b=>/저장|수정완료|확인/.test(b.innerText?.trim())&&b!==editBtn&&b.offsetParent!==null);`,
|
|
`if(saveBtn){saveBtn.click();await w(3000);}`,
|
|
`else{const sub=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='등록');if(sub){sub.click();await w(3000);}}`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyUpdateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_UPDATE'};`,
|
|
`R.url=location.pathname+location.search;`,
|
|
`const pageText=document.body.innerText;`,
|
|
`const inputs=Array.from(document.querySelectorAll('input,textarea')).filter(i=>i.offsetParent!==null);`,
|
|
`R.hasModified=pageText.includes('수정됨')||inputs.some(i=>i.value?.includes('수정됨'));`,
|
|
`R.toast=toastInfo();`,
|
|
`const toastOk=R.toast.text&&(/수정|완료|저장|성공/.test(R.toast.text));`,
|
|
`R.toastOk=toastOk;R.ok=R.hasModified||toastOk;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
deleteScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'DELETE'};`,
|
|
// If on list, find and click the row first
|
|
`const onDetail=location.search.includes('mode=view')||location.search.includes('mode=edit')||new RegExp('/[0-9]+$|/[0-9a-f]{8,}$').test(location.pathname);`,
|
|
`if(!onDetail){`,
|
|
` const rows=Array.from(document.querySelectorAll('table tbody tr'));`,
|
|
` const row=rows.find(r=>r.innerText?.includes(ts))||rows.find(r=>r.innerText?.includes('E2E_TEST_'));`,
|
|
` if(!row){R.error='E2E_TEST_ 행 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
` row.click();await w(2500);`,
|
|
`}`,
|
|
`R.detailUrl=location.pathname+location.search;R.ts=ts;`,
|
|
`const delBtn=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='삭제');`,
|
|
`if(!delBtn){R.error='삭제 버튼 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`delBtn.click();await w(1000);`,
|
|
`const cfm=Array.from(document.querySelectorAll('[role="alertdialog"] button,[role="dialog"] button,button')).find(b=>/확인|삭제|예|Yes/.test(b.innerText?.trim())&&b!==delBtn&&b.offsetParent!==null);`,
|
|
`if(cfm){cfm.click();await w(3000);}`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyDeleteScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_DELETE'};await w(1000);`,
|
|
`const onDetail=location.search.includes('mode=view')||new RegExp('/[0-9]+$|/[0-9a-f]{8,}$').test(location.pathname);`,
|
|
`if(onDetail){const btn=Array.from(document.querySelectorAll('button,a')).find(b=>/목록/.test(b.innerText?.trim()));if(btn){btn.click();await w(2000);}else{history.back();await w(2000);}}`,
|
|
`R.url=location.pathname;`,
|
|
`const rows=document.querySelectorAll('table tbody tr');R.rowCount=rows.length;`,
|
|
`const found=Array.from(rows).find(r=>r.innerText?.includes(ts));`,
|
|
`R.stillExists=!!found;R.ok=!found;`,
|
|
`if(found)R.warn='E2E_TEST_ 데이터가 여전히 존재';`,
|
|
`R.ts=ts;R.toast=toastInfo();`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
},
|
|
|
|
// ─── 어음관리 ───────────────────────────────────────────────
|
|
bills: {
|
|
id: 'full-crud-acc-bills',
|
|
name: 'Full CRUD 테스트: 어음관리',
|
|
menuNavigation: { level1: '회계관리', level2: '어음관리' },
|
|
|
|
createScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'CREATE',ts};`,
|
|
`const testId='E2E'+ts.replace(/_/g,'').substring(4,10);R.testId=testId;`,
|
|
`const btn=Array.from(document.querySelectorAll('button')).find(b=>/어음.*등록|등록/.test(b.innerText?.trim()));`,
|
|
`if(!btn){R.error='등록 버튼 없음';return JSON.stringify(R);}`,
|
|
`btn.click();await w(2500);`,
|
|
// 어음번호
|
|
`const numInput=document.querySelector('input[placeholder*="어음번호"]')||Array.from(document.querySelectorAll('input[type="text"]')).find(i=>i.offsetParent!==null&&!i.readOnly&&!i.disabled);`,
|
|
`if(numInput){sv(numInput,'E2E_TEST_'+testId);await w(200);}`,
|
|
// 거래처 combobox
|
|
`const combos=Array.from(document.querySelectorAll('button[role="combobox"]')).filter(b=>b.offsetParent!==null);`,
|
|
`for(let i=0;i<combos.length;i++){const cb=combos[i];const lbl=cb.closest('[class*=field],[class*=Field],[class*=form-item]')?.querySelector('label')?.innerText||'';`,
|
|
`if(lbl.includes('거래처')||i===1){cb.click();await w(600);const lb=document.querySelector('[role="listbox"]');`,
|
|
`if(lb){const opt=lb.querySelector('[role="option"]');if(opt){opt.click();await w(400);}}`,
|
|
`else{document.dispatchEvent(new KeyboardEvent('keydown',{key:'Escape',bubbles:true}));await w(200);}break;}}`,
|
|
// 금액
|
|
`const amt=document.querySelector('input[placeholder*="금액"]');if(amt){sv(amt,'10000');await w(200);}`,
|
|
// 비고
|
|
`const note=document.querySelector('input[placeholder*="비고"]');if(note){sv(note,'E2E_TEST_어음_'+ts);await w(200);}`,
|
|
// 등록
|
|
`const sub=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='등록'&&b.offsetParent!==null);`,
|
|
`if(!sub){R.error='등록 버튼 없음';return JSON.stringify(R);}`,
|
|
`sub.click();await w(3000);`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyCreateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_CREATE'};await w(500);`,
|
|
`const rows=document.querySelectorAll('table tbody tr');R.rowCount=rows.length;`,
|
|
`const found=Array.from(rows).find(r=>r.innerText?.includes('E2E_TEST_')||r.innerText?.includes('E2E'));`,
|
|
`R.found=!!found;R.ok=R.found;`,
|
|
`if(found)R.foundText=found.innerText?.substring(0,80);`,
|
|
`R.toast=toastInfo();`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
readScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'READ'};`,
|
|
`let row;for(let i=0;i<3;i++){const rows=Array.from(document.querySelectorAll('table tbody tr'));row=rows.find(r=>r.innerText?.includes('E2E_TEST_')||r.innerText?.includes('E2E'));if(row)break;await w(1000);}`,
|
|
`if(!row){R.error='E2E_TEST_ 행 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`row.click();await w(2500);`,
|
|
`R.detailUrl=location.pathname+location.search;`,
|
|
`const inputs=Array.from(document.querySelectorAll('input,textarea')).filter(i=>i.offsetParent!==null);`,
|
|
`R.hasE2E=document.body.innerText.includes('E2E_TEST_')||document.body.innerText.includes('E2E')||inputs.some(i=>i.value?.includes('E2E_TEST_')||i.value?.includes('E2E'));`,
|
|
`R.ok=R.hasE2E;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
readVerifyScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'READ_VERIFY'};`,
|
|
`R.url=location.pathname+location.search;`,
|
|
`const inputs=Array.from(document.querySelectorAll('input,textarea')).filter(i=>i.offsetParent!==null);`,
|
|
`R.fieldCount=inputs.length;`,
|
|
`const hasTestData=inputs.some(i=>i.value?.includes('E2E_TEST_')||i.value?.includes('E2E'));`,
|
|
`R.hasTestData=hasTestData||document.body.innerText.includes('E2E_TEST_');`,
|
|
`R.ok=R.hasTestData;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
updateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'UPDATE'};`,
|
|
`const editBtn=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='수정');`,
|
|
`if(!editBtn){R.error='수정 버튼 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`editBtn.click();await w(2000);`,
|
|
// Modify 비고 field
|
|
`const noteInput=document.querySelector('input[placeholder*="비고"]')||Array.from(document.querySelectorAll('input[type="text"]')).filter(i=>i.offsetParent!==null&&!i.readOnly&&!i.disabled).pop();`,
|
|
`if(noteInput){sv(noteInput,'E2E_수정됨_'+ts);await w(200);R.modified='비고';}`,
|
|
`else{const inputs=Array.from(document.querySelectorAll('input[type="text"]')).filter(i=>i.offsetParent!==null&&!i.readOnly&&!i.disabled);`,
|
|
`if(inputs.length>0){sv(inputs[0],inputs[0].value+'_수정됨');await w(200);R.modified='input[0]';}}`,
|
|
// Save
|
|
`const saveBtn=Array.from(document.querySelectorAll('button')).find(b=>/저장|수정|확인/.test(b.innerText?.trim())&&b!==editBtn&&b.offsetParent!==null);`,
|
|
`if(saveBtn){saveBtn.click();await w(3000);}`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyUpdateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_UPDATE'};`,
|
|
`const pageText=document.body.innerText;`,
|
|
`const inputs=Array.from(document.querySelectorAll('input,textarea')).filter(i=>i.offsetParent!==null);`,
|
|
`const hasModified=pageText.includes('수정됨')||inputs.some(i=>i.value?.includes('수정됨'));`,
|
|
`R.toast=toastInfo();`,
|
|
`const toastOk=R.toast.text&&(/수정|완료|저장|성공/.test(R.toast.text));`,
|
|
`R.hasModified=hasModified;R.toastOk=toastOk;R.ok=hasModified||toastOk;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
deleteScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'DELETE'};`,
|
|
`if(!location.search.includes('mode=view')&&!location.search.includes('mode=edit')){`,
|
|
` const rows=Array.from(document.querySelectorAll('table tbody tr'));`,
|
|
` const row=rows.find(r=>r.innerText?.includes('E2E_TEST_')||r.innerText?.includes('E2E'));`,
|
|
` if(!row){R.error='E2E_TEST_ 행 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
` row.click();await w(2500);`,
|
|
`}`,
|
|
`const delBtn=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='삭제');`,
|
|
`if(!delBtn){R.error='삭제 버튼 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`delBtn.click();await w(1000);`,
|
|
`const cfm=Array.from(document.querySelectorAll('[role="alertdialog"] button,[role="dialog"] button,button')).find(b=>/확인|삭제|예|Yes/.test(b.innerText?.trim())&&b!==delBtn&&b.offsetParent!==null);`,
|
|
`if(cfm){cfm.click();await w(3000);}`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyDeleteScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_DELETE'};await w(1000);`,
|
|
`if(location.search.includes('mode=view')){`,
|
|
` const btn=Array.from(document.querySelectorAll('button,a')).find(b=>/목록/.test(b.innerText?.trim()));`,
|
|
` if(btn){btn.click();await w(2000);}else{history.back();await w(2000);}}`,
|
|
`const rows=document.querySelectorAll('table tbody tr');R.rowCount=rows.length;`,
|
|
`const found=Array.from(rows).find(r=>r.innerText?.includes(ts));`,
|
|
`R.stillExists=!!found;R.ok=!found;R.ts=ts;`,
|
|
`R.toast=toastInfo();`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
},
|
|
|
|
// ─── 입금관리 ───────────────────────────────────────────────
|
|
deposit: {
|
|
id: 'full-crud-acc-deposit',
|
|
name: 'Full CRUD 테스트: 입금관리',
|
|
menuNavigation: { level1: '회계관리', level2: '입금관리' },
|
|
|
|
createScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'CREATE',ts};`,
|
|
`const btn=Array.from(document.querySelectorAll('button')).find(b=>/입금.*등록|입금등록|등록/.test(b.innerText?.trim()));`,
|
|
`if(!btn){R.error='등록 버튼 없음';return JSON.stringify(R);}`,
|
|
`btn.click();await w(2500);`,
|
|
// 입금자명
|
|
`const nameIn=document.querySelector('input[placeholder*="입금자명"]')||document.querySelector('input[placeholder*="입금자"]');`,
|
|
`if(nameIn){sv(nameIn,'E2E_TEST_입금자_'+ts);await w(200);}`,
|
|
// 입금금액
|
|
`const amtIn=document.querySelector('input[placeholder*="입금금액"]')||document.querySelector('input[type="number"]');`,
|
|
`if(amtIn){sv(amtIn,'50000');await w(200);}`,
|
|
// 적요
|
|
`const noteIn=document.querySelector('input[placeholder*="적요"]');`,
|
|
`if(noteIn){sv(noteIn,'E2E_TEST_입금_'+ts);await w(200);}`,
|
|
// 거래처 combobox
|
|
`const combos=Array.from(document.querySelectorAll('button[role="combobox"]')).filter(b=>b.offsetParent!==null);`,
|
|
`for(const cb of combos){const lbl=cb.closest('[class*=field],[class*=Field],[class*=form-item]')?.querySelector('label')?.innerText||'';`,
|
|
`if(lbl.includes('거래처')){cb.click();await w(600);const lb=document.querySelector('[role="listbox"]');`,
|
|
`if(lb){const opt=lb.querySelector('[role="option"]');if(opt){opt.click();await w(400);}}`,
|
|
`else{document.dispatchEvent(new KeyboardEvent('keydown',{key:'Escape',bubbles:true}));await w(200);}break;}}`,
|
|
// 입금유형 combobox
|
|
`for(const cb of combos){const lbl=cb.closest('[class*=field],[class*=Field],[class*=form-item]')?.querySelector('label')?.innerText||'';`,
|
|
`if(lbl.includes('유형')){cb.click();await w(600);const lb=document.querySelector('[role="listbox"]');`,
|
|
`if(lb){const opt=lb.querySelector('[role="option"]');if(opt){opt.click();await w(400);}}`,
|
|
`else{document.dispatchEvent(new KeyboardEvent('keydown',{key:'Escape',bubbles:true}));await w(200);}break;}}`,
|
|
// 등록
|
|
`const sub=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='등록'&&b.offsetParent!==null);`,
|
|
`if(!sub){R.error='등록 버튼 없음';return JSON.stringify(R);}`,
|
|
`sub.click();await w(3000);`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyCreateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_CREATE'};await w(500);`,
|
|
`const rows=document.querySelectorAll('table tbody tr');R.rowCount=rows.length;`,
|
|
`const found=Array.from(rows).find(r=>r.innerText?.includes('E2E_TEST_'));`,
|
|
`R.found=!!found;R.ok=R.found;`,
|
|
`if(found)R.foundText=found.innerText?.substring(0,80);`,
|
|
`R.toast=toastInfo();`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
readScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'READ'};`,
|
|
`let row;for(let i=0;i<3;i++){const rows=Array.from(document.querySelectorAll('table tbody tr'));row=rows.find(r=>r.innerText?.includes('E2E_TEST_'));if(row)break;await w(1000);}`,
|
|
`if(!row){R.error='E2E_TEST_ 행 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`row.click();await w(2500);`,
|
|
`R.detailUrl=location.pathname+location.search;`,
|
|
`const inputs=Array.from(document.querySelectorAll('input,textarea')).filter(i=>i.offsetParent!==null);`,
|
|
`R.hasE2E=document.body.innerText.includes('E2E_TEST_')||inputs.some(i=>i.value?.includes('E2E_TEST_'));`,
|
|
`R.ok=R.hasE2E;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
readVerifyScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'READ_VERIFY'};`,
|
|
`R.url=location.pathname+location.search;`,
|
|
`const inputs=Array.from(document.querySelectorAll('input,textarea')).filter(i=>i.offsetParent!==null);`,
|
|
`R.fieldCount=inputs.length;`,
|
|
`const hasTestData=inputs.some(i=>i.value?.includes('E2E_TEST_'))||document.body.innerText.includes('E2E_TEST_');`,
|
|
`R.hasTestData=hasTestData;R.ok=hasTestData;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
updateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'UPDATE'};`,
|
|
`const editBtn=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='수정');`,
|
|
`if(!editBtn){R.error='수정 버튼 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`editBtn.click();await w(2000);`,
|
|
// Modify 적요 field
|
|
`const noteIn=document.querySelector('input[placeholder*="적요"]');`,
|
|
`if(noteIn){sv(noteIn,'E2E_수정됨_'+ts);await w(200);R.modified='적요';}`,
|
|
`else{const inputs=Array.from(document.querySelectorAll('input[type="text"]')).filter(i=>i.offsetParent!==null&&!i.readOnly&&!i.disabled);`,
|
|
`if(inputs.length>0){sv(inputs[0],inputs[0].value+'_수정됨');await w(200);R.modified='input[0]';}}`,
|
|
// Save
|
|
`const saveBtn=Array.from(document.querySelectorAll('button')).find(b=>/저장|수정|확인/.test(b.innerText?.trim())&&b!==editBtn&&b.offsetParent!==null);`,
|
|
`if(saveBtn){saveBtn.click();await w(3000);}`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyUpdateScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_UPDATE'};`,
|
|
`const pageText=document.body.innerText;`,
|
|
`const inputs=Array.from(document.querySelectorAll('input,textarea')).filter(i=>i.offsetParent!==null);`,
|
|
`const hasModified=pageText.includes('수정됨')||inputs.some(i=>i.value?.includes('수정됨'));`,
|
|
`R.toast=toastInfo();`,
|
|
`const toastOk=R.toast.text&&(/수정|완료|저장|성공/.test(R.toast.text));`,
|
|
`R.hasModified=hasModified;R.toastOk=toastOk;R.ok=hasModified||toastOk;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
deleteScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'DELETE'};`,
|
|
`if(!location.search.includes('mode=view')&&!location.search.includes('mode=edit')){`,
|
|
` const rows=Array.from(document.querySelectorAll('table tbody tr'));`,
|
|
` const row=rows.find(r=>r.innerText?.includes('E2E_TEST_'));`,
|
|
` if(!row){R.error='E2E_TEST_ 행 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
` row.click();await w(2500);`,
|
|
`}`,
|
|
`const delBtn=Array.from(document.querySelectorAll('button')).find(b=>b.innerText?.trim()==='삭제');`,
|
|
`if(!delBtn){R.error='삭제 버튼 없음';R.ok=false;return JSON.stringify(R);}`,
|
|
`delBtn.click();await w(1000);`,
|
|
`const cfm=Array.from(document.querySelectorAll('[role="alertdialog"] button,[role="dialog"] button,button')).find(b=>/확인|삭제|예|Yes/.test(b.innerText?.trim())&&b!==delBtn&&b.offsetParent!==null);`,
|
|
`if(cfm){cfm.click();await w(3000);}`,
|
|
`R.toast=toastInfo();R.ok=true;`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
|
|
verifyDeleteScript: [
|
|
`(async()=>{`, H,
|
|
`const R={phase:'VERIFY_DELETE'};await w(1000);`,
|
|
`if(location.search.includes('mode=view')){`,
|
|
` const btn=Array.from(document.querySelectorAll('button,a')).find(b=>/목록/.test(b.innerText?.trim()));`,
|
|
` if(btn){btn.click();await w(2000);}else{history.back();await w(2000);}}`,
|
|
`const rows=document.querySelectorAll('table tbody tr');R.rowCount=rows.length;`,
|
|
`const found=Array.from(rows).find(r=>r.innerText?.includes(ts));`,
|
|
`R.stillExists=!!found;R.ok=!found;R.ts=ts;`,
|
|
`R.toast=toastInfo();`,
|
|
`return JSON.stringify(R);`,
|
|
`})()`,
|
|
].join(''),
|
|
},
|
|
};
|
|
|
|
// ════════════════════════════════════════════════════════════════
|
|
// SCENARIO GENERATOR
|
|
// ════════════════════════════════════════════════════════════════
|
|
function generateScenario(pageKey) {
|
|
const pg = PAGES[pageKey];
|
|
const steps = [];
|
|
let id = 1;
|
|
const nav = pg.menuNavigation;
|
|
const pfx = `[${nav.level1} > ${nav.level2}]`;
|
|
|
|
// ─── SETUP ───
|
|
steps.push({ id: id++, name: `${pfx} 페이지 로드 대기`, action: 'wait', timeout: 3000 });
|
|
steps.push({ id: id++, name: `${pfx} 테이블 로드 대기`, action: 'wait_for_table', timeout: 5000 });
|
|
|
|
// ─── CREATE ───
|
|
steps.push({ id: id++, name: `${pfx} [CREATE] 데이터 생성`, action: 'evaluate', script: pg.createScript, timeout: 30000, phase: 'CREATE' });
|
|
steps.push({ id: id++, name: `${pfx} [CREATE] 생성 후 대기`, action: 'wait', timeout: 3000 });
|
|
steps.push({ id: id++, name: `${pfx} [CREATE] 목록 복귀`, action: 'evaluate', script: BACK_TO_LIST, timeout: 10000, phase: 'CREATE' });
|
|
steps.push({ id: id++, name: `${pfx} [CREATE] 목록 안정화 대기`, action: 'wait', timeout: 2000 });
|
|
|
|
// ─── VERIFY CREATE ───
|
|
steps.push({ id: id++, name: `${pfx} [VERIFY] 생성 데이터 확인`, action: 'evaluate', script: pg.verifyCreateScript, timeout: 15000, phase: 'VERIFY' });
|
|
|
|
// ─── READ (상세 조회) ───
|
|
steps.push({ id: id++, name: `${pfx} [READ] 상세 페이지 진입`, action: 'evaluate', script: pg.readScript, timeout: 15000, phase: 'READ' });
|
|
steps.push({ id: id++, name: `${pfx} [READ] 상세 페이지 대기`, action: 'wait', timeout: 2000 });
|
|
steps.push({ id: id++, name: `${pfx} [READ] 상세 데이터 검증`, action: 'evaluate', script: pg.readVerifyScript, timeout: 15000, phase: 'READ' });
|
|
|
|
// ─── UPDATE (수정) ───
|
|
steps.push({ id: id++, name: `${pfx} [UPDATE] 수정 및 저장`, action: 'evaluate', script: pg.updateScript, timeout: 30000, phase: 'UPDATE' });
|
|
steps.push({ id: id++, name: `${pfx} [UPDATE] 저장 후 대기`, action: 'wait', timeout: 3000 });
|
|
steps.push({ id: id++, name: `${pfx} [UPDATE] 수정 내용 검증`, action: 'evaluate', script: pg.verifyUpdateScript, timeout: 15000, phase: 'UPDATE' });
|
|
|
|
// ─── Back to list for DELETE ───
|
|
steps.push({ id: id++, name: `${pfx} [UPDATE] 목록 복귀`, action: 'evaluate', script: BACK_TO_LIST, timeout: 10000, phase: 'UPDATE' });
|
|
steps.push({ id: id++, name: `${pfx} [UPDATE] 목록 안정화 대기`, action: 'wait', timeout: 2000 });
|
|
|
|
// ─── DELETE ───
|
|
steps.push({ id: id++, name: `${pfx} [DELETE] 데이터 삭제`, action: 'evaluate', script: pg.deleteScript, timeout: 30000, phase: 'DELETE', critical: true });
|
|
steps.push({ id: id++, name: `${pfx} [DELETE] 삭제 후 대기`, action: 'wait', timeout: 3000 });
|
|
steps.push({ id: id++, name: `${pfx} [DELETE] 목록 복귀`, action: 'evaluate', script: BACK_TO_LIST, timeout: 10000, phase: 'DELETE' });
|
|
steps.push({ id: id++, name: `${pfx} [DELETE] 목록 안정화 대기`, action: 'wait', timeout: 2000 });
|
|
|
|
// ─── VERIFY DELETE ───
|
|
steps.push({ id: id++, name: `${pfx} [VERIFY] 삭제 확인`, action: 'evaluate', script: pg.verifyDeleteScript, timeout: 15000, phase: 'VERIFY' });
|
|
|
|
return {
|
|
id: pg.id,
|
|
name: pg.name,
|
|
version: '1.0.0',
|
|
auth: { role: 'admin' },
|
|
menuNavigation: pg.menuNavigation,
|
|
screenshotPolicy: { captureOnFail: true, captureOnPass: false },
|
|
steps,
|
|
};
|
|
}
|
|
|
|
// ════════════════════════════════════════════════════════════════
|
|
// MAIN
|
|
// ════════════════════════════════════════════════════════════════
|
|
function main() {
|
|
if (!fs.existsSync(SCENARIOS_DIR)) fs.mkdirSync(SCENARIOS_DIR, { recursive: true });
|
|
|
|
const generated = [];
|
|
for (const key of Object.keys(PAGES)) {
|
|
const scenario = generateScenario(key);
|
|
const filePath = path.join(SCENARIOS_DIR, `${scenario.id}.json`);
|
|
fs.writeFileSync(filePath, JSON.stringify(scenario, null, 2), 'utf-8');
|
|
generated.push({ id: scenario.id, steps: scenario.steps.length });
|
|
console.log(` ${scenario.id}.json (${scenario.steps.length} steps)`);
|
|
}
|
|
|
|
console.log(`\n Generated ${generated.length} scenarios`);
|
|
console.log(`\n Run: node e2e/runner/run-all.js --filter full-crud`);
|
|
}
|
|
|
|
main();
|