26 lines
1.5 KiB
TypeScript
26 lines
1.5 KiB
TypeScript
import {test} from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {readFileSync} from 'node:fs';
|
|
import {clockAuthDestination} from './clock-pwa';
|
|
import {employeeCodeFromBadge, employeeBadgePayload} from './clock-badge';
|
|
|
|
test('clock is a distinct standalone PWA that starts and stays in /clock',()=>{
|
|
const manifest=JSON.parse(readFileSync('public/clock.webmanifest','utf8'));
|
|
assert.equal(manifest.id,'/clock');assert.equal(manifest.start_url,'/clock');
|
|
assert.equal(manifest.scope,'/clock');assert.equal(manifest.display,'standalone');
|
|
assert.notEqual(manifest.name,JSON.parse(readFileSync('public/manifest.json','utf8')).name);
|
|
for(const size of ['192x192','512x512'])assert.ok(manifest.icons.some((i:{sizes:string})=>i.sizes===size));
|
|
});
|
|
test('clock sign-in, onboarding and return paths remain in app scope',()=>{
|
|
assert.equal(clockAuthDestination(null),'/clock/login');
|
|
assert.equal(clockAuthDestination({passwordChanged:false}),'/clock/change-password');
|
|
assert.equal(clockAuthDestination({passwordChanged:true}),'/clock');
|
|
});
|
|
test('scanner accepts existing Plant name/code badges and Infrastructure code-only badges',()=>{
|
|
assert.equal(employeeCodeFromBadge('FORTUNE NCUBE | MCW053'),'MCW053');
|
|
assert.equal(employeeCodeFromBadge(' mcw053 '),'mcw053');
|
|
assert.equal(employeeBadgePayload({name:'FORTUNE NCUBE',employeeNo:'MCW053'}),'FORTUNE NCUBE | MCW053');
|
|
assert.equal(employeeCodeFromBadge('name | code | extra'),null);
|
|
assert.equal(employeeCodeFromBadge(' | MCW053'),null);
|
|
assert.equal(employeeCodeFromBadge('name | '),null);
|
|
});
|