feat: add helper process (#2753)

This commit is contained in:
Peng Xiao
2023-06-13 10:01:43 +08:00
committed by GitHub
parent dff8a0db7d
commit 5ba2dff008
74 changed files with 1002 additions and 1048 deletions

View File

@@ -80,8 +80,21 @@ export const test = base.extend<{
// a random id to avoid conflicts between tests
const id = generateUUID();
const ext = process.platform === 'win32' ? '.cmd' : '';
const dist = resolve(__dirname, '..', 'dist');
const clonedDist = resolve(__dirname, '../e2e-dist-' + id);
await fs.copy(dist, clonedDist);
const packageJson = await fs.readJSON(
resolve(__dirname, '..', 'package.json')
);
// overwrite the app name
packageJson.name = 'affine-test-' + id;
// overwrite the path to the main script
packageJson.main = './main.js';
// write to the cloned dist
await fs.writeJSON(resolve(clonedDist, 'package.json'), packageJson);
const electronApp = await electron.launch({
args: [resolve(__dirname, '..'), '--app-name', 'affine-test-' + id],
args: [clonedDist],
executablePath: resolve(
__dirname,
'..',
@@ -95,11 +108,11 @@ export const test = base.extend<{
colorScheme: 'light',
});
await use(electronApp);
// FIXME: the following does not work well on CI
// const sessionDataPath = await electronApp.evaluate(async ({ app }) => {
// return app.getPath('sessionData');
// });
// await fs.rm(sessionDataPath, { recursive: true, force: true });
try {
await fs.rm(clonedDist, { recursive: true, force: true });
} catch (error) {
console.log(error);
}
},
appInfo: async ({ electronApp }, use) => {
const appInfo = await electronApp.evaluate(async ({ app }) => {