Yuki Takei 1 месяц назад
Родитель
Сommit
f0b379f7ce
1 измененных файлов с 6 добавлено и 9 удалено
  1. 6 9
      apps/app/src/server/service/yjs/yjs.integ.ts

+ 6 - 9
apps/app/src/server/service/yjs/yjs.integ.ts

@@ -1,5 +1,5 @@
 import { YDocStatus } from '@growi/core/dist/consts';
 import { YDocStatus } from '@growi/core/dist/consts';
-import mongoose, { Types } from 'mongoose';
+import { Types } from 'mongoose';
 import type { Server } from 'socket.io';
 import type { Server } from 'socket.io';
 import { mock } from 'vitest-mock-extended';
 import { mock } from 'vitest-mock-extended';
 
 
@@ -28,15 +28,11 @@ const getPrivateMdbInstance = (yjsService: IYjsService): MongodbPersistence => {
 
 
 describe('YjsService', () => {
 describe('YjsService', () => {
   describe('getYDocStatus()', () => {
   describe('getYDocStatus()', () => {
-    beforeAll(async () => {
+    beforeAll(() => {
       const ioMock = mock<Server>();
       const ioMock = mock<Server>();
 
 
       // initialize
       // initialize
       initializeYjsService(ioMock);
       initializeYjsService(ioMock);
-
-      // Wait for index creation to complete to avoid race condition
-      const collection = mongoose.connection.collection('yjs-writings');
-      await collection.listIndexes().toArray();
     });
     });
 
 
     afterAll(async () => {
     afterAll(async () => {
@@ -49,9 +45,10 @@ describe('YjsService', () => {
       try {
       try {
         await privateMdb.flushDB();
         await privateMdb.flushDB();
       } catch (error) {
       } catch (error) {
-        // Ignore IndexBuildAborted error (code: 276) which can occur in CI
-        // when cleanup happens while index creation is still in progress
-        if (error.code !== 276) {
+        // Ignore errors that can occur due to async index creation:
+        // - 26: NamespaceNotFound (collection not yet created)
+        // - 276: IndexBuildAborted (cleanup during index creation)
+        if (error.code !== 26 && error.code !== 276) {
           throw error;
           throw error;
         }
         }
       }
       }