chore: Improve perf of server tests (#5785)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { buildUser, buildTeam } from "@server/test/factories";
|
||||
import {
|
||||
getTestServer,
|
||||
@@ -5,7 +7,7 @@ import {
|
||||
setSelfHosted,
|
||||
} from "@server/test/support";
|
||||
|
||||
const mockTeamInSessionId = "1e023d05-951c-41c6-9012-c9fa0402e1c3";
|
||||
const mockTeamInSessionId = uuidv4();
|
||||
|
||||
jest.mock("@server/utils/authentication", () => ({
|
||||
getSessionsInCookie() {
|
||||
@@ -25,9 +27,7 @@ describe("#auth.info", () => {
|
||||
id: mockTeamInSessionId,
|
||||
});
|
||||
|
||||
const user = await buildUser({
|
||||
teamId: team.id,
|
||||
});
|
||||
const user = await buildUser({ teamId: team.id });
|
||||
await buildUser();
|
||||
await buildUser({
|
||||
teamId: team2.id,
|
||||
@@ -53,9 +53,7 @@ describe("#auth.info", () => {
|
||||
|
||||
it("should require the team to not be deleted", async () => {
|
||||
const team = await buildTeam();
|
||||
const user = await buildUser({
|
||||
teamId: team.id,
|
||||
});
|
||||
const user = await buildUser({ teamId: team.id });
|
||||
await team.destroy();
|
||||
const res = await server.post("/api/auth.info", {
|
||||
body: {
|
||||
@@ -107,19 +105,20 @@ describe("#auth.config", () => {
|
||||
});
|
||||
|
||||
it("should return available providers for team subdomain", async () => {
|
||||
const subdomain = faker.internet.domainWord();
|
||||
await buildTeam({
|
||||
guestSignin: false,
|
||||
subdomain: "example",
|
||||
subdomain,
|
||||
authenticationProviders: [
|
||||
{
|
||||
name: "slack",
|
||||
providerId: "123",
|
||||
providerId: uuidv4(),
|
||||
},
|
||||
],
|
||||
});
|
||||
const res = await server.post("/api/auth.config", {
|
||||
headers: {
|
||||
host: `example.outline.dev`,
|
||||
host: `${subdomain}.outline.dev`,
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
@@ -129,19 +128,20 @@ describe("#auth.config", () => {
|
||||
});
|
||||
|
||||
it("should return available providers for team custom domain", async () => {
|
||||
const domain = faker.internet.domainName();
|
||||
await buildTeam({
|
||||
guestSignin: false,
|
||||
domain: "docs.mycompany.com",
|
||||
domain,
|
||||
authenticationProviders: [
|
||||
{
|
||||
name: "slack",
|
||||
providerId: "123",
|
||||
providerId: uuidv4(),
|
||||
},
|
||||
],
|
||||
});
|
||||
const res = await server.post("/api/auth.config", {
|
||||
headers: {
|
||||
host: "docs.mycompany.com",
|
||||
host: domain,
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
@@ -151,19 +151,20 @@ describe("#auth.config", () => {
|
||||
});
|
||||
|
||||
it("should return email provider for team when guest signin enabled", async () => {
|
||||
const subdomain = faker.internet.domainWord();
|
||||
await buildTeam({
|
||||
guestSignin: true,
|
||||
subdomain: "example",
|
||||
subdomain,
|
||||
authenticationProviders: [
|
||||
{
|
||||
name: "slack",
|
||||
providerId: "123",
|
||||
providerId: uuidv4(),
|
||||
},
|
||||
],
|
||||
});
|
||||
const res = await server.post("/api/auth.config", {
|
||||
headers: {
|
||||
host: "example.outline.dev",
|
||||
host: `${subdomain}.outline.dev`,
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
@@ -174,20 +175,21 @@ describe("#auth.config", () => {
|
||||
});
|
||||
|
||||
it("should not return provider when disabled", async () => {
|
||||
const subdomain = faker.internet.domainWord();
|
||||
await buildTeam({
|
||||
guestSignin: false,
|
||||
subdomain: "example",
|
||||
subdomain,
|
||||
authenticationProviders: [
|
||||
{
|
||||
name: "slack",
|
||||
providerId: "123",
|
||||
providerId: uuidv4(),
|
||||
enabled: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
const res = await server.post("/api/auth.config", {
|
||||
headers: {
|
||||
host: "example.outline.dev",
|
||||
host: `${subdomain}.outline.dev`,
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
@@ -204,7 +206,7 @@ describe("#auth.config", () => {
|
||||
authenticationProviders: [
|
||||
{
|
||||
name: "slack",
|
||||
providerId: "123",
|
||||
providerId: uuidv4(),
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -223,7 +225,7 @@ describe("#auth.config", () => {
|
||||
authenticationProviders: [
|
||||
{
|
||||
name: "slack",
|
||||
providerId: "123",
|
||||
providerId: uuidv4(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user