Include complete API and frontend sources for unified deployment
This commit is contained in:
1 parent
627b0ae60e
commit
d8fcae32b0
93 files changed
+53270
-3
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { createExpertQrPdf, loginLink } from '../utils/expert-qr-pdf.js';
|
||||
|
||||
async function main() {
|
||||
const users = Array.from({ length: 25 }, (_, i) => ({
|
||||
firstName: 'Александр',
|
||||
lastName: 'Эксперт ' + i,
|
||||
middleName: 'Александрович',
|
||||
login: 'expert-' + i,
|
||||
passwordForAdmin: 'Test+&?#%Ю2026',
|
||||
}));
|
||||
const link = new URL(loginLink('https://grading.example.ru/app/', users[0]));
|
||||
assert.equal(link.origin, 'https://grading.example.ru');
|
||||
assert.equal(link.pathname, '/app/');
|
||||
const query = new URLSearchParams(link.hash.slice('/login?'.length + 1));
|
||||
assert.equal(query.get('l'), users[0].login);
|
||||
assert.equal(query.get('p'), users[0].passwordForAdmin);
|
||||
const pdf = (await createExpertQrPdf(users, 'https://grading.example.ru/app/')).toString('latin1');
|
||||
assert.equal(pdf.slice(0, 5), '%PDF-');
|
||||
assert.equal((pdf.match(/\/Type \/Page\b/g) || []).length, 3);
|
||||
assert.equal((pdf.match(/\/Subtype \/Link\b/g) || []).length, 25);
|
||||
for (const [technicalCount, regularCount, pages] of [
|
||||
[2, 5, 2],
|
||||
[12, 1, 2],
|
||||
[13, 2, 3],
|
||||
[12, 12, 2],
|
||||
[1, 0, 1],
|
||||
]) {
|
||||
const regular = users.slice(0, regularCount).map(user => ({ ...user, role: 'expert' }));
|
||||
const technical = users.slice(0, technicalCount).map((user, i) => ({
|
||||
...user,
|
||||
role: 'technical',
|
||||
login: 'technical-' + i,
|
||||
cases: [{ name: 'Тестовый кейс ' + i }],
|
||||
}));
|
||||
const grouped = (await createExpertQrPdf([...regular, ...technical], 'https://grading.example.ru/')).toString(
|
||||
'latin1'
|
||||
);
|
||||
assert.equal((grouped.match(/\/Type \/Page\b/g) || []).length, pages);
|
||||
const links = [...grouped.matchAll(/\/URI\s*\(([^)]*)\)/g)].map(match => match[1]);
|
||||
assert.deepEqual(
|
||||
links,
|
||||
[...technical, ...regular].map(user => loginLink('https://grading.example.ru/', user))
|
||||
);
|
||||
}
|
||||
console.log(
|
||||
'PASS QR cards and links; technical experts first; role groups start on separate pages; A4 pagination at group boundaries; reserved credentials round-trip.'
|
||||
);
|
||||
}
|
||||
main().catch(error => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in new issue
Block a user