Skip to content

Commit 94cf32e

Browse files
authored
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 -->
1 parent ffbd21e commit 94cf32e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tests/affine-cloud-copilot/e2e/utils/settings-panel-utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cleanupWorkspace } from '@affine-test/kit/utils/cloud';
12
import { expect, type Page } from '@playwright/test';
23

34
const WORKSPACE_EMBEDDING_SWITCH_TEST_ID = 'workspace-embedding-setting-switch';
@@ -214,6 +215,7 @@ export class SettingsPanelUtils {
214215
status = 'synced'
215216
) {
216217
await expect(async () => {
218+
await cleanupWorkspace(page.url().split('/').slice(-2)[0] || '');
217219
await this.openSettingsPanel(page);
218220
const title = page.getByTestId('embedding-progress-title');
219221
// oxlint-disable-next-line prefer-dom-node-dataset

tests/kit/src/utils/cloud.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ export async function createRandomUser(): Promise<{
152152
} as any;
153153
}
154154

155+
export async function cleanupWorkspace(workspaceId: string): Promise<void> {
156+
await runPrisma(async client => {
157+
const ret = await client.snapshot.deleteMany({
158+
where: { workspaceId, id: { not: workspaceId } },
159+
});
160+
console.error(ret);
161+
});
162+
}
163+
155164
export async function switchDefaultChatModel(model: string) {
156165
await runPrisma(async client => {
157166
const promptId = await client.aiPrompt

0 commit comments

Comments
 (0)