48 lines
2.1 KiB
JavaScript
48 lines
2.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import test from "node:test";
|
|
|
|
const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const readSource = (relativePath) =>
|
|
readFileSync(resolve(appRoot, relativePath), "utf8");
|
|
|
|
const homeSource = readSource("src/pages/index.vue");
|
|
const workSource = readSource("src/pages/work/index.vue");
|
|
const bannerSource = readSource("src/components/business/TestBatchBanner.vue");
|
|
const modeSwitchSource = readSource(
|
|
"src/components/business/TestBatchModeSwitch.vue",
|
|
);
|
|
|
|
test("首页使用受约束的运营布局并保护横向空间", () => {
|
|
assert.match(homeSource, /class="dashboard-page"/);
|
|
assert.match(homeSource, /class="dashboard-scroll"/);
|
|
assert.match(homeSource, /class="dashboard-content"/);
|
|
assert.match(homeSource, /class="dashboard-hero"/);
|
|
assert.match(homeSource, /class="dashboard-metric-grid"/);
|
|
assert.match(homeSource, /class="exception-list"/);
|
|
assert.match(homeSource, /class="exception-item"/);
|
|
assert.match(homeSource, /overflow-x:\s*hidden/);
|
|
assert.match(homeSource, /overflow-wrap:\s*anywhere/);
|
|
});
|
|
|
|
test("工作台入口在窄屏下保持单列和可换行", () => {
|
|
assert.match(workSource, /class="work-page"/);
|
|
assert.match(workSource, /class="work-scroll"/);
|
|
assert.match(workSource, /class="work-content"/);
|
|
assert.match(workSource, /class="work-entry-list"/);
|
|
assert.match(workSource, /class="work-entry"/);
|
|
assert.match(workSource, /class="work-entry-copy"/);
|
|
assert.match(workSource, /overflow-x:\s*hidden/);
|
|
assert.match(workSource, /overflow-wrap:\s*anywhere/);
|
|
});
|
|
|
|
test("测试批次提示和切换区不会撑开页面", () => {
|
|
assert.match(bannerSource, /class="test-batch-banner"/);
|
|
assert.match(bannerSource, /overflow-wrap:\s*anywhere/);
|
|
assert.match(modeSwitchSource, /class="test-batch-switch"/);
|
|
assert.match(modeSwitchSource, /class="test-batch-picker"/);
|
|
assert.match(modeSwitchSource, /overflow-wrap:\s*anywhere/);
|
|
});
|