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

test(finora): assert read-only member cannot create inventory counts

davoodmehraban89 committed Nov 23, 2026 at 18:18 UTC 0b15eaad209e3c51be7b9823034f14bfbee9c6dc
1 file changed +15 -10
scripts/wp2-stock-tenant-jwt-e2e.mjs
+15 -10
@@ -186,16 +186,21 @@ try{
186 assert.deepEqual((await rows(collection,aid,jwtA))[0].data,oldData,
187 'FINORA_ISSUE223_POSTED_IMMUTABILITY_BYPASS: '+collection);
188 }
189 - const readOnlyCreateId='QA223_READONLY_CREATE_'+suffix;
190 - const readOnlyCreate=await rest('records?select=id',jwtC,{
191 - method:'POST',headers:{'Content-Type':'application/json',Prefer:'return=representation'},
192 - body:JSON.stringify({organization_id:orgA,owner_id:c.id,collection:'stockMovements',
193 - id:readOnlyCreateId,data:movementData(c.id,ca1,whA1,1)})
194 - });
195 - assert.ok([401,403].includes(readOnlyCreate.status),
196 - 'FINORA_ISSUE223_READONLY_CREATE_ALLOWED: inventory:read member HTTP '+readOnlyCreate.status);
197 - assert.deepEqual(await rows('stockMovements',readOnlyCreateId,jwtA),[],
198 - 'read-only inventory member created a stock movement');
189 + // Read-only must not create either supported stock source collection.
190 + for(const [collection,data] of [
191 + ['stockMovements',movementData(c.id,ca1,whA1,1)],
192 + ['inventoryCounts',countData(c.id,ca1,whA1,1)]
193 + ]){
194 + const readOnlyCreateId='QA223_READONLY_CREATE_'+collection+'_'+suffix;
195 + const readOnlyCreate=await rest('records?select=id',jwtC,{
196 + method:'POST',headers:{'Content-Type':'application/json',Prefer:'return=representation'},
197 + body:JSON.stringify({organization_id:orgA,owner_id:c.id,collection,id:readOnlyCreateId,data})
198 + });
199 + assert.ok([401,403].includes(readOnlyCreate.status),
200 + 'FINORA_ISSUE223_READONLY_CREATE_ALLOWED: '+collection+' inventory:read member HTTP '+readOnlyCreate.status);
201 + assert.deepEqual(await rows(collection,readOnlyCreateId,jwtA),[],
202 + 'read-only inventory member created '+collection);
203 + }
204 // Owners have organization-wide scope and legitimately see A1/A2. A delegated
205 // member with company scope A1 sees A1 only; neither result is the UI selector.
206 // Client active-company Kardex filtering remains a separate product acceptance gate.