Skip to content

Commit e480fa6

Browse files
andrew-polkclaude
andcommitted
chore(language-chooser-react-mui): add e2e tests for variant alert and fuzzy script search
Covers the dialog wiring of BL-14904 (invalid-variant alert on OK) and BL-14903 (fuzzy script matching in the script dropdown), which previously had only unit tests on their underlying functions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 8e0e2a1 commit e480fa6

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

components/language-chooser/react/language-chooser-react-mui/e2e/customizationDialog.e2e.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,47 @@ test.describe("Customization button and dialog", () => {
360360
await expect(dialogTagPreview).toContainText("ce-x-test123f");
361361
});
362362

363+
test("Invalidly formatted variant shows alert on OK", async () => {
364+
await selectChechenCard(page);
365+
await clickCustomizationButton(page);
366+
const customizationDialog = await customizationDialogLocator(page);
367+
await expect(customizationDialog).toBeVisible();
368+
369+
// 11 characters, too long for a BCP 47 variant subtag (5-8)
370+
await enterVariant(customizationDialog, "dialectTest");
371+
372+
let alertMessage = "";
373+
const alertHandled = page.waitForEvent("dialog").then(async (dialog) => {
374+
alertMessage = dialog.message();
375+
await dialog.accept();
376+
});
377+
378+
await okButtonLocator(customizationDialog).click();
379+
await alertHandled;
380+
381+
await expect(alertMessage).toContain(
382+
"Variant is not in a valid BCP 47 format."
383+
);
384+
});
385+
386+
test("Script dropdown finds scripts by fuzzy matching", async () => {
387+
await selectChechenCard(page);
388+
await clickCustomizationButton(page);
389+
const customizationDialog = await customizationDialogLocator(page);
390+
await expect(customizationDialog).toBeVisible();
391+
392+
// "Cyrilic" (misspelled) is not a substring of "Cyrillic", so only the
393+
// fuzzy search can surface it
394+
await scriptFieldLocator(customizationDialog).fill("Cyrilic");
395+
await expect(
396+
page.getByRole("option", { name: "Cyrillic", exact: true })
397+
).toBeVisible();
398+
399+
// close the options popup so it doesn't block the next test's cleanup
400+
await page.keyboard.press("Escape");
401+
await expect(page.getByRole("listbox")).not.toBeVisible();
402+
});
403+
363404
test("Live BCP 47 tag preview updates as fields change in dialog", async () => {
364405
await selectChechenCard(page);
365406
await clickCustomizationButton(page);

0 commit comments

Comments
 (0)