test: add workspace ref in e2e (#3217)

This commit is contained in:
Alex Yang
2023-07-13 20:41:46 +08:00
committed by GitHub
parent 64cf297399
commit d18df12951
18 changed files with 140 additions and 101 deletions

View File

@@ -4,6 +4,7 @@ import fs from 'node:fs';
import path, { resolve } from 'node:path';
import process from 'node:process';
import type { Workspace } from '@blocksuite/store';
import { test as baseTest } from '@playwright/test';
export const rootDir = resolve(__dirname, '..', '..');
@@ -26,7 +27,26 @@ function generateUUID() {
export const enableCoverage = !!process.env.CI || !!process.env.COVERAGE;
export const test = baseTest.extend({
type CurrentWorkspace = {
id: string;
flavour: string;
blockSuiteWorkspace: Workspace;
};
export const test = baseTest.extend<{
workspace: {
current: () => Promise<CurrentWorkspace>;
};
}>({
workspace: async ({ page }, use) => {
await use({
current: async () => {
return await page.evaluate(async () => {
return (globalThis as any).currentWorkspace;
});
},
});
},
context: async ({ context }, use) => {
if (enableCoverage) {
await context.addInitScript(() =>