playwright-fluent
Version:
Fluent API around playwright
29 lines (28 loc) • 1.25 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.expectThatDialogHasMessage = void 0;
const utils_1 = require("../../utils");
const fluent_api_1 = require("../../fluent-api");
async function expectThatDialogHasMessage(dialog, message, options = fluent_api_1.defaultAssertOptions) {
const waitOptions = {
...utils_1.defaultWaitUntilOptions,
...fluent_api_1.defaultAssertOptions,
...options,
throwOnTimeout: true,
};
await (0, utils_1.waitUntil)(async () => {
const currentDialog = dialog();
const currentMessage = currentDialog === null || currentDialog === void 0 ? void 0 : currentDialog.message();
if (typeof currentMessage !== 'string') {
return false;
}
return currentMessage.includes(message);
}, async () => {
const currentDialog = dialog();
if (!currentDialog) {
return `No dialog has been opened. Maybe you forgot to call the '.withDialogs()' on the playwright-fluent instance.`;
}
return `Current dialog has message '${currentDialog.message()}' but it should be '${message}'`;
}, waitOptions);
}
exports.expectThatDialogHasMessage = expectThatDialogHasMessage;
;