mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
fix(server): unstable test (#13436)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Improved test reliability by automatically cleaning up workspace snapshots during embedding status checks in end-to-end tests. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { cleanupWorkspace } from '@affine-test/kit/utils/cloud';
|
||||||
import { expect, type Page } from '@playwright/test';
|
import { expect, type Page } from '@playwright/test';
|
||||||
|
|
||||||
const WORKSPACE_EMBEDDING_SWITCH_TEST_ID = 'workspace-embedding-setting-switch';
|
const WORKSPACE_EMBEDDING_SWITCH_TEST_ID = 'workspace-embedding-setting-switch';
|
||||||
@@ -214,6 +215,7 @@ export class SettingsPanelUtils {
|
|||||||
status = 'synced'
|
status = 'synced'
|
||||||
) {
|
) {
|
||||||
await expect(async () => {
|
await expect(async () => {
|
||||||
|
await cleanupWorkspace(page.url().split('/').slice(-2)[0] || '');
|
||||||
await this.openSettingsPanel(page);
|
await this.openSettingsPanel(page);
|
||||||
const title = page.getByTestId('embedding-progress-title');
|
const title = page.getByTestId('embedding-progress-title');
|
||||||
// oxlint-disable-next-line prefer-dom-node-dataset
|
// oxlint-disable-next-line prefer-dom-node-dataset
|
||||||
|
|||||||
@@ -152,6 +152,15 @@ export async function createRandomUser(): Promise<{
|
|||||||
} as any;
|
} as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function cleanupWorkspace(workspaceId: string): Promise<void> {
|
||||||
|
await runPrisma(async client => {
|
||||||
|
const ret = await client.snapshot.deleteMany({
|
||||||
|
where: { workspaceId, id: { not: workspaceId } },
|
||||||
|
});
|
||||||
|
console.error(ret);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function switchDefaultChatModel(model: string) {
|
export async function switchDefaultChatModel(model: string) {
|
||||||
await runPrisma(async client => {
|
await runPrisma(async client => {
|
||||||
const promptId = await client.aiPrompt
|
const promptId = await client.aiPrompt
|
||||||
|
|||||||
Reference in New Issue
Block a user