chore: Improve perf of server tests (#5785)
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
buildTeam,
|
||||
buildUser,
|
||||
} from "@server/test/factories";
|
||||
import { setupTestDatabase, seed } from "@server/test/support";
|
||||
import { setupTestDatabase } from "@server/test/support";
|
||||
import slugify from "@server/utils/slugify";
|
||||
|
||||
setupTestDatabase();
|
||||
@@ -116,9 +116,7 @@ describe("#save", () => {
|
||||
describe("#getChildDocumentIds", () => {
|
||||
test("should return empty array if no children", async () => {
|
||||
const team = await buildTeam();
|
||||
const user = await buildUser({
|
||||
teamId: team.id,
|
||||
});
|
||||
const user = await buildUser({ teamId: team.id });
|
||||
const collection = await buildCollection({
|
||||
userId: user.id,
|
||||
teamId: team.id,
|
||||
@@ -135,9 +133,7 @@ describe("#getChildDocumentIds", () => {
|
||||
|
||||
test("should return nested child document ids", async () => {
|
||||
const team = await buildTeam();
|
||||
const user = await buildUser({
|
||||
teamId: team.id,
|
||||
});
|
||||
const user = await buildUser({ teamId: team.id });
|
||||
const collection = await buildCollection({
|
||||
userId: user.id,
|
||||
teamId: team.id,
|
||||
@@ -171,14 +167,14 @@ describe("#getChildDocumentIds", () => {
|
||||
|
||||
describe("#findByPk", () => {
|
||||
test("should return document when urlId is correct", async () => {
|
||||
const { document } = await seed();
|
||||
const document = await buildDocument();
|
||||
const id = `${slugify(document.title)}-${document.urlId}`;
|
||||
const response = await Document.findByPk(id);
|
||||
expect(response?.id).toBe(document.id);
|
||||
});
|
||||
|
||||
test("should return document when urlId is given without the slug prefix", async () => {
|
||||
const { document } = await seed();
|
||||
const document = await buildDocument();
|
||||
const id = document.urlId;
|
||||
const response = await Document.findByPk(id);
|
||||
expect(response?.id).toBe(document.id);
|
||||
|
||||
Reference in New Issue
Block a user