test(datetime): expect the empty-clipboard toast in the paste E2E test

This commit is contained in:
Neha P
2026-11-04 11:25:06 +05:30
parent 86f3df621d
commit aa4d4f0979
2 changed files with 12 additions and 4 deletions
@@ -69,11 +69,12 @@ export class DateTimePickerPage {
this.customPeriodTrigger = this.customRow.locator('[role="combobox"]');
// ==================== Expected toast messages ====================
// Values of common.dateRangeCopied / dateRangePasted / dateRangePasteError
// Values of common.dateRangeCopied / dateRangePasted / dateRangePasteError / dateRangePasteEmpty
// in web/src/locales/languages/en-US.json.
this.copiedToastMessage = 'Date range copied';
this.pastedToastMessage = 'Date range pasted';
this.pasteErrorToastMessage = 'Could not parse date range';
this.pasteEmptyToastMessage = 'Clipboard is empty. Copy a date range first.';
}
// ==================== Locator factories ====================
@@ -250,6 +251,11 @@ export class DateTimePickerPage {
await expect(this.toastByMessage(this.pasteErrorToastMessage)).toBeVisible();
}
async expectPasteEmptyToast() {
await expect(this.toastByMessage(this.pasteEmptyToastMessage)).toBeVisible();
await expect(this.toastByMessage(this.pasteErrorToastMessage)).toHaveCount(0);
}
// ==================== Value readers ====================
async getStartTimeValue() {
@@ -276,19 +276,21 @@ test.describe("DateTime Picker Copy Paste testcases", () => {
});
// TC-12
test("should show the parse error toast when the clipboard is empty", {
test("should say the clipboard is empty when pasting an empty clipboard", {
tag: ['@datetime-picker', '@all', '@P2']
}, async () => {
testLogger.info('Pasting with an empty clipboard');
await pm.dateTimePickerPage.selectRelativePeriod('15-m');
const labelBeforePaste = await pm.dateTimePickerPage.getTriggerLabel();
await pm.dateTimePickerPage.seedClipboard('');
await pm.dateTimePickerPage.clickPaste();
await pm.dateTimePickerPage.expectPasteErrorToast();
await pm.dateTimePickerPage.expectPasteEmptyToast();
await pm.dateTimePickerPage.expectRelativePanelActive();
expect(await pm.dateTimePickerPage.getTriggerLabel()).toBe(labelBeforePaste);
testLogger.info('Empty clipboard rejected with the parse error toast');
testLogger.info('Empty clipboard rejected with the empty-clipboard toast');
});
});