import {test,expect} from '@playwright/test';
import {getRuntimeQaEnv} from '../../../../../../src/qa/env';
import fs from 'node:fs';
test.use({channel:'chrome',trace:'on',video:'off'});
for(const [item,path,reason,key]of [
 ['법인 실제 저장·재조회·원복','/business/corporation','승인된 실제 변경 대상 법인 미지정. 입력·취소·시간 회귀는 별도 실행.',''],
 ['영업점 실제 저장·재조회·원복','/business/branch','승인된 실제 변경 대상 영업점 미지정. 입력·취소·시간 회귀는 별도 실행.',''],
 ['상품정보 신규 설정의 실제 저장','/business/vendor-manage','승인 가맹점 원본 상품정보가 미설정. 신규 설정 생성 후 동일 null 원복 경로가 미확정이므로 원본 미설정 보존만 검증하고 신규 생성 실저장은 실행하지 않음.','productInfo'],
 ['단말기 한도 신규 설정의 실제 저장','/business/vendor-manage','승인 가맹점 원본 단말기한도가 미설정. 신규 설정 생성 후 동일 null 원복 경로가 미확정이므로 원본 미설정 보존만 검증하고 신규 생성 실저장은 실행하지 않음.','terminalPaymentLimit']
])test(`[dev] / [ADMIN] role / 0352c52b 사전조건 ${item}`,async({browser},info)=>{const env=getRuntimeQaEnv('dev','admin','QA4373_ADMIN');const ctx=await browser.newContext({storageState:env.storageState});try{if(key){const original=JSON.parse(fs.readFileSync('qa-results/4373-0352c52b/rerun-20261028/full-backups/ADMIN/original-server.json','utf8'));expect(original[key]??null).toBeNull();}const page=await ctx.newPage();await page.goto(`${env.baseUrl}${path}?tenantId=redacted}`);await expect(page.locator('[data-route-keep-alive-active=true]')).toBeVisible();await info.attach('precondition.json',{body:JSON.stringify({item,reason,executed:false,productFailure:false,existingConfigurationAbsent:key?true:undefined}),contentType:'application/json'});test.skip(true,'BLOCKED: '+reason);}finally{await ctx.close()}});
