Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
meetulr committed Nov 2, 2024
1 parent de316a2 commit c6863d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/resolvers/Mutation/addPeopleToUserTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ export const addPeopleToUserTag: MutationResolvers["addPeopleToUserTag"] =
allAncestorTags.map((tagId) => ({
updateOne: {
filter: { userId: user._id, tagId },
update: { $setOnInsert: { userId: user._id, tagId } },
update: {
$setOnInsert: {
userId: user._id,
tagId,
organizationId: tag.organizationId,
},
},
upsert: true,
setDefaultsOnInsert: true,
},
Expand Down
3 changes: 3 additions & 0 deletions tests/resolvers/Mutation/unassignUserTag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ describe("resolvers -> Mutation -> unassignUserTag", () => {
// Assign the tag to the user
await TagUser.create({
...args.input,
organizationId: testTag?.organizationId,
});

// Test the unassignUserTag resolver
Expand Down Expand Up @@ -266,11 +267,13 @@ describe("resolvers -> Mutation -> unassignUserTag", () => {
// Assign the parent and sub tag to the user
await TagUser.create({
...args.input,
organizationId: testTag?.organizationId,
});

await TagUser.create({
...args.input,
tagId: testSubTag1 ? testSubTag1._id.toString() : "",
organizationId: testSubTag1?.organizationId,
});

// Test the unassignUserTag resolver
Expand Down
13 changes: 9 additions & 4 deletions tests/resolvers/User/tagsAssignedWith.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import "dotenv/config";
import {
parseCursor,
Expand All @@ -8,7 +7,10 @@ import { connect, disconnect } from "../../helpers/db";
import type mongoose from "mongoose";
import { beforeAll, afterAll, describe, it, expect } from "vitest";
import type { TestUserTagType } from "../../helpers/tags";
import type { TestUserType } from "../../helpers/userAndOrg";
import type {
TestOrganizationType,
TestUserType,
} from "../../helpers/userAndOrg";
import { createTagsAndAssignToUser } from "../../helpers/tags";
import { GraphQLError } from "graphql";
import type { DefaultGraphQLArgumentError } from "../../../src/utilities/graphQLConnection";
Expand All @@ -20,11 +22,13 @@ import {
import { Types } from "mongoose";

let MONGOOSE_INSTANCE: typeof mongoose;
let testTag: TestUserTagType, testUser: TestUserType;
let testTag: TestUserTagType,
testUser: TestUserType,
testOrganization: TestOrganizationType;

beforeAll(async () => {
MONGOOSE_INSTANCE = await connect();
[testUser, , [testTag]] = await createTagsAndAssignToUser();
[testUser, testOrganization, [testTag]] = await createTagsAndAssignToUser();
});

afterAll(async () => {
Expand Down Expand Up @@ -52,6 +56,7 @@ describe("tagsAssignedWith resolver", () => {
parent,
{
first: 3,
organizationId: testOrganization?._id,
},
{},
);
Expand Down

0 comments on commit c6863d0

Please sign in to comment.