35 lines
1.8 KiB
JavaScript
35 lines
1.8 KiB
JavaScript
const fs = require('node:fs')
|
|||
|
|
const assert = require('node:assert/strict')
|
||
|
|
const root = '/Volumes/Extreme SSD/yawan-storage/weknora/acceptance'
|
||
|
|
const base = 'http://127.0.0.1:18080/api/v1'
|
||
|
|
const fixtures = [
|
||
|
|
['training-maps','c9fb3c98-a9f3-40f0-8ac0-2756c83288de'],
|
||
|
|
['training-maps','013a398f-fe0e-4287-8f3f-6fe7d6f468f9'],
|
||
|
|
['flows','1011c8bc-a0f4-4baf-abab-cd1c05a85889'],
|
||
|
|
['flows','15fc92d5-d0f8-416f-97bc-1927ffe39a71'],
|
||
|
|
['agents','6065fcd5-d827-40a1-8fe4-902906576b85'],
|
||
|
|
['agents','e69f8f18-010d-43c7-be2c-4cd1409df2aa'],
|
||
|
|
]
|
||
|
|
async function main() {
|
||
|
|
const c=JSON.parse(fs.readFileSync(`${root}/super-admin-login.json`,'utf8'))
|
||
|
|
const login=await fetch(`${base}/auth/login`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({email:c.email,password:c.password})})
|
||
|
|
assert.equal(login.status,200)
|
||
|
|
const auth=await login.json()
|
||
|
|
const headers={Authorization:`Bearer ${auth.token}`,'X-Tenant-ID':'10059'}
|
||
|
|
const archive=[]
|
||
|
|
for(const [kind,id] of fixtures) {
|
||
|
|
const path=kind==='agents'?`/agents/${id}`:`/workbench/resources/${kind}/${id}`
|
||
|
|
const r=await fetch(base+path,{headers})
|
||
|
|
if(r.status===404) continue
|
||
|
|
assert.equal(r.status,200)
|
||
|
|
const row=(await r.json()).data
|
||
|
|
assert.ok(/^real-generation-178958(7501724|7865185)/.test(row.name),'Only known failed verification fixtures may be removed')
|
||
|
|
archive.push({kind,row})
|
||
|
|
fs.writeFileSync(`${root}/failed-generation-fixtures-archived.json`,JSON.stringify(archive,null,2),{mode:0o600})
|
||
|
|
const deletion=await fetch(base+path,{method:'DELETE',headers})
|
||
|
|
assert.ok([200,204].includes(deletion.status),`Fixture deletion ${deletion.status}`)
|
||
|
|
}
|
||
|
|
console.log(JSON.stringify({removed:archive.length,preserved:'Successful real-generation sample, usage ledger and test evidence'}))
|
||
|
|
}
|
||
|
|
main().catch(e=>{console.error(e.message);process.exitCode=1})
|