fix(e2e): match the modal OK button exactly so a random suffix cannot collide (#253) #256
@@ -27,7 +27,12 @@ export class AdminInventory {
|
|||||||
this.price = page.getByLabel('Price (USD)');
|
this.price = page.getByLabel('Price (USD)');
|
||||||
this.category = page.getByLabel('Category', { exact: true });
|
this.category = page.getByLabel('Category', { exact: true });
|
||||||
this.saveButton = page.getByRole('button', { name: 'Save', exact: true });
|
this.saveButton = page.getByRole('button', { name: 'Save', exact: true });
|
||||||
this.confirmButton = page.getByRole('button', { name: 'OK' });
|
// exact, because Playwright matches an accessible name case-insensitively
|
||||||
|
// as a *substring* by default. Item names carry a random base36 suffix, and
|
||||||
|
// one containing "ok" — plus any leftover toast still on screen, such as
|
||||||
|
// "Freed rmtiq9okg22k9e" — makes this resolve to two buttons and fail as a
|
||||||
|
// strict mode violation. See #253.
|
||||||
|
this.confirmButton = page.getByRole('button', { name: 'OK', exact: true });
|
||||||
this.formDialog = page.getByRole('dialog');
|
this.formDialog = page.getByRole('dialog');
|
||||||
this.tagPicker = page.getByText('Pick existing tags');
|
this.tagPicker = page.getByText('Pick existing tags');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ export class AdminTaxonomy {
|
|||||||
this.addCategoryButton = page.getByRole('button', { name: 'Add Category' });
|
this.addCategoryButton = page.getByRole('button', { name: 'Add Category' });
|
||||||
this.addTagButton = page.getByRole('button', { name: 'Add Tag' });
|
this.addTagButton = page.getByRole('button', { name: 'Add Tag' });
|
||||||
this.name = page.getByLabel('Name');
|
this.name = page.getByLabel('Name');
|
||||||
this.confirmButton = page.getByRole('button', { name: 'OK' });
|
// Substring matching would collide with random suffixes. See #253.
|
||||||
|
this.confirmButton = page.getByRole('button', { name: 'OK', exact: true });
|
||||||
this.tagAddedNotice = page.getByText('Tag added');
|
this.tagAddedNotice = page.getByText('Tag added');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ test.describe('Filtering the storefront by availability', () => {
|
|||||||
await page.reload();
|
await page.reload();
|
||||||
|
|
||||||
await expect(storefront.gridCell(NAMES.sold)).toBeVisible();
|
await expect(storefront.gridCell(NAMES.sold)).toBeVisible();
|
||||||
await expect(page.getByRole('radio', { name: 'All' })).toBeChecked();
|
// exact: 'All' is short enough to appear inside other labels. See #253.
|
||||||
|
await expect(page.getByRole('radio', { name: 'All', exact: true })).toBeChecked();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Not sold is the default, so it is held as "no preference" rather than as an
|
// Not sold is the default, so it is held as "no preference" rather than as an
|
||||||
|
|||||||
Reference in New Issue
Block a user