🩹 backend,oo: adding userId override for application updatingEditingSession (#525)
This commit is contained in:
@@ -409,17 +409,21 @@ export default class UserApi {
|
||||
});
|
||||
}
|
||||
|
||||
async endEditingDocument(
|
||||
editingSessionKey: string
|
||||
async updateEditingDocument(
|
||||
editingSessionKey: string,
|
||||
keepEditing: boolean = false,
|
||||
userId: string | null = null,
|
||||
): Promise<Response> {
|
||||
const fullPath = `${__dirname}/assets/${UserApi.ALL_FILES[0]}`;
|
||||
const readable= Readable.from(fs.createReadStream(fullPath));
|
||||
const form = formAutoContent({ file: readable });
|
||||
form.headers["authorization"] = `Bearer ${this.jwt}`;
|
||||
|
||||
let queryString = keepEditing ? "keepEditing=true" : "";
|
||||
if (userId)
|
||||
queryString += `${queryString.length ? "&" : ""}userId=${encodeURIComponent(userId)}`;
|
||||
return await this.platform.app.inject({
|
||||
method: "POST",
|
||||
url: `${UserApi.DOC_URL}/editing_session/${editingSessionKey}`,
|
||||
url: `${UserApi.DOC_URL}/editing_session/${encodeURIComponent(editingSessionKey)}${queryString ? "?" : ""}${queryString}`,
|
||||
headers: {
|
||||
authorization: `Bearer ${this.jwt}`
|
||||
},
|
||||
|
||||
@@ -4,7 +4,6 @@ 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, { ApplicationEditingKeyStatus } from "../../../src/services/applications-api";
|
||||
import { afterEach } from "node:test";
|
||||
import Application from "../../../src/services/applications/entities/application";
|
||||
@@ -135,7 +134,7 @@ describe("the Drive's documents' editing session kind-of-lock", () => {
|
||||
//given
|
||||
const editingSessionKey = await currentUser.beginEditingDocumentExpectOk(temporaryDocument.id, 'e2e_testing');
|
||||
//when
|
||||
const response = await currentUser.endEditingDocument(editingSessionKey);
|
||||
const response = await currentUser.updateEditingDocument(editingSessionKey);
|
||||
|
||||
//then
|
||||
expect(response.statusCode).toBe(200);
|
||||
|
||||
Reference in New Issue
Block a user