c56da8dc26
恢复 /creation 新版创作工具主页及创作、项目公共侧栏。 将 creation-home 重新纳入 Vite、TypeScript、ESLint 与 Vitest 活动编译链。 恢复 /creation 的 Nginx 与 Pingora SPA 白名单并保留旧子路径下线边界。 补充路由、标题、CSS 过滤和网关 smoke 回归验证。
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import type { Plugin } from 'vite';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import viteConfig from '../vite.config';
|
|
|
|
async function resolveRetiredCssPlugin() {
|
|
const resolvedConfig =
|
|
typeof viteConfig === 'function'
|
|
? await viteConfig({ command: 'serve', mode: 'test' })
|
|
: viteConfig;
|
|
const plugins = (resolvedConfig.plugins ?? []).flat(Infinity) as Plugin[];
|
|
return plugins.find(
|
|
(plugin) => plugin?.name === 'retired-creation-template-css',
|
|
);
|
|
}
|
|
|
|
describe('retired creation template CSS plugin', () => {
|
|
it('runs before Tailwind turns source CSS into a Vite JavaScript module', async () => {
|
|
const plugin = await resolveRetiredCssPlugin();
|
|
|
|
expect(plugin).toBeDefined();
|
|
expect(plugin?.enforce).toBe('pre');
|
|
});
|
|
|
|
it('keeps the active creation landing CSS while removing retired template CSS', async () => {
|
|
const plugin = await resolveRetiredCssPlugin();
|
|
const transform = plugin?.transform;
|
|
|
|
expect(typeof transform).toBe('function');
|
|
if (typeof transform !== 'function') {
|
|
return;
|
|
}
|
|
|
|
const result = await transform.call(
|
|
{} as never,
|
|
"@import 'tailwindcss';\n.creation-landing { color: red; }\n.puzzle-runtime { color: blue; }",
|
|
'/workspace/src/index.css',
|
|
);
|
|
const code = typeof result === 'string' ? result : result?.code;
|
|
|
|
expect(code).toContain('.creation-landing');
|
|
expect(code).not.toContain('.puzzle-runtime');
|
|
expect(code).toContain('@source "./components/creation-home"');
|
|
});
|
|
});
|