perf(desktop): defer startup payloads
This commit is contained in:
1 parent
c29bd98d94
commit
b6be8a74df
4 files changed
+87
-21
No files matched your search
@@ -4,6 +4,9 @@ import test from "node:test";
|
||||
|
||||
const appSource = readFileSync("apps/desktop/src/App.vue", "utf8");
|
||||
const appDialogsSource = readFileSync("apps/desktop/src/components/layout/AppDialogs.vue", "utf8");
|
||||
const contentAreaSource = readFileSync("apps/desktop/src/components/layout/ContentArea.vue", "utf8");
|
||||
const i18nSource = readFileSync("apps/desktop/src/i18n/index.ts", "utf8");
|
||||
const mainSource = readFileSync("apps/desktop/src/main.ts", "utf8");
|
||||
|
||||
test("app defers cold-start side panels and modal pages behind async components", () => {
|
||||
assert.match(appSource, /defineAsyncComponent/);
|
||||
@@ -28,3 +31,21 @@ test("app dialogs only render async dialogs when their open state needs them", (
|
||||
assert.match(appDialogsSource, /<SchemaDiagramDialog\s+v-if="dialogs\.showDiagramDialog\.value"/);
|
||||
assert.match(appDialogsSource, /<DatabaseExportDialog\s+v-if="dialogs\.showDatabaseExportDialog\.value"/);
|
||||
});
|
||||
|
||||
test("content area defers database-specific browsers behind async components", () => {
|
||||
assert.match(contentAreaSource, /defineAsyncComponent/);
|
||||
for (const component of ["DataGrid", "RedisKeyBrowser", "MongoDocBrowser", "ObjectBrowser"]) {
|
||||
assert.doesNotMatch(contentAreaSource, new RegExp(`import ${component} from`));
|
||||
assert.match(contentAreaSource, new RegExp(`const ${component} = defineAsyncComponent`));
|
||||
}
|
||||
});
|
||||
|
||||
test("i18n defers non-default locale payloads out of the startup chunk", () => {
|
||||
assert.doesNotMatch(i18nSource, /import en from "\.\/locales\/en"/);
|
||||
assert.doesNotMatch(i18nSource, /import es from "\.\/locales\/es"/);
|
||||
assert.match(i18nSource, /const localeLoaders/);
|
||||
assert.match(i18nSource, /en:\s*\(\)\s*=>\s*import\("\.\/locales\/en"\)/);
|
||||
assert.match(i18nSource, /es:\s*\(\)\s*=>\s*import\("\.\/locales\/es"\)/);
|
||||
assert.match(mainSource, /loadSavedLocale\(\)/);
|
||||
assert.match(mainSource, /app\.mount\("#root"\)/);
|
||||
});
|
||||
Reference in new issue
Block a user