This commit is contained in:
+32
-16
@@ -14,7 +14,6 @@ test('start screen exposes cookie status, optional local progress and deliberate
|
||||
const html = await read('public/index.html');
|
||||
const loader = await read('public/js/bootstrap-loader.js');
|
||||
const storage = await read('public/js/privacy-storage.js');
|
||||
|
||||
assert.match(html, /Diese Anwendung setzt derzeit keine Cookies/);
|
||||
assert.match(html, /class="cookie-toggle"[^>]*disabled/);
|
||||
assert.match(html, /class="progress-storage-toggle"/);
|
||||
@@ -28,12 +27,15 @@ test('start screen exposes cookie status, optional local progress and deliberate
|
||||
assert.match(storage, /cookiesEnabled: \(\) => false/);
|
||||
});
|
||||
|
||||
test('information button opens scrollable overlay pages for privacy, imprint and technology', async () => {
|
||||
test('information button toggles dropdown and opens scrollable overlay pages', async () => {
|
||||
const html = await read('public/index.html');
|
||||
const css = await read('public/css/app.css');
|
||||
const ui = await read('public/js/legal-ui.js');
|
||||
|
||||
assert.match(html, /id="info-button"/);
|
||||
assert.match(html, /aria-haspopup="true"/);
|
||||
assert.match(html, /aria-expanded="false"/);
|
||||
assert.match(html, /id="info-dropdown"/);
|
||||
assert.match(html, /<dialog id="info-dialog"/);
|
||||
assert.match(html, /data-info-target="privacy"/);
|
||||
assert.match(html, /data-info-target="imprint"/);
|
||||
@@ -43,14 +45,15 @@ test('information button opens scrollable overlay pages for privacy, imprint and
|
||||
assert.match(html, /jQuery 4\.0\.0/);
|
||||
assert.match(css, /\.info-dialog-content[\s\S]*overflow-y:\s*auto/);
|
||||
assert.match(css, /\.info-dialog-content[\s\S]*touch-action:\s*pan-y/);
|
||||
assert.match(css, /\.info-dropdown[\s\S]*transition:\s*opacity 180ms ease, transform 180ms ease/);
|
||||
assert.match(css, /\.info-dropdown\.is-open[\s\S]*pointer-events:\s*auto/);
|
||||
assert.match(ui, /pointerup/);
|
||||
assert.match(ui, /keydown/);
|
||||
assert.doesNotMatch(ui, /addEventListener\(['"]click['"]/);
|
||||
assert.doesNotMatch(ui, /addEventListener\(['"]click['"]\)/);
|
||||
});
|
||||
|
||||
test('application persists current route, viewed stations and played audio only through privacy storage', async () => {
|
||||
const app = await read('public/js/app.js');
|
||||
|
||||
assert.match(app, /PrivacyStorage\.saveRouteState/);
|
||||
assert.match(app, /PrivacyStorage\.activateRoute/);
|
||||
assert.match(app, /state\.viewed\.add\(state\.activePoiId\)/);
|
||||
@@ -60,7 +63,6 @@ test('application persists current route, viewed stations and played audio only
|
||||
assert.match(app, /await initializeLocation\(context\)/);
|
||||
});
|
||||
|
||||
|
||||
class FakeElement extends EventTarget {
|
||||
constructor(id = '') {
|
||||
super();
|
||||
@@ -74,12 +76,28 @@ class FakeElement extends EventTarget {
|
||||
this.dataset = {};
|
||||
this.attributes = new Map();
|
||||
this.focused = false;
|
||||
this.classNames = new Set();
|
||||
this.classList = {
|
||||
toggle: (name, enabled) => {
|
||||
if (enabled) this.classNames.add(name);
|
||||
else this.classNames.delete(name);
|
||||
},
|
||||
contains: name => this.classNames.has(name)
|
||||
};
|
||||
}
|
||||
|
||||
focus() {
|
||||
this.focused = true;
|
||||
}
|
||||
|
||||
contains(target) {
|
||||
return target === this;
|
||||
}
|
||||
|
||||
getAttribute(name) {
|
||||
return this.attributes.get(name) ?? null;
|
||||
}
|
||||
|
||||
setAttribute(name, value) {
|
||||
this.attributes.set(name, String(value));
|
||||
if (name === 'open') this.open = true;
|
||||
@@ -115,10 +133,9 @@ test('legal overlay handlers synchronize switches without advancing the start sc
|
||||
const elements = new Map([
|
||||
['info-dialog', new FakeElement('info-dialog')],
|
||||
['info-dialog-title', new FakeElement('info-dialog-title')],
|
||||
['info-menu', new FakeElement('info-menu')],
|
||||
['info-back', new FakeElement('info-back')],
|
||||
['info-close', new FakeElement('info-close')],
|
||||
['info-button', new FakeElement('info-button')]
|
||||
['info-button', new FakeElement('info-button')],
|
||||
['info-dropdown', new FakeElement('info-dropdown')]
|
||||
]);
|
||||
const content = new FakeElement();
|
||||
const privacyPage = new FakeElement();
|
||||
@@ -134,14 +151,12 @@ test('legal overlay handlers synchronize switches without advancing the start sc
|
||||
const cookieToggles = [new FakeElement()];
|
||||
let enabled = false;
|
||||
const changes = [];
|
||||
|
||||
class TestCustomEvent extends Event {
|
||||
constructor(type, options = {}) {
|
||||
super(type);
|
||||
this.detail = options.detail;
|
||||
}
|
||||
}
|
||||
|
||||
const document = new EventTarget();
|
||||
document.getElementById = id => elements.get(id);
|
||||
document.querySelectorAll = selector => {
|
||||
@@ -157,7 +172,6 @@ test('legal overlay handlers synchronize switches without advancing the start sc
|
||||
return match ? pages[match[1]] : null;
|
||||
};
|
||||
document.addEventListener('wegwichtel:progress-storage-changed', event => changes.push(event.detail.enabled));
|
||||
|
||||
const context = {
|
||||
Wegwichtel: {
|
||||
PrivacyStorage: {
|
||||
@@ -177,12 +191,16 @@ test('legal overlay handlers synchronize switches without advancing the start sc
|
||||
vm.runInNewContext(source, context, { filename: sourcePath });
|
||||
|
||||
elements.get('info-button').dispatchEvent(pointerEvent());
|
||||
assert.equal(elements.get('info-dialog').open, true);
|
||||
assert.equal(elements.get('info-menu').hidden, false);
|
||||
assert.equal(elements.get('info-dialog').open, false);
|
||||
assert.equal(elements.get('info-dropdown').hidden, false);
|
||||
assert.equal(elements.get('info-dropdown').classList.contains('is-open'), true);
|
||||
assert.equal(elements.get('info-button').getAttribute('aria-expanded'), 'true');
|
||||
|
||||
targetButtons[0].dispatchEvent(pointerEvent());
|
||||
assert.equal(elements.get('info-dialog').open, true);
|
||||
assert.equal(elements.get('info-dropdown').hidden, true);
|
||||
assert.equal(elements.get('info-button').getAttribute('aria-expanded'), 'false');
|
||||
assert.equal(privacyPage.hidden, false);
|
||||
assert.equal(elements.get('info-back').hidden, false);
|
||||
assert.equal(elements.get('info-dialog-title').textContent, 'Datenschutzerklärung');
|
||||
|
||||
progressToggles[0].checked = true;
|
||||
@@ -191,8 +209,6 @@ test('legal overlay handlers synchronize switches without advancing the start sc
|
||||
assert.equal(progressToggles[1].checked, true);
|
||||
assert.equal(cookieToggles[0].checked, false);
|
||||
|
||||
elements.get('info-back').dispatchEvent(pointerEvent());
|
||||
assert.equal(elements.get('info-menu').hidden, false);
|
||||
elements.get('info-close').dispatchEvent(pointerEvent());
|
||||
assert.equal(elements.get('info-dialog').open, false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user