diff --git a/src/handlers/experience-gate/xp-gate.ts b/src/handlers/experience-gate/xp-gate.ts index 4d3971aa..7779bc55 100644 --- a/src/handlers/experience-gate/xp-gate.ts +++ b/src/handlers/experience-gate/xp-gate.ts @@ -9,8 +9,8 @@ export async function handleExperienceChecks(context: Context) { } = context; if (!experience) { - logger.error("Experience checks are disabled"); - return; + logger.info("Experience checks are disabled"); + return true; } if (!(await accountAgeHandler(context))) { diff --git a/tests/main.test.ts b/tests/main.test.ts index 715c2a42..9927cc2c 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -240,6 +240,20 @@ describe("User start/stop", () => { } } }); + + + test("User can't start an issue if they don't pass the experience checks", async () => { + const issue = db.issue.findFirst({ where: { id: { equals: 1 } } }) as unknown as Issue; + const sender = db.users.findFirst({ where: { id: { equals: 1 } } }) as unknown as Sender; + + + const context = createContext(issue, sender, "/start", true, true, true, false); + const warnSpy = jest.spyOn(context.logger, "error"); + await userStartStop(context); + + expect(warnSpy).toHaveBeenNthCalledWith(1, "ubiquity has less than required 50% experience with solidity"); + expect(warnSpy).toHaveBeenNthCalledWith(2, "You do not meet the requirements to start this issue."); + }); }); async function setupTests() { @@ -384,7 +398,7 @@ async function setupTests() { }); } -function createContext(issue: Record, sender: Record, body = "/start", isEnabled = true, withData = true) { +function createContext(issue: Record, sender: Record, body = "/start", isEnabled = true, withData = true, experience = false, passXp = true) { const ctx: Context = { adapters: {} as ReturnType, payload: { @@ -407,17 +421,31 @@ function createContext(issue: Record, sender: Record