@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 19b1464
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 14:30 UTC

test(admin): verify redacted Persian server rejection and cleared temporary password

davoodmehraban89 committed Oct 12, 2026 at 11:18 UTC 19b1464edb0cd0ccac2202fc7a6ae2fc8bd8dceb
1 file changed +23
scripts/admin-provisioning.spec.js
+23
@@ -48,3 +48,26 @@ test('invalid email/weak password are rejected client-side without invoking serv
48 await page.locator('#modal-admin-create-user button').filter({hasText:'بستن'}).click();
49 await expect(page.locator('#modal-admin-create-user')).not.toHaveClass(/active/);
50 });
51 +
52 +test('server-side provisioning 400 shows actionable safe Persian reason without leaking raw HTTP error',async({page})=>{
53 + await page.goto(BASE,{waitUntil:'domcontentloaded'});
54 + await page.evaluate(()=>{
55 + currentUser={id:'OWNER_QA',role:'admin'};
56 + document.getElementById('auth-screen').style.display='none';
57 + window.__calls=0;
58 + window.confirm=()=>true;
59 + Object.defineProperty(sb,'functions',{configurable:true,value:{invoke:async()=>{
60 + window.__calls++;
61 + return {data:null,error:{message:'Edge Function returned a non-2xx status code',context:new Response(JSON.stringify({error:'unexpected_failure'}),{status:400,headers:{'content-type':'application/json'}})}};
62 + }}});
63 + adminOpenCreateUser();
64 + });
65 + await page.locator('#admin-new-email').fill('test@example.invalid');
66 + await page.locator('#admin-new-password').fill('Temp!Password1234');
67 + await page.locator('#admin-create-submit').click();
68 + await expect(page.locator('#admin-create-status')).toContainText('پایگاه داده ساخت حساب را رد کرده است');
69 + await expect(page.locator('#admin-create-status')).not.toContainText('non-2xx');
70 + await expect(page.locator('#admin-new-password')).toHaveValue('');
71 + expect(await page.evaluate(()=>window.__calls)).toBe(1);
72 + await expect(page.locator('#modal-admin-create-user.active')).toBeVisible();
73 +});