mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
ec76057c5e
* Testing playwright for Desktop automation
* add more data-testid field
* remove commited test-results
* test: skip group upkeep for now
* test: mention test create group instead of restoring from seed
* test: run on testnet
* fix: revert messagebanner unread count changes
from commit 8107d75e89
Co-authored-by: Emily <emily@oxen.io>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { _electron, Page } from '@playwright/test';
|
|
import { readdirSync, rmdirSync } from 'fs-extra';
|
|
import { dirname, join } from 'path';
|
|
import { MULTI_PREFIX, NODE_ENV, openElectronAppOnly } from './open';
|
|
|
|
const getDirectoriesOfSessionDataPath = (source: string) =>
|
|
readdirSync(source, { withFileTypes: true })
|
|
.filter(dirent => dirent.isDirectory())
|
|
.map(dirent => dirent.name)
|
|
.filter(n => n.startsWith(`Session-${NODE_ENV}-${MULTI_PREFIX}`));
|
|
|
|
export const cleanUpOtherTest = async () => {
|
|
const electronApp = await openElectronAppOnly('start');
|
|
const appPath = await electronApp.evaluate(async ({ app }) => {
|
|
return app.getPath('userData');
|
|
});
|
|
const window = await electronApp.firstWindow();
|
|
await window.close();
|
|
if (!appPath.length) {
|
|
throw new Error('appDataPath unset');
|
|
}
|
|
const parentFolderOfAllDataPath = dirname(appPath);
|
|
|
|
if (!parentFolderOfAllDataPath || parentFolderOfAllDataPath.length < 20) {
|
|
throw new Error('parentFolderOfAllDataPath not found or invalid');
|
|
}
|
|
|
|
const allAppDataPath = getDirectoriesOfSessionDataPath(parentFolderOfAllDataPath);
|
|
allAppDataPath.map(folder => {
|
|
if (!appPath) {
|
|
throw new Error('parentFolderOfAllDataPath unset');
|
|
}
|
|
const pathToRemove = join(parentFolderOfAllDataPath, folder);
|
|
rmdirSync(pathToRemove, { recursive: true });
|
|
});
|
|
};
|
|
|
|
export const forceCloseAllWindows = async (windows: Array<Page>) => {
|
|
return Promise.all(windows.map(w => w.close()));
|
|
};
|