Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

test(bot-settings): assert the selected colour button by its own aria-pressed

Bugfixer 2608c63a7c034
diff --git a/src/components/BotProfileAvatarCard.test.ts b/src/components/BotProfileAvatarCard.test.ts
index d517aa877e..a5ba08c953 100644
--- a/src/components/BotProfileAvatarCard.test.ts
+++ b/src/components/BotProfileAvatarCard.test.ts
@@ -107,14 +107,20 @@ describe("BotProfileAvatarCard body picker", () => {
});
});
+function colorButton(markup: string, color: string): string {
+ const tag = markup.match(new RegExp(`<button[^>]*aria-label="Use ${color} mascot color"[^>]*>`))?.[0];
+ expect(tag, `${color} color button`).toBeDefined();
+ return tag ?? "";
+}
+
describe("BotProfileAvatarCard color picker", () => {
it("keeps the color picker for a custom photo in every flat crop", () => {
for (const crop of ["circle", "rounded", "square"] as const) {
const markup = renderCard(makeBot({ avatarUrl: "/api/attachments/cat.webp", avatarCrop: crop, color: "blue" }));
expect(markup).toContain(">Color<");
- expect(markup).toContain('aria-pressed="true" class="size-10');
- expect(markup).toContain('aria-label="Use blue mascot color"');
+ expect(colorButton(markup, "blue")).toContain('aria-pressed="true"');
+ expect(colorButton(markup, "green")).toContain('aria-pressed="false"');
expect(markup).not.toContain(">Expression<");
}
});