Skip to content

Commit

Permalink
test(dropdown): add end-to-end test for toggling dropdown visibility …
Browse files Browse the repository at this point in the history
…and selecting option two
  • Loading branch information
ckrook authored and theJohnnyMe committed Oct 16, 2024
1 parent 483eb85 commit 5eb1d52
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/core/src/components/dropdown/test/filter/dropdown.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,30 @@ test.describe.parallel('tds-dropdown-filter', () => {
await expect(inputElement).toHaveValue(''); // Ensure input is cleared
await expect(resetButton).toBeHidden(); // Reset button should hide again after clearing the input
});

test('toggle dropdown visibility and select option two', async ({ page }) => {
await page.goto(componentTestPath);

const inputElement = page.getByRole('textbox');
const dropdownListElementTwoButton = page
.locator('tds-dropdown-option')
.filter({ hasText: /Option 2/ });

const dropdownButton = page.locator('tds-icon[aria-label="Open/Close dropdown"]');

// Focus on the input element and start typing
await expect(dropdownListElementTwoButton).toBeHidden();
await inputElement.click();
await expect(inputElement).toBeVisible();

// Click the dropdown button to open the dropdown list
await dropdownListElementTwoButton.click();
await inputElement.click();
// Click the dropdown button to close the dropdown list
await dropdownButton.click();
// Click the dropdown button to open the dropdown list
await dropdownButton.click();

await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit 5eb1d52

Please sign in to comment.