mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
feat: add helper process (#2753)
This commit is contained in:
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user