Files
cacti/tests/e2e/theme-css.ts
Thomas Vincent 62063a29e0 fix(theme): [develop] correct CSS cascade, invalid values and responsive selectors (#8293)
* fix(themes): correct CSS cascade, font fallbacks and responsive selectors

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(themes): remove validated empty and redundant CSS rules

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* style(css): remove reviewed inactive rules and redundant separators

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* style(themes): consolidate two reviewed duplicate selectors

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(themes): remove identical whitespace declaration after consolidation

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(theme): keep context menu fallbacks in Cacti overrides

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test(theme): measure native CSS and header coverage

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* ci: retain bootstrap coverage and validate request dispatch

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: synchronize native coverage fixture dispatch

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: measure coverage at the exact PR revision

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: cover Midwinter and graph heading CSS repairs in Chromium

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* ci: take the theme coverage base from the merge commit parent

- github.event.pull_request.base.sha can predate the develop tip the checkout was merged onto, which counted develop's own CSS lines as the PR's.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-10-14 22:51:15 -04:00

34 lines
1.3 KiB
TypeScript

/* Copyright (C) 2004-2026 The Cacti Group. GPL-2.0-or-later. */
import { test, type Page } from '@playwright/test';
import { existsSync, readFileSync } from 'node:fs';
import { resolve } from 'node:path';
const root = resolve(__dirname, '../..');
export async function installThemeCss(page: Page, file: string) {
const url = `http://cacti-theme.test/${file}`;
await page.route(url, route => route.fulfill({
contentType: 'text/css', body: readFileSync(resolve(root, file), 'utf8'),
}));
await page.addStyleTag({ url });
}
export function collectThemeCoverage() {
if (process.env.CACTI_THEME_COVERAGE === '1') {
const { collectCoverage } = require('./tests/fixture-coverage');
collectCoverage(test);
}
test.beforeEach(async ({ page }) => {
await page.route('http://cacti-theme.test/**', route => {
const file = new URL(route.request().url()).pathname.slice(1);
if (file === 'blank') {
return route.fulfill({ contentType: 'text/html', body: '<!DOCTYPE html><html><body></body></html>' });
}
const path = resolve(root, file);
if (!path.startsWith(root + '/') || !existsSync(path)) return route.abort();
return route.fulfill({ path, contentType: file.endsWith('.css') ? 'text/css' : undefined });
});
await page.goto('http://cacti-theme.test/blank');
});
}