Skip to content

Commit

Permalink
extended test timeout
Browse files Browse the repository at this point in the history
It seems there are more fellows so the test takes more time.

I also moved the timeout to the fellows tests so it doesn't extend the timeout in other tests that work properly with the shorter one
  • Loading branch information
Bullrich committed Nov 29, 2023
1 parent 5f07f7a commit ed14629
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 31 deletions.
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testTimeout: 8_000,
testMatch: [__dirname + "/src/**/test/**/*.test.ts"],
};
78 changes: 48 additions & 30 deletions src/test/fellows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { mock, mockClear, MockProxy } from "jest-mock-extended";
import { ActionLogger, TeamApi } from "../github/types";
import { PolkadotFellows } from "../polkadot/fellows";

const timeout = 10_000;

describe("CAPI test", () => {
let fellows: TeamApi;
let logger: MockProxy<ActionLogger>;
Expand All @@ -13,20 +15,28 @@ describe("CAPI test", () => {
fellows = new PolkadotFellows(logger);
});

test("Should fetch fellows", async () => {
const members = await fellows.getTeamMembers("2");
expect(members.length).toBeGreaterThan(0);
});
test(
"Should fetch fellows",
async () => {
const members = await fellows.getTeamMembers("2");
expect(members.length).toBeGreaterThan(0);
},
timeout,
);

test("Should cache fellows", async () => {
const members = await fellows.getTeamMembers("2");
expect(members.length).toBeGreaterThan(0);
expect(logger.debug).toHaveBeenCalledWith("Connecting to collective parachain");
mockClear(logger);
const members2 = await fellows.getTeamMembers("2");
expect(members2.length).toBeGreaterThan(0);
expect(logger.debug).not.toHaveBeenCalledWith("Connecting to collective parachain");
});
test(
"Should cache fellows",
async () => {
const members = await fellows.getTeamMembers("2");
expect(members.length).toBeGreaterThan(0);
expect(logger.debug).toHaveBeenCalledWith("Connecting to collective parachain");
mockClear(logger);
const members2 = await fellows.getTeamMembers("2");
expect(members2.length).toBeGreaterThan(0);
expect(logger.debug).not.toHaveBeenCalledWith("Connecting to collective parachain");
},
timeout,
);

describe("Fetch by rank", () => {
beforeEach(() => {
Expand All @@ -39,27 +49,35 @@ describe("CAPI test", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(fellows as any).fellowsCache = fellowsMap;
});
test("should return fellows of a give rank", async () => {
const rank1 = await fellows.getTeamMembers("1");
expect(rank1).toEqual(["user-1", "user-2", "user-3", "user-4", "user-5"]);
test(
"should return fellows of a give rank",
async () => {
const rank1 = await fellows.getTeamMembers("1");
expect(rank1).toEqual(["user-1", "user-2", "user-3", "user-4", "user-5"]);

const rank2 = await fellows.getTeamMembers("2");
expect(rank2).toEqual(["user-2", "user-3", "user-4", "user-5"]);
const rank2 = await fellows.getTeamMembers("2");
expect(rank2).toEqual(["user-2", "user-3", "user-4", "user-5"]);

const rank3 = await fellows.getTeamMembers("3");
expect(rank3).toEqual(["user-3", "user-4", "user-5"]);
const rank3 = await fellows.getTeamMembers("3");
expect(rank3).toEqual(["user-3", "user-4", "user-5"]);

const rank4 = await fellows.getTeamMembers("4");
expect(rank4).toEqual(["user-4", "user-5"]);
const rank4 = await fellows.getTeamMembers("4");
expect(rank4).toEqual(["user-4", "user-5"]);

const rank5 = await fellows.getTeamMembers("5");
expect(rank5).toEqual(["user-5"]);
});
const rank5 = await fellows.getTeamMembers("5");
expect(rank5).toEqual(["user-5"]);
},
timeout,
);

test("should throw if there are no fellows available", async () => {
await expect(fellows.getTeamMembers("6")).rejects.toThrowError(
"Found no members of rank 6 or higher. Please see debug logs",
);
});
test(
"should throw if there are no fellows available",
async () => {
await expect(fellows.getTeamMembers("6")).rejects.toThrowError(
"Found no members of rank 6 or higher. Please see debug logs",
);
},
timeout,
);
});
});

0 comments on commit ed14629

Please sign in to comment.