dbx/packages/app-tests/appToolbarDropdownTooltip.t...

32 lines
1.7 KiB
TypeScript

import { readFileSync } from "node:fs";
import assert from "node:assert/strict";
import test from "node:test";
test("toolbar theme and language menus use shadcn tooltip without nesting trigger primitives", () => {
const source = readFileSync("apps/desktop/src/components/layout/AppToolbar.vue", "utf8");
assert.match(
source,
/<Tooltip>\s*<TooltipTrigger as-child>\s*<span class="inline-flex">\s*<DropdownMenu>\s*<DropdownMenuTrigger as-child>\s*<Button[\s\S]*?<\/Button>\s*<\/DropdownMenuTrigger>\s*<DropdownMenuContent align="end">[\s\S]*?<\/DropdownMenuContent>\s*<\/DropdownMenu>\s*<\/span>\s*<\/TooltipTrigger>\s*<TooltipContent>{{ t\("toolbar\.theme"\) }}<\/TooltipContent>\s*<\/Tooltip>/,
);
assert.match(
source,
/<Tooltip>\s*<TooltipTrigger as-child>\s*<span class="inline-flex">\s*<DropdownMenu>\s*<DropdownMenuTrigger as-child>\s*<Button[\s\S]*?<\/Button>\s*<\/DropdownMenuTrigger>\s*<DropdownMenuContent align="end">[\s\S]*?<\/DropdownMenuContent>\s*<\/DropdownMenu>\s*<\/span>\s*<\/TooltipTrigger>\s*<TooltipContent>{{ t\("common\.language"\) }}<\/TooltipContent>\s*<\/Tooltip>/,
);
assert.doesNotMatch(
source,
/<DropdownMenu>\s*<Tooltip>\s*<TooltipTrigger as-child>\s*<DropdownMenuTrigger as-child>/,
);
assert.doesNotMatch(source, /group\/toolbar-tip/);
assert.doesNotMatch(source, /group-hover\/toolbar-tip/);
});
test("toolbar uses SunMoon for the system theme option", () => {
const source = readFileSync("apps/desktop/src/components/layout/AppToolbar.vue", "utf8");
assert.match(source, /SunMoon/);
assert.match(source, /<SunMoon v-if="themeMode === 'system'"/);
assert.match(source, /<SunMoon class="h-4 w-4" \/>/);
assert.doesNotMatch(source, /Monitor/);
});