refactor: plugin loading logic (#3448)

This commit is contained in:
Alex Yang
2023-07-28 19:43:52 -07:00
committed by GitHub
parent 4cb1bf6a9f
commit 9f43c0ddc8
14 changed files with 332 additions and 138 deletions

View File

@@ -0,0 +1,31 @@
import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test';
test('plugin should exist', async ({ page }) => {
await openHomePage(page);
await waitEditorLoad(page);
await page.route('**/plugins/**/package.json', route => route.fetch(), {
times: 3,
});
await page.waitForTimeout(50);
const packageJson = await page.evaluate(() => {
// @ts-expect-error
return window.__pluginPackageJson__;
});
expect(packageJson).toEqual([
{
name: '@affine/bookmark-plugin',
affinePlugin: expect.anything(),
},
{
name: '@affine/copilot-plugin',
affinePlugin: expect.anything(),
},
{
name: '@affine/hello-world-plugin',
affinePlugin: expect.anything(),
},
]);
});