playwright-fluent
Version:
Fluent API around playwright
32 lines (31 loc) • 1.33 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.expectThatDialogHasValue = void 0;
const utils_1 = require("../../utils");
const fluent_api_1 = require("../../fluent-api");
async function expectThatDialogHasValue(dialog, value, 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 currentValue = currentDialog === null || currentDialog === void 0 ? void 0 : currentDialog.defaultValue();
if (typeof currentValue !== 'string') {
return false;
}
if (currentValue.length === 0) {
return value === '';
}
return currentValue.includes(value);
}, 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 value '${currentDialog.defaultValue()}' but it should be '${value}'`;
}, waitOptions);
}
exports.expectThatDialogHasValue = expectThatDialogHasValue;
;