Skip to content

Commit

Permalink
ci: added club creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Drixares committed Nov 2, 2024
1 parent 0edadf7 commit bc0107d
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions tests/e2e/challenges.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import createApp from "@/app";
import globals from "@/env/env";
import { toDateString } from "@/utils/date";
import { del, get, post, put } from "../utils";

const app = createApp("e2e-challenges");

const testGlobals = {
testId: 0,
challengedId: 0
clubId: 0,
challengedId: 0,
};

describe("Test challenges", () => {
Expand All @@ -30,9 +31,26 @@ describe("Test challenges", () => {
});
});

test("should create a challenge", async () => {
test("should create a club and challenge", async () => {

const resClub = await post(
app,
"/admin/clubs",
{
name: "challenge club test",
avatarUrl: "https://placehold.co/400",
description: "description",
dailyDate: toDateString(new Date("2024-11-01"))
},
{
"X-ADMIN-KEY": globals.env.ADMIN_TOKEN
}
);

testGlobals.clubId = resClub.body.response[0].data.id ?? "invalid";

const res = await post(app, "/admin/challenges", {
clubId: 1,
clubId: testGlobals.clubId,
score: 100,
name: "test challenge"
}, {
Expand All @@ -50,7 +68,7 @@ describe("Test challenges", () => {
id: expect.any(Number),
score: 100,
name: "test challenge",
clubId: 1,
clubId: testGlobals.clubId,
}
}
]
Expand Down Expand Up @@ -81,7 +99,7 @@ describe("Test challenges", () => {
id: testGlobals.challengedId,
score: 100,
name: "edited challenge",
clubId: 1,
clubId: testGlobals.clubId,
}
}
]
Expand All @@ -105,7 +123,7 @@ describe("Test challenges", () => {
id: expect.any(Number),
score: 100,
name: "edited challenge",
clubId: 1,
clubId: testGlobals.clubId,
}
])
}
Expand Down

0 comments on commit bc0107d

Please sign in to comment.