diff --git a/tests/accuracy/export.test.ts b/tests/accuracy/export.test.ts index 46accd30f..5b2624171 100644 --- a/tests/accuracy/export.test.ts +++ b/tests/accuracy/export.test.ts @@ -10,6 +10,7 @@ describeAccuracyTests([ parameters: { database: "mflix", collection: "movies", + exportTitle: Matcher.string(), exportTarget: [ { name: "find", @@ -28,6 +29,7 @@ describeAccuracyTests([ parameters: { database: "mflix", collection: "movies", + exportTitle: Matcher.string(), exportTarget: [ { name: "find", @@ -50,6 +52,7 @@ describeAccuracyTests([ parameters: { database: "mflix", collection: "movies", + exportTitle: Matcher.string(), exportTarget: [ { name: "find", @@ -77,6 +80,7 @@ describeAccuracyTests([ parameters: { database: "mflix", collection: "movies", + exportTitle: Matcher.string(), exportTarget: [ { name: "find", diff --git a/tests/integration/common/connectionManager.oidc.test.ts b/tests/integration/common/connectionManager.oidc.test.ts index a14a5ab4b..e3a406eb6 100644 --- a/tests/integration/common/connectionManager.oidc.test.ts +++ b/tests/integration/common/connectionManager.oidc.test.ts @@ -168,17 +168,28 @@ describe.skipIf(process.platform !== "linux")("ConnectionManager OIDC Tests", as }; }; - const status: ConnectionStatus = await vi.waitFor(async () => { - const result: ConnectionStatus = (await state.serviceProvider.runCommand("admin", { - connectionStatus: 1, - })) as unknown as ConnectionStatus; - - if (!result) { - throw new Error("Status can not be undefined. Retrying."); - } - - return result; - }); + const status: ConnectionStatus = await vi.waitFor( + async () => { + const result = (await state.serviceProvider.runCommand("admin", { + connectionStatus: 1, + })) as unknown as ConnectionStatus | undefined; + + if (!result) { + throw new Error("Status can not be undefined. Retrying."); + } + + if (!result.authInfo.authenticatedUsers.length) { + throw new Error("No authenticated users found. Retrying."); + } + + if (!result.authInfo.authenticatedUserRoles.length) { + throw new Error("No authenticated user roles found. Retrying."); + } + + return result; + }, + { timeout: 5000 } + ); expect(status.authInfo.authenticatedUsers[0]).toEqual({ user: "dev/testuser", diff --git a/tests/integration/tools/atlas/accessLists.test.ts b/tests/integration/tools/atlas/accessLists.test.ts index 961898ae4..a711f38ff 100644 --- a/tests/integration/tools/atlas/accessLists.test.ts +++ b/tests/integration/tools/atlas/accessLists.test.ts @@ -27,16 +27,18 @@ describeWithAtlas("ip access lists", (integration) => { const apiClient = integration.mcpServer().session.apiClient; const projectId = getProjectId(); - - for (const value of values) { - await apiClient.deleteProjectIpAccessList({ - params: { - path: { - groupId: projectId, - entryValue: value, + if (projectId) { + // projectId may be empty if beforeAll failed. + for (const value of values) { + await apiClient.deleteProjectIpAccessList({ + params: { + path: { + groupId: projectId, + entryValue: value, + }, }, - }, - }); + }); + } } }); diff --git a/tests/integration/tools/atlas/atlasHelpers.ts b/tests/integration/tools/atlas/atlasHelpers.ts index df3a52f95..38a69291d 100644 --- a/tests/integration/tools/atlas/atlasHelpers.ts +++ b/tests/integration/tools/atlas/atlasHelpers.ts @@ -41,7 +41,7 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio try { const group = await createProject(apiClient); - projectId = group.id || ""; + projectId = group.id; } catch (error) { console.error("Failed to create project:", error); throw error; @@ -50,14 +50,16 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio afterAll(async () => { const apiClient = integration.mcpServer().session.apiClient; - - await apiClient.deleteProject({ - params: { - path: { - groupId: projectId, + if (projectId) { + // projectId may be empty if beforeAll failed. + await apiClient.deleteProject({ + params: { + path: { + groupId: projectId, + }, }, - }, - }); + }); + } }); const args = { @@ -90,7 +92,7 @@ export function parseTable(text: string): Record[] { export const randomId = new ObjectId().toString(); -async function createProject(apiClient: ApiClient): Promise { +async function createProject(apiClient: ApiClient): Promise>> { const projectName: string = `testProj-` + randomId; const orgs = await apiClient.listOrganizations(); @@ -109,5 +111,5 @@ async function createProject(apiClient: ApiClient): Promise { throw new Error("Failed to create project"); } - return group; + return group as Group & Required>; } diff --git a/tests/integration/tools/atlas/clusters.test.ts b/tests/integration/tools/atlas/clusters.test.ts index 0621ec7f2..9ae7aabcb 100644 --- a/tests/integration/tools/atlas/clusters.test.ts +++ b/tests/integration/tools/atlas/clusters.test.ts @@ -62,10 +62,10 @@ describeWithAtlas("clusters", (integration) => { afterAll(async () => { const projectId = getProjectId(); - - const session: Session = integration.mcpServer().session; - - await deleteAndWaitCluster(session, projectId, clusterName); + if (projectId) { + const session: Session = integration.mcpServer().session; + await deleteAndWaitCluster(session, projectId, clusterName); + } }); describe("atlas-create-free-cluster", () => { diff --git a/tests/integration/tools/atlas/dbUsers.test.ts b/tests/integration/tools/atlas/dbUsers.test.ts index bbf76200f..b6b055321 100644 --- a/tests/integration/tools/atlas/dbUsers.test.ts +++ b/tests/integration/tools/atlas/dbUsers.test.ts @@ -28,11 +28,17 @@ describeWithAtlas("db users", (integration) => { }; afterEach(async () => { + const projectId = getProjectId(); + if (!projectId) { + // projectId may be empty if beforeAll failed + return; + } + try { await integration.mcpServer().session.apiClient.deleteDatabaseUser({ params: { path: { - groupId: getProjectId(), + groupId: projectId, username: userName, databaseName: "admin", },