Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix async dialog specs when they fail #5859

Merged
merged 1 commit into from May 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions test/dialog.spec.js
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/
const expect = require('expect');
const sinon = require('sinon');

const {
getTestState,
setupTestPageAndContextHooks,
Expand All @@ -34,16 +36,23 @@ describe('Page.Events.Dialog', function () {
});
await page.evaluate(() => alert('yo'));
});

itFailsFirefox('should allow accepting prompts', async () => {
const { page } = getTestState();

page.on('dialog', (dialog) => {
expect(dialog.type()).toBe('prompt');
expect(dialog.defaultValue()).toBe('yes.');
expect(dialog.message()).toBe('question?');
const onDialog = sinon.stub().callsFake((dialog) => {
dialog.accept('answer!');
});
page.on('dialog', onDialog);

const result = await page.evaluate(() => prompt('question?', 'yes.'));

expect(onDialog.callCount).toEqual(1);
const dialog = onDialog.firstCall.args[0];
expect(dialog.type()).toBe('prompt');
expect(dialog.defaultValue()).toBe('yes.');
expect(dialog.message()).toBe('question?');

expect(result).toBe('answer!');
});
it('should dismiss the prompt', async () => {
Expand Down