test: disable most codegen on headful firefox (#4839)

It has problems with focus.
This commit is contained in:
Dmitry Gozman 2020-12-28 17:39:30 -08:00 committed by GitHub
parent 7f8717f139
commit 8fbb984f64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,9 +18,12 @@ import { folio } from './cli.fixtures';
import * as http from 'http';
import * as url from 'url';
const { it, expect } = folio;
const { it, describe, expect } = folio;
it('should click', async ({ page, recorder }) => {
describe('cli codegen', (test, { browserName, headful }) => {
test.fixme(browserName === 'firefox' && headful, 'Focus is off');
}, () => {
it('should click', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<button onclick="console.log('click')">Submit</button>`);
const selector = await recorder.hoverOverElement('button');
@ -35,9 +38,9 @@ it('should click', async ({ page, recorder }) => {
// Click text="Submit"
await page.click('text="Submit"');`);
expect(message.text()).toBe('click');
});
});
it('should not target selector preview by text regexp', async ({ page, recorder }) => {
it('should not target selector preview by text regexp', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<span>dummy</span>`);
// Force highlight.
@ -67,9 +70,9 @@ it('should not target selector preview by text regexp', async ({ page, recorder
// Click text=/.*Some long text here.*/
await page.click('text=/.*Some long text here.*/');`);
expect(message.text()).toBe('click');
});
});
it('should fill', async ({ page, recorder }) => {
it('should fill', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input id="input" name="name" oninput="console.log(input.value)"></input>`);
const selector = await recorder.focusElement('input');
expect(selector).toBe('input[name="name"]');
@ -83,9 +86,9 @@ it('should fill', async ({ page, recorder }) => {
// Fill input[name="name"]
await page.fill('input[name="name"]', 'John');`);
expect(message.text()).toBe('John');
});
});
it('should fill textarea', async ({ page, recorder }) => {
it('should fill textarea', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<textarea id="textarea" name="name" oninput="console.log(textarea.value)"></textarea>`);
const selector = await recorder.focusElement('textarea');
expect(selector).toBe('textarea[name="name"]');
@ -99,9 +102,9 @@ it('should fill textarea', async ({ page, recorder }) => {
// Fill textarea[name="name"]
await page.fill('textarea[name="name"]', 'John');`);
expect(message.text()).toBe('John');
});
});
it('should press', async ({ page, recorder }) => {
it('should press', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input name="name" onkeypress="console.log('press')"></input>`);
const selector = await recorder.focusElement('input');
@ -118,9 +121,9 @@ it('should press', async ({ page, recorder }) => {
// Press Enter with modifiers
await page.press('input[name="name"]', 'Shift+Enter');`);
expect(messages[0].text()).toBe('press');
});
});
it('should update selected element after pressing Tab', async ({ page, recorder }) => {
it('should update selected element after pressing Tab', async ({ page, recorder }) => {
await recorder.setContentAndWait(`
<input name="one"></input>
<input name="two"></input>
@ -147,9 +150,9 @@ it('should update selected element after pressing Tab', async ({ page, recorder
expect(recorder.output()).toContain(`
// Fill input[name="two"]
await page.fill('input[name="two"]', 'barfoo321');`);
});
});
it('should record ArrowDown', async ({ page, recorder }) => {
it('should record ArrowDown', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input name="name" onkeydown="console.log('press:' + event.key)"></input>`);
const selector = await recorder.focusElement('input');
@ -168,9 +171,9 @@ it('should record ArrowDown', async ({ page, recorder }) => {
// Press ArrowDown
await page.press('input[name="name"]', 'ArrowDown');`);
expect(messages[0].text()).toBe('press:ArrowDown');
});
});
it('should emit single keyup on ArrowDown', async ({ page, recorder }) => {
it('should emit single keyup on ArrowDown', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input name="name" onkeydown="console.log('down:' + event.key)" onkeyup="console.log('up:' + event.key)"></input>`);
const selector = await recorder.focusElement('input');
@ -191,11 +194,9 @@ it('should emit single keyup on ArrowDown', async ({ page, recorder }) => {
expect(messages.length).toBe(2);
expect(messages[0].text()).toBe('down:ArrowDown');
expect(messages[1].text()).toBe('up:ArrowDown');
});
});
it('should check', (test, { browserName, headful }) => {
test.fixme(browserName === 'firefox' && headful, 'Focus is off');
}, async ({ page, recorder }) => {
it('should check', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="console.log(checkbox.checked)"></input>`);
const selector = await recorder.focusElement('input');
@ -211,11 +212,9 @@ it('should check', (test, { browserName, headful }) => {
// Check input[name="accept"]
await page.check('input[name="accept"]');`);
expect(message.text()).toBe('true');
});
});
it('should check with keyboard', (test, { browserName, headful }) => {
test.fixme(browserName === 'firefox' && headful, 'Focus is off');
}, async ({ page, recorder }) => {
it('should check with keyboard', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="console.log(checkbox.checked)"></input>`);
const selector = await recorder.focusElement('input');
@ -231,11 +230,9 @@ it('should check with keyboard', (test, { browserName, headful }) => {
// Check input[name="accept"]
await page.check('input[name="accept"]');`);
expect(message.text()).toBe('true');
});
});
it('should uncheck', (test, { browserName, headful }) => {
test.fixme(browserName === 'firefox' && headful, 'Focus is off');
}, async ({ page, recorder }) => {
it('should uncheck', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" checked name="accept" onchange="console.log(checkbox.checked)"></input>`);
const selector = await recorder.focusElement('input');
@ -250,9 +247,9 @@ it('should uncheck', (test, { browserName, headful }) => {
// Uncheck input[name="accept"]
await page.uncheck('input[name="accept"]');`);
expect(message.text()).toBe('false');
});
});
it('should select', async ({ page, recorder }) => {
it('should select', async ({ page, recorder }) => {
await recorder.setContentAndWait('<select id="age" onchange="console.log(age.selectedOptions[0].value)"><option value="1"><option value="2"></select>');
const selector = await recorder.hoverOverElement('select');
@ -267,11 +264,11 @@ it('should select', async ({ page, recorder }) => {
// Select 2
await page.selectOption('select[id="age"]', '2');`);
expect(message.text()).toBe('2');
});
});
it('should await popup', (test, { browserName, headful }) => {
it('should await popup', (test, { browserName, headful }) => {
test.fixme(browserName === 'webkit' && headful, 'Middle click does not open a popup in our webkit embedder');
}, async ({ page, recorder }) => {
}, async ({ page, recorder }) => {
await recorder.setContentAndWait('<a target=_blank rel=noopener href="about:blank">link</a>');
const selector = await recorder.hoverOverElement('a');
@ -289,9 +286,9 @@ it('should await popup', (test, { browserName, headful }) => {
page.click('text="link"')
]);`);
expect(popup.url()).toBe('about:blank');
});
});
it('should assert navigation', async ({ page, recorder }) => {
it('should assert navigation', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<a onclick="window.location.href='about:blank#foo'">link</a>`);
const selector = await recorder.hoverOverElement('a');
@ -307,10 +304,10 @@ it('should assert navigation', async ({ page, recorder }) => {
await page.click('text="link"');
// assert.equal(page.url(), 'about:blank#foo');`);
expect(page.url()).toContain('about:blank#foo');
});
});
it('should await navigation', async ({ page, recorder }) => {
it('should await navigation', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<a onclick="setTimeout(() => window.location.href='about:blank#foo', 1000)">link</a>`);
const selector = await recorder.hoverOverElement('a');
@ -328,28 +325,28 @@ it('should await navigation', async ({ page, recorder }) => {
page.click('text="link"')
]);`);
expect(page.url()).toContain('about:blank#foo');
});
});
it('should contain open page', async ({ recorder }) => {
it('should contain open page', async ({ recorder }) => {
await recorder.setContentAndWait(``);
expect(recorder.output()).toContain(`const page = await context.newPage();`);
});
});
it('should contain second page', async ({ contextWrapper, recorder }) => {
it('should contain second page', async ({ contextWrapper, recorder }) => {
await recorder.setContentAndWait(``);
await contextWrapper.context.newPage();
await recorder.waitForOutput('page1');
expect(recorder.output()).toContain('const page1 = await context.newPage();');
});
});
it('should contain close page', async ({ contextWrapper, recorder }) => {
it('should contain close page', async ({ contextWrapper, recorder }) => {
await recorder.setContentAndWait(``);
await contextWrapper.context.newPage();
await recorder.page.close();
await recorder.waitForOutput('page.close();');
});
});
it('should not lead to an error if /html gets clicked', async ({ contextWrapper, recorder }) => {
it('should not lead to an error if /html gets clicked', async ({ contextWrapper, recorder }) => {
await recorder.setContentAndWait('');
await contextWrapper.context.newPage();
const errors: any[] = [];
@ -360,14 +357,14 @@ it('should not lead to an error if /html gets clicked', async ({ contextWrapper,
await recorder.page.close();
await recorder.waitForOutput('page.close();');
expect(errors.length).toBe(0);
});
});
it('should upload a single file', async ({ page, recorder }) => {
it('should upload a single file', async ({ page, recorder }) => {
await recorder.setContentAndWait(`
<form>
<input type="file">
</form>
`);
`);
await page.focus('input[type=file]');
await page.setInputFiles('input[type=file]', 'test/assets/file-to-upload.txt');
@ -377,14 +374,14 @@ it('should upload a single file', async ({ page, recorder }) => {
expect(recorder.output()).toContain(`
// Upload file-to-upload.txt
await page.setInputFiles('input[type="file"]', 'file-to-upload.txt');`);
});
});
it('should upload multiple files', async ({ page, recorder }) => {
it('should upload multiple files', async ({ page, recorder }) => {
await recorder.setContentAndWait(`
<form>
<input type="file" multiple>
</form>
`);
`);
await page.focus('input[type=file]');
await page.setInputFiles('input[type=file]', ['test/assets/file-to-upload.txt', 'test/assets/file-to-upload-2.txt']);
@ -394,14 +391,14 @@ it('should upload multiple files', async ({ page, recorder }) => {
expect(recorder.output()).toContain(`
// Upload file-to-upload.txt, file-to-upload-2.txt
await page.setInputFiles('input[type="file"]', ['file-to-upload.txt', 'file-to-upload-2.txt']);`);
});
});
it('should clear files', async ({ page, recorder }) => {
it('should clear files', async ({ page, recorder }) => {
await recorder.setContentAndWait(`
<form>
<input type="file" multiple>
</form>
`);
`);
await page.focus('input[type=file]');
await page.setInputFiles('input[type=file]', 'test/assets/file-to-upload.txt');
await page.setInputFiles('input[type=file]', []);
@ -411,9 +408,9 @@ it('should clear files', async ({ page, recorder }) => {
expect(recorder.output()).toContain(`
// Clear selected files
await page.setInputFiles('input[type="file"]', []);`);
});
});
it('should download files', async ({ page, recorder, httpServer }) => {
it('should download files', async ({ page, recorder, httpServer }) => {
httpServer.setHandler((req: http.IncomingMessage, res: http.ServerResponse) => {
const pathName = url.parse(req.url!).path;
if (pathName === '/download') {
@ -440,9 +437,9 @@ it('should download files', async ({ page, recorder, httpServer }) => {
page.waitForEvent('download'),
page.click('text="Download"')
]);`);
});
});
it('should handle dialogs', async ({ page, recorder }) => {
it('should handle dialogs', async ({ page, recorder }) => {
await recorder.setContentAndWait(`
<button onclick="alert()">click me</button>
`);
@ -459,9 +456,9 @@ it('should handle dialogs', async ({ page, recorder }) => {
dialog.dismiss().catch(() => {});
});
await page.click('text="click me"')`);
});
});
it('should handle history.postData', async ({ page, recorder, httpServer }) => {
it('should handle history.postData', async ({ page, recorder, httpServer }) => {
httpServer.setHandler((req: http.IncomingMessage, res: http.ServerResponse) => {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end('Hello world');
@ -478,11 +475,11 @@ it('should handle history.postData', async ({ page, recorder, httpServer }) => {
await recorder.waitForOutput(`seqNum=${i}`);
expect(recorder.output()).toContain(`await page.goto('${httpServer.PREFIX}/#seqNum=${i}');`);
}
});
});
it('should record open in a new tab with url', (test, { browserName }) => {
it('should record open in a new tab with url', (test, { browserName }) => {
test.fixme(browserName === 'webkit', 'Ctrl+click does not open in new tab on WebKit');
}, async ({ page, recorder, browserName, platform }) => {
}, async ({ page, recorder, browserName, platform }) => {
await recorder.setContentAndWait(`<a href="about:blank?foo">link</a>`);
const selector = await recorder.hoverOverElement('a');
@ -505,11 +502,11 @@ it('should record open in a new tab with url', (test, { browserName }) => {
})
]);`);
}
});
});
it('should not clash pages', (test, { browserName }) => {
it('should not clash pages', (test, { browserName }) => {
test.fixme(browserName === 'firefox', 'Times out on Firefox, maybe the focus issue');
}, async ({ page, recorder }) => {
}, async ({ page, recorder }) => {
const [popup1] = await Promise.all([
page.context().waitForEvent('page'),
page.evaluate(`window.open('about:blank')`)
@ -530,9 +527,9 @@ it('should not clash pages', (test, { browserName }) => {
expect(recorder.output()).toContain(`await page1.fill('input[id="name"]', 'TextA');`);
expect(recorder.output()).toContain(`await page2.fill('input[id="name"]', 'TextB');`);
});
});
it('click should emit events in order', async ({ page, recorder }) => {
it('click should emit events in order', async ({ page, recorder }) => {
await recorder.setContentAndWait(`
<button id=button>
<script>
@ -549,33 +546,34 @@ it('click should emit events in order', async ({ page, recorder }) => {
recorder.waitForOutput('page.click')
]);
expect(messages).toEqual(['mousedown', 'mouseup', 'click']);
});
});
it('should update hover model on action', async ({ page, recorder }) => {
it('should update hover model on action', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="checkbox.name='updated'"></input>`);
const [ models ] = await Promise.all([
recorder.waitForActionPerformed(),
page.click('input')
]);
expect(models.hovered).toBe('input[name="updated"]');
});
});
it('should update active model on action', (test, { browserName, headful }) => {
it('should update active model on action', (test, { browserName, headful }) => {
test.fixme(browserName === 'webkit' && !headful);
test.fixme(browserName === 'firefox' && !headful);
}, async ({ page, recorder }) => {
}, async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="checkbox.name='updated'"></input>`);
const [ models ] = await Promise.all([
recorder.waitForActionPerformed(),
page.click('input')
]);
expect(models.active).toBe('input[name="updated"]');
});
});
it('should check input with chaning id', async ({ page, recorder }) => {
it('should check input with chaning id', async ({ page, recorder }) => {
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="checkbox.name = 'updated'"></input>`);
await Promise.all([
recorder.waitForActionPerformed(),
page.click('input[id=checkbox]')
]);
});
});