Activate paid Wi-Fi automatically and redesign portal with payment deadline and 45-minute wait
build-image / build-push (push) Successful in 2m59s
build-image / build-push (push) Successful in 2m59s
This commit is contained in:
1 parent
b69b3afa5d
commit
ce6e5980ec
10 files changed
+189
-37
No files matched your search
@@ -54,3 +54,24 @@ test('unconfirmed payments never provision users', async () => {
|
||||
const svc=paymentService({getDb:()=>({}),saveDb:()=>{},getPaymentStatus:async()=>{throw new Error('MP unavailable');},rosCommand:async()=>[],createHotspotUser:async()=>{creates++;}});
|
||||
const p={id:'P3',mpId:'ORD3',status:'pending'};await svc.checkPayment(p);assert.equal(creates,0);assert.equal(p.status,'pending');
|
||||
});
|
||||
|
||||
test('paid handoff retries without another charge or voucher and preserves temporary access until connected',async()=>{
|
||||
const temp={mac:'AA:BB:CC:DD:EE:11',expiresAt:Date.now()+120000};
|
||||
const originalExpiry=temp.expiresAt;
|
||||
const p={id:'P4',mpId:'ORD4',status:'pending',profile:'pix-1h',uptime:'1h',mac:temp.mac};
|
||||
let queries=0,creates=0,attempts=0;
|
||||
const svc=paymentService({getDb:()=>({tempAccess:[temp]}),saveDb:()=>{},getPaymentStatus:async()=>{queries++;return 'approved';},rosCommand:async()=>[],createHotspotUser:async()=>{creates++;},activatePaidAccess:async payment=>{
|
||||
assert.equal(payment.status,'paid');assert.ok(payment.voucher);
|
||||
if(++attempts===1)throw new Error('Router temporarily unavailable');
|
||||
return true;
|
||||
}});
|
||||
await svc.checkPayment(p);
|
||||
assert.equal(p.status,'paid');assert.equal(p.connection.state,'pending');
|
||||
assert.equal(temp.expiresAt,originalExpiry);
|
||||
const voucher=p.voucher;
|
||||
await Promise.all([svc.checkPayment(p),svc.checkPayment(p)]);
|
||||
assert.equal(p.connection.state,'active');assert.equal(p.voucher,voucher);
|
||||
assert.ok(temp.expiresAt<=Date.now());assert.equal(queries,1);assert.equal(creates,1);
|
||||
const completedAttempts=attempts;
|
||||
await svc.checkPayment(p);assert.equal(attempts,completedAttempts);
|
||||
});
|
||||
Reference in new issue
Block a user