Files

65 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

2026-10-29 11:57:29 +01:00
// Generated, do not edit. sha256:24b0358e2ad3c4daacdef6e28f3515514103cb02f09c0d3fa792252b376261f0
import { describe, it, beforeEach, mock } from 'node:test';
import assert from 'node:assert/strict';
const prefs = new Map();
mock.module('../../client/data/preferences.js', {
namedExports: {
getPref: async (scope, key, fallback) => (prefs.has(`${scope}.${key}`) ? prefs.get(`${scope}.${key}`) : fallback),
setPref: async (scope, key, value) => { prefs.set(`${scope}.${key}`, value); },
},
});
globalThis.location = { hash: '#/home' };
const { registerAttention, refreshAttention, attentionForRoute } = await import('../../client/ui/attention.js');
let items = [];
registerAttention(() => items);
const limiet = severity => ({ id: 'usage:goldapi', severity, route: 'system', tab: 'integrations/providers', label: 'GoldAPI' });
const fade = () => attentionForRoute('system').map(a => a.fade);
const ga = async hash => { location.hash = hash; await refreshAttention(); };
beforeEach(async () => {
items = [];
await ga('#/home');
});
describe('een gezien bolletje dimt', () => {
it('is vol zolang je er niet geweest bent, en dimt zodra je op de plek staat', async () => {
items = [limiet('problem')];
await ga('#/home');
assert.deepEqual(fade(), ['full'], 'buiten de pagina ontstaan: vol');
await ga('#/system/integrations/providers');
assert.deepEqual(fade(), ['dim'], 'gezien');
await ga('#/home');
assert.deepEqual(fade(), ['dim'], 'en dat blijft zo als je weggaat');
});
it('een andere ernst is een nieuwe toestand en begint weer vol', async () => {
items = [limiet('attention')];
await ga('#/home');
await ga('#/system/integrations/providers');
assert.deepEqual(fade(), ['dim']);
items = [limiet('problem')];
await ga('#/home');
assert.deepEqual(fade(), ['full']);
});
it('een oorzaak die verdwijnt en terugkomt, begint opnieuw', async () => {
items = [limiet('problem')];
await ga('#/home');
await ga('#/system/integrations/providers');
items = [];
await ga('#/home');
items = [limiet('problem')];
await ga('#/home');
assert.deepEqual(fade(), ['full']);
});
it('een ander tabblad van dezelfde pagina telt niet als gezien', async () => {
items = [limiet('problem')];
await ga('#/home');
await ga('#/system/integrations/sources');
assert.deepEqual(fade(), ['full']);
});
});