Skip to content

Commit

Permalink
Write userQuests tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evadecker committed Dec 10, 2024
1 parent 872064c commit 7deae75
Show file tree
Hide file tree
Showing 7 changed files with 997 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ frontend:

testing:
- changed-files:
- any-glob-to-any-file: ['tests/**', '**.test.{ts,tsx}', 'playwright.config.ts']
- any-glob-to-any-file: ['tests/**', '**/**.test.ts', '**/**.test.tsx','playwright.config.ts']

workflows:
- changed-files:
Expand Down
39 changes: 39 additions & 0 deletions convex/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ import { modules } from "./test.setup";

describe("auth", () => {
describe("createOrUpdateUser", () => {
it("should return existing user if id already exists", async () => {
const t = convexTest(schema, modules);

const userId = await t.run(async (ctx) => {
return await ctx.db.insert("users", {
email: "[email protected]",
role: "user",
});
});

const user = await t.run(async (ctx) => {
return await createOrUpdateUser(ctx, {
existingUserId: userId,
});
});

expect(user).toBe(userId);
});

it("should set role to admin in development environment", async () => {
const t = convexTest(schema, modules);

Expand Down Expand Up @@ -46,5 +65,25 @@ describe("auth", () => {
expect(user?.role).toBe("user");
vi.unstubAllEnvs();
});

it("should initialize default user settings", async () => {
const t = convexTest(schema, modules);

const userId = await t.run(async (ctx) => {
return await createOrUpdateUser(ctx, {
profile: {
email: "[email protected]",
},
});
});

const userSettings = await t.query(api.userSettings.getByUserId, {
userId,
});

expect(userSettings).toBeDefined();
expect(userSettings?.theme).toBe("system");
expect(userSettings?.groupQuestsBy).toBe("dateAdded");
});
});
});
Loading

0 comments on commit 7deae75

Please sign in to comment.