playwright-fluent
Version:
Fluent API around playwright
29 lines (28 loc) • 1.26 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.expectThatDialogHasExactValue = void 0;
const utils_1 = require("../../utils");
const fluent_api_1 = require("../../fluent-api");
async function expectThatDialogHasExactValue(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;
}
return currentValue === 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.expectThatDialogHasExactValue = expectThatDialogHasExactValue;
;