Wizard: Disable "No results found" options

The "No results found for <searchTerm>" options were previously enabled, but ignored upon click. This disables them properly and adds tests to check if they're disabled.
This commit is contained in:
regexowl 2025-03-14 08:42:14 +01:00 committed by Klara Simickova
parent fbc0ea13e6
commit 88f41b0b75
5 changed files with 82 additions and 37 deletions

View file

@ -76,12 +76,12 @@ const selectLanguages = async () => {
await waitFor(() => user.click(enOption));
};
const searchForKeyboard = async () => {
const searchForKeyboard = async (keyboard: string) => {
const user = userEvent.setup();
const keyboardDropdown = await screen.findByPlaceholderText(
/select a keyboard/i
);
await waitFor(() => user.type(keyboardDropdown, 'us'));
await waitFor(() => user.type(keyboardDropdown, keyboard));
};
const selectKeyboard = async () => {
@ -145,17 +145,35 @@ describe('Step Locale', () => {
test('keyboard search results get sorted correctly', async () => {
await renderCreateMode();
await goToLocaleStep();
await searchForKeyboard();
await searchForKeyboard('us');
const options = await screen.findAllByRole('option');
expect(options[0]).toHaveTextContent('us');
expect(options[1]).toHaveTextContent('us-acentos');
expect(options[2]).toHaveTextContent('us-alt-intl');
});
test('unknown option is disabled', async () => {
await renderCreateMode();
await goToLocaleStep();
await searchForLanguage('foo');
await screen.findByText(/no results found/i);
expect(
await screen.findByRole('option', { name: /no results found/i })
).toBeDisabled();
await clearLanguageSearch();
await searchForKeyboard('foo');
await screen.findByText(/no results found/i);
expect(
await screen.findByRole('option', { name: /no results found/i })
).toBeDisabled();
});
test('revisit step button on Review works', async () => {
await renderCreateMode();
await goToLocaleStep();
await searchForKeyboard();
await searchForKeyboard('us');
await selectKeyboard();
await goToReviewStep();
await clickRevisitButton();
@ -191,7 +209,7 @@ describe('Locale request generated correctly', () => {
test('with keyboard selected', async () => {
await renderCreateMode();
await goToLocaleStep();
await searchForKeyboard();
await searchForKeyboard('us');
await selectKeyboard();
await goToReviewStep();
const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT);
@ -214,7 +232,7 @@ describe('Locale request generated correctly', () => {
await renderCreateMode();
await goToLocaleStep();
await selectLanguages();
await searchForKeyboard();
await searchForKeyboard('us');
await selectKeyboard();
await goToReviewStep();
const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT);

View file

@ -59,6 +59,14 @@ const selectTimezone = async () => {
await waitFor(() => user.click(amsterdamTimezone));
};
const searchForUnknownTimezone = async () => {
const user = userEvent.setup();
const timezoneDropdown = await screen.findByPlaceholderText(
/select a timezone/i
);
await waitFor(() => user.type(timezoneDropdown, 'foo'));
};
const addNtpServerViaKeyDown = async (ntpServer: string) => {
const user = userEvent.setup();
const ntpServersInput = await screen.findByPlaceholderText(
@ -124,6 +132,16 @@ describe('Step Timezone', () => {
await verifyCancelButton(router);
});
test('unknown option is disabled', async () => {
await renderCreateMode();
await goToTimezoneStep();
await searchForUnknownTimezone();
await screen.findByText(/no results found/i);
expect(
await screen.findByRole('option', { name: /no results found/i })
).toBeDisabled();
});
test('duplicate NTP server cannnot be added', async () => {
await renderCreateMode();
await goToTimezoneStep();