Skip to content

Commit

Permalink
♻️Moved default services list to util function
Browse files Browse the repository at this point in the history
  • Loading branch information
shepilov committed Dec 3, 2024
1 parent f359df0 commit 49ec7b5
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 391 deletions.
19 changes: 2 additions & 17 deletions tdrive/backend/node/test/e2e/av/av.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "./load_test_config";
import "reflect-metadata";
import { afterAll, beforeEach, describe, expect, it, jest } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import { init, initWithDefaults, TestPlatform } from "../setup";
import { deserialize } from "class-transformer";
import UserApi from "../common/user-api";
import { DriveItemDetailsMockClass } from "../common/entities/mock_entities";
Expand All @@ -19,22 +19,7 @@ describe("The documents antivirus", () => {
);

beforeEach(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"files",
"auth",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
});

afterAll(async () => {
Expand Down
21 changes: 2 additions & 19 deletions tdrive/backend/node/test/e2e/console/backchannel-logout.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, beforeEach, describe, expect, it } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import { init, initWithDefaults, TestPlatform } from "../setup";
import { TestDbService } from "../utils.prepare.db";
import UserApi from "../common/user-api";

Expand All @@ -15,24 +15,7 @@ describe("The /backchannel_logout API", () => {
});

beforeAll(async () => {
platform = await init({
services: [
"database",
"search",
"message-queue",
"websocket",
"applications",
"webserver",
"user",
"auth",
"storage",
"counter",
"console",
"workspaces",
"statistics",
"platform-services",
],
});
platform = await initWithDefaults();
testDbService = await TestDbService.getInstance(platform);
});

Expand Down
22 changes: 3 additions & 19 deletions tdrive/backend/node/test/e2e/documents/documents-browser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, beforeEach, afterEach, it, expect, afterAll } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import { TestDbService } from "../utils.prepare.db";
import {initWithDefaults, TestPlatform } from "../setup";
import UserApi from "../common/user-api";

describe("The Documents Browser Window and API", () => {
Expand All @@ -11,22 +10,7 @@ describe("The Documents Browser Window and API", () => {
let files: any;

beforeEach(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"files",
"auth",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
currentUser = await UserApi.getInstance(platform);
sharedWIthMeFolder = "shared_with_me";
myDriveId = "user_" + currentUser.user.id;
Expand All @@ -37,7 +21,7 @@ describe("The Documents Browser Window and API", () => {
expect(Array.from(files.entries())).toHaveLength(UserApi.ALL_FILES.length);
});

afterAll(async () => {
afterEach(async () => {
await platform?.tearDown();
// @ts-ignore
platform = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import { initWithDefaults, TestPlatform } from "../setup";
import UserApi from "../common/user-api";
import config from "config";

Expand Down Expand Up @@ -28,26 +28,7 @@ describe("The Drive feature", () => {
});

// Initialize platform with required services
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"search",
"files",
"messages",
"auth",
"channels",
"counter",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
});

afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, beforeEach, it, expect, afterAll, jest } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import { initWithDefaults, TestPlatform } from "../setup";
import UserApi from "../common/user-api";
import * as utils from "../../../src/services/documents/utils";
import { DocumentsEngine } from "../../../src/services/documents/services/engine";
Expand All @@ -22,27 +22,7 @@ describe("the Drive feature", () => {
let currentUser: UserApi;

beforeEach(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"search",
"files",
"messages",
"auth",
"channels",
"counter",
"statistics",
"platform-services",
"documents",
"email-pusher",
],
});
platform = await initWithDefaults();
currentUser = await UserApi.getInstance(platform);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, beforeAll, afterAll, it, expect } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import { init, initWithDefaults, TestPlatform } from "../setup";
import UserApi from "../common/user-api";

describe("The Documents Browser Window and API", () => {
Expand All @@ -11,22 +11,7 @@ describe("The Documents Browser Window and API", () => {
let files: any;

beforeAll(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"files",
"auth",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
currentUser = await UserApi.getInstance(platform, true, { companyRole: "admin" });
anotherUser = await UserApi.getInstance(platform, true, { companyRole: "admin" });
myDriveId = "user_" + currentUser.user.id;
Expand Down
23 changes: 2 additions & 21 deletions tdrive/backend/node/test/e2e/documents/documents-quota.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import { initWithDefaults, TestPlatform } from "../setup";
import UserApi from "../common/user-api";
import config from "config";
import { e2e_createDocumentFile, e2e_createVersion } from "./utils";
Expand Down Expand Up @@ -33,26 +33,7 @@ describe("the Drive feature", () => {
}
return jest.requireActual("config").get(setting);
});
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"search",
"files",
"messages",
"auth",
"channels",
"counter",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
currentUser = await UserApi.getInstance(platform);
});

Expand Down
22 changes: 2 additions & 20 deletions tdrive/backend/node/test/e2e/documents/documents-search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, afterAll } from "@jest/globals";
import { init, TestPlatform } from "../setup";
import { initWithDefaults, TestPlatform } from "../setup";
import UserApi from "../common/user-api";
import { DriveFileMockClass } from "../common/entities/mock_entities";
import { DriveFile } from "../../../src/services/documents/entities/drive-file";
Expand All @@ -14,25 +14,7 @@ describe("the Drive Search feature", () => {
const uploadedByUserTwo = [];

beforeAll(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"search",
"files",
"messages",
"auth",
"channels",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
});

afterAll(async () => {
Expand Down
23 changes: 2 additions & 21 deletions tdrive/backend/node/test/e2e/documents/documents-tab.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterAll, beforeEach, describe, expect, it } from "@jest/globals";
import { deserialize } from "class-transformer";
import { AccessInformation } from "../../../src/services/documents/entities/drive-file";
import { init, TestPlatform } from "../setup";
import { initWithDefaults, TestPlatform } from "../setup";
import { TestDbService } from "../utils.prepare.db";
import UserApi from "../common/user-api";

Expand All @@ -28,26 +28,7 @@ describe("the Drive Tdrive tabs feature", () => {
}

beforeEach(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"search",
"files",
"messages",
"auth",
"channels",
"counter",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
currentUser = await UserApi.getInstance(platform);
});

Expand Down
23 changes: 2 additions & 21 deletions tdrive/backend/node/test/e2e/documents/documents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, beforeEach, it, expect, afterAll } from "@jest/globals";
import { deserialize } from "class-transformer";
import { File } from "../../../src/services/files/entities/file";
import { ResourceUpdateResponse } from "../../../src/utils/types";
import { init, TestPlatform } from "../setup";
import { initWithDefaults, TestPlatform } from "../setup";
import { TestDbService } from "../utils.prepare.db";
import {
e2e_createDocumentFile,
Expand All @@ -21,26 +21,7 @@ describe("the Drive feature", () => {
let currentUser: UserApi;

beforeEach(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"search",
"files",
"messages",
"auth",
"channels",
"counter",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
currentUser = await UserApi.getInstance(platform);
});

Expand Down
25 changes: 2 additions & 23 deletions tdrive/backend/node/test/e2e/documents/editing-session.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeAll, beforeEach, it, expect, afterAll, jest } from "@jest/globals";

import { init, TestPlatform } from "../setup";
import { initWithDefaults, TestPlatform } from "../setup";
import UserApi from "../common/user-api";

import { DriveFile, TYPE as DriveFileType } from "../../../src/services/documents/entities/drive-file";
Expand All @@ -15,28 +15,7 @@ describe("the Drive's documents' editing session kind-of-lock", () => {
let temporaryDocument: DriveFile;

beforeAll(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"message-queue",
"user",
"search",
"files",
"websocket",
"messages",
"auth",
"realtime",
"channels",
"counter",
"statistics",
"platform-services",
"documents",
],
});
platform = await initWithDefaults();
currentUser = await UserApi.getInstance(platform);
currentUserRoot = `user_${currentUser.user.id}`;
});
Expand Down
Loading

0 comments on commit 49ec7b5

Please sign in to comment.