Ensure mobile controls dialog closes reliably
This commit is contained in:
@@ -206,6 +206,31 @@ test.describe('Active pick list', () => {
|
|||||||
await expect(page.getByText(/Qty:\s*1\s+unit/i)).toBeVisible();
|
await expect(page.getByText(/Qty:\s*1\s+unit/i)).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('closes mobile controls with the close button and backdrop', async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
|
|
||||||
|
await navigateToNewPickList(page);
|
||||||
|
await addProductToPickList(page, additionalProduct);
|
||||||
|
|
||||||
|
const productRow = page
|
||||||
|
.getByText(additionalProduct, { exact: true })
|
||||||
|
.locator('xpath=ancestor::div[contains(@class, "MuiStack-root")]')
|
||||||
|
.first();
|
||||||
|
const controlsDialog = page.getByRole('dialog', { name: additionalProduct });
|
||||||
|
|
||||||
|
await productRow.click();
|
||||||
|
await expect(controlsDialog).toBeVisible();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Close controls' }).click();
|
||||||
|
await expect(controlsDialog).toHaveCount(0);
|
||||||
|
|
||||||
|
await productRow.click();
|
||||||
|
await expect(controlsDialog).toBeVisible();
|
||||||
|
|
||||||
|
await page.locator('.MuiBackdrop-root').click({ position: { x: 10, y: 10 } });
|
||||||
|
await expect(controlsDialog).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
test('toggles picked visibility and disables the filter when all items are picked', async ({ page }) => {
|
test('toggles picked visibility and disables the filter when all items are picked', async ({ page }) => {
|
||||||
await navigateToNewPickList(page);
|
await navigateToNewPickList(page);
|
||||||
await addProductToPickList(page, secondaryProduct);
|
await addProductToPickList(page, secondaryProduct);
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ export const PickItemRow = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCloseControls = () => {
|
||||||
|
setIsControlsOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleRowKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
const handleRowKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
||||||
if (!isNarrowScreen) return;
|
if (!isNarrowScreen) return;
|
||||||
|
|
||||||
@@ -182,7 +186,7 @@ export const PickItemRow = ({
|
|||||||
{isNarrowScreen && (
|
{isNarrowScreen && (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={isControlsOpen}
|
open={isControlsOpen}
|
||||||
onClose={() => setIsControlsOpen(false)}
|
onClose={handleCloseControls}
|
||||||
fullWidth
|
fullWidth
|
||||||
maxWidth="xs"
|
maxWidth="xs"
|
||||||
aria-labelledby="item-controls-title"
|
aria-labelledby="item-controls-title"
|
||||||
@@ -196,10 +200,7 @@ export const PickItemRow = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
<IconButton
|
<IconButton
|
||||||
aria-label="Close controls"
|
aria-label="Close controls"
|
||||||
onClick={(event) => {
|
onClick={handleCloseControls}
|
||||||
stopPropagation(event);
|
|
||||||
setIsControlsOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Close />
|
<Close />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|||||||
Reference in New Issue
Block a user