Files
WebApp/scripts/ux06b-resources.test.mjs
T
2026-10-13 11:38:17 -06:00

60 lines
2.5 KiB
JavaScript

import { readFileSync } from 'node:fs';
import { test } from 'node:test';
import assert from 'node:assert/strict';
const root = new URL('../', import.meta.url);
const read = path => readFileSync(new URL(path, root), 'utf8');
test('UX-06B: idioma, título, base y favicon', () => {
const index = read('src/index.html');
for (const value of [
'lang="es"',
'<title>Plataforma de Indicadores | ISSSTELEON</title>',
'<base href="/"',
'href="favicon.ico"',
]) assert.ok(index.includes(value), value);
});
test('UX-06B: fuentes aprobadas, pesos, HTTPS, swap y fallback', () => {
const index = read('src/index.html');
assert.equal(index.match(/family=Rajdhani/g)?.length, 1);
assert.equal(index.match(/family=Roboto/g)?.length, 1);
for (const value of [
'https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700',
'family=Roboto:wght@300;400;500',
'display=swap',
'https://fonts.googleapis.com/icon?family=Material+Icons',
]) assert.ok(index.includes(value), value);
const styles = read('src/styles.scss');
assert.ok(styles.includes("--issste-font-heading: 'Rajdhani', 'Roboto', sans-serif;"));
assert.ok(styles.includes("--issste-font-body: 'Roboto', sans-serif;"));
});
test('UX-06B: PNG original y mecanismo de publicación del asset', () => {
const png = readFileSync(new URL('public/images/LogoISSSTELEON.png', root));
assert.deepEqual(Array.from(png.subarray(0, 8)), [137, 80, 78, 71, 13, 10, 26, 10]);
assert.equal(png.readUInt32BE(16), 1125);
assert.equal(png.readUInt32BE(20), 358);
const config = JSON.parse(read('angular.json'));
assert.ok(config.projects.WebApp.architect.build.options.assets.some(
asset => asset.glob === '**/*' && asset.input === 'public',
));
assert.ok(read('src/app/app.html').includes('src="images/LogoISSSTELEON.png"'));
});
test('UX-06B: tokens globales, tema único y uso en shell/navegación', () => {
const styles = read('src/styles.scss');
for (const value of [
'--issste-text: #081839;',
'--issste-background: #F7F7F7;',
'@include mat.theme-overrides(',
'primary: var(--issste-text)',
'outline: var(--issste-text-secondary)',
]) assert.ok(styles.includes(value), value);
assert.equal(styles.match(/@include mat.theme\(/g)?.length, 1);
assert.ok(read('src/app/app.scss').includes('background: var(--issste-surface)'));
assert.ok(read('src/app/app.scss').includes('font-family: var(--issste-font-heading)'));
assert.ok(read('src/app/features/indicadores/indicadores-page.scss')
.includes('background: var(--issste-accent)'));
});