chore: Test performance (#5786)
This commit is contained in:
@@ -39,9 +39,10 @@ describe("#auth.info", () => {
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
|
||||
const availableTeamIds = body.data.availableTeams.map((t: any) => t.id);
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(availableTeamIds.length).toEqual(3);
|
||||
expect(availableTeamIds).toContain(team.id);
|
||||
expect(availableTeamIds).toContain(team2.id);
|
||||
|
||||
@@ -1726,10 +1726,6 @@ describe("#documents.search", () => {
|
||||
},
|
||||
});
|
||||
|
||||
// setTimeout is needed here because SearchQuery is saved asynchronously
|
||||
// in order to not slow down the response time.
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
|
||||
const searchQuery = await SearchQuery.findAll({
|
||||
where: {
|
||||
teamId: user.teamId,
|
||||
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
ValidationError,
|
||||
IncorrectEditionError,
|
||||
} from "@server/errors";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import auth from "@server/middlewares/authentication";
|
||||
import { rateLimiter } from "@server/middlewares/rateLimiter";
|
||||
import { transaction } from "@server/middlewares/transaction";
|
||||
@@ -818,15 +817,13 @@ router.post(
|
||||
// When requesting subsequent pages of search results we don't want to record
|
||||
// duplicate search query records
|
||||
if (offset === 0) {
|
||||
void SearchQuery.create({
|
||||
await SearchQuery.create({
|
||||
userId: user?.id,
|
||||
teamId,
|
||||
shareId,
|
||||
source: ctx.state.auth.type || "app", // we'll consider anything that isn't "api" to be "app"
|
||||
query,
|
||||
results: totalCount,
|
||||
}).catch((err) => {
|
||||
Logger.error("Failed to create search query", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -76,32 +76,24 @@ describe("#team.update", () => {
|
||||
it("should add new allowed Domains, removing empty string values", async () => {
|
||||
const team = await buildTeam();
|
||||
const admin = await buildAdmin({ teamId: team.id });
|
||||
const domain1 = faker.internet.domainName();
|
||||
const domain2 = faker.internet.domainName();
|
||||
const res = await server.post("/api/team.update", {
|
||||
body: {
|
||||
token: admin.getJwtToken(),
|
||||
allowedDomains: [
|
||||
"example-company.com",
|
||||
"",
|
||||
"example-company.org",
|
||||
"",
|
||||
"",
|
||||
],
|
||||
allowedDomains: [domain1, "", domain2, "", ""],
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.allowedDomains.sort()).toEqual([
|
||||
"example-company.com",
|
||||
"example-company.org",
|
||||
]);
|
||||
expect(body.data.allowedDomains.includes(domain1)).toBe(true);
|
||||
expect(body.data.allowedDomains.includes(domain2)).toBe(true);
|
||||
|
||||
const teamDomains: TeamDomain[] = await TeamDomain.findAll({
|
||||
where: { teamId: team.id },
|
||||
});
|
||||
expect(teamDomains.map((d) => d.name).sort()).toEqual([
|
||||
"example-company.com",
|
||||
"example-company.org",
|
||||
]);
|
||||
expect(teamDomains.map((d) => d.name).includes(domain1)).toBe(true);
|
||||
expect(teamDomains.map((d) => d.name).includes(domain2)).toBe(true);
|
||||
});
|
||||
|
||||
it("should remove old allowed Domains", async () => {
|
||||
@@ -139,27 +131,25 @@ describe("#team.update", () => {
|
||||
name: faker.internet.domainName(),
|
||||
createdById: admin.id,
|
||||
});
|
||||
const domain1 = faker.internet.domainName();
|
||||
const domain2 = faker.internet.domainName();
|
||||
|
||||
const res = await server.post("/api/team.update", {
|
||||
body: {
|
||||
token: admin.getJwtToken(),
|
||||
allowedDomains: ["example-company.org", "example-company.net"],
|
||||
allowedDomains: [domain1, domain2],
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.allowedDomains.sort()).toEqual([
|
||||
"example-company.net",
|
||||
"example-company.org",
|
||||
]);
|
||||
expect(body.data.allowedDomains.includes(domain1)).toBe(true);
|
||||
expect(body.data.allowedDomains.includes(domain2)).toBe(true);
|
||||
|
||||
const teamDomains: TeamDomain[] = await TeamDomain.findAll({
|
||||
where: { teamId: team.id },
|
||||
});
|
||||
expect(teamDomains.map((d) => d.name).sort()).toEqual(
|
||||
["example-company.org", "example-company.net"].sort()
|
||||
);
|
||||
|
||||
expect(teamDomains.map((d) => d.name).includes(domain1)).toBe(true);
|
||||
expect(teamDomains.map((d) => d.name).includes(domain2)).toBe(true);
|
||||
expect(await TeamDomain.findByPk(existingTeamDomain.id)).toBeNull();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user