chore: More flakey test improvements (#5801)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { SaveOptions } from "sequelize";
|
||||
import type { SaveOptions, WhereOptions } from "sequelize";
|
||||
import {
|
||||
ForeignKey,
|
||||
AfterSave,
|
||||
@@ -111,6 +111,19 @@ class Event extends IdModel {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the latest event matching the where clause
|
||||
*
|
||||
* @param where The options to match against
|
||||
* @returns A promise resolving to the latest event or null
|
||||
*/
|
||||
static findLatest(where: WhereOptions) {
|
||||
return this.findOne({
|
||||
where,
|
||||
order: [["createdAt", "DESC"]],
|
||||
});
|
||||
}
|
||||
|
||||
static ACTIVITY_EVENTS: TEvent["name"][] = [
|
||||
"collections.create",
|
||||
"collections.delete",
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { buildAdmin, buildTeam } from "@server/test/factories";
|
||||
import { setCloudHosted } from "@server/test/support";
|
||||
import TeamDomain from "./TeamDomain";
|
||||
|
||||
describe("team domain model", () => {
|
||||
beforeEach(setCloudHosted);
|
||||
|
||||
describe("create", () => {
|
||||
it("should allow creation of domains", async () => {
|
||||
const team = await buildTeam();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { CollectionPermission } from "@shared/types";
|
||||
import { buildUser, buildTeam, buildCollection } from "@server/test/factories";
|
||||
import CollectionUser from "./CollectionUser";
|
||||
@@ -42,10 +43,11 @@ describe("user model", () => {
|
||||
|
||||
describe("availableTeams", () => {
|
||||
it("should return teams where another user with the same email exists", async () => {
|
||||
const email = faker.internet.email().toLowerCase();
|
||||
const user = await buildUser({
|
||||
email: "user-available-teams@example.com",
|
||||
email,
|
||||
});
|
||||
const anotherUser = await buildUser({ email: user.email });
|
||||
const anotherUser = await buildUser({ email });
|
||||
|
||||
const response = await user.availableTeams();
|
||||
expect(response.length).toEqual(2);
|
||||
|
||||
Reference in New Issue
Block a user