♻️ backend: fix e2e editing session test, make ApplicationApiService a singleton (#525)

This commit is contained in:
Eric Doughty-Papassideris
2024-09-18 21:25:30 +02:00
parent be10393435
commit 9db0fddc98
4 changed files with 41 additions and 9 deletions
@@ -516,7 +516,7 @@ export default class UserApi {
async getDocumentByEditingKey(editing_session_key: string) {
return await this.platform.app.inject({
method: "GET",
url: `${UserApi.DOC_URL}/companies/${this.platform.workspace.company_id}/item/editing_session/${encodeURIComponent(editing_session_key)}`,
url: `${UserApi.DOC_URL}/editing_session/${encodeURIComponent(editing_session_key)}`,
headers: {
authorization: `Bearer ${this.jwt}`
}
@@ -1,10 +1,13 @@
import { describe, beforeAll, beforeEach, it, expect, afterAll } from "@jest/globals";
import { describe, beforeAll, beforeEach, it, expect, afterAll, jest } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import UserApi from "../common/user-api";
import { DriveFile, TYPE as DriveFileType } from "../../../src/services/documents/entities/drive-file";
import exp = require("node:constants");
import ApplicationsApiService from "../../../src/services/applications-api";
import { afterEach } from "node:test";
import Application from "../../../src/services/applications/entities/application";
describe("the Drive's documents' editing session kind-of-lock", () => {
let platform: TestPlatform | null;
@@ -49,6 +52,11 @@ describe("the Drive's documents' editing session kind-of-lock", () => {
parent_id: currentUserRoot,
scope: "personal",
});
jest.spyOn(ApplicationsApiService.getDefault(), 'getApplicationConfig').mockImplementation((id) => id === "e2e_testing" ? {} as Application : undefined);
});
afterEach(() => {
jest.restoreAllMocks();
});
it("atomicCompareAndSet allows a single value at a time", async () => {