Skip to content

It would be nice if PromptRequiredError already had the suggestions for the prompt #6

Open
@Gnuxie

Description

@Gnuxie
  it("Will prompt for the policy list when it is missing", async function () {
    const { protectedRoomsSet, policyRoomManager } = await createProtectedRooms();
    const banResult = await CommandExecutorHelper.parseAndInvoke(
      DraupnirBanCommand,
      {
        policyRoomManager,
        roomResolver,
        issuerManager: protectedRoomsSet.issuerManager,
        defaultReasons: ["spam"],
        clientUserID: `@draupnir:ourserver.example.com` as StringUserID,
      },
      {},
      MatrixUserIDPresentationType.wrap(MatrixUserID.fromUserID("@spam:spam.example.com" as StringUserID)),
      undefined, // no policy room provided, we expect a prompt.
    );
    if (isOk(banResult)) {
      throw new TypeError(`We expect a prompt error to be returned`);
    }
    if (!(banResult.error instanceof PromptRequiredError)) {
      throw new TypeError(`Expected to have a prompt required error`)
    }
    expect(banResult.error.parameterRequiringPrompt.name).toBe("list");
  });

Would mean a test like this could also test that the prompt had been called properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions