-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pptr+selenium: fixes clearValue and add shouldClear to control cleari…
…ng behavior
- Loading branch information
Showing
7 changed files
with
131 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
import { browser, $} from 'protractor'; | ||
import { browser, $ } from 'protractor'; | ||
import { SetupFn, runTestSuite, getTestAppUrl } from '@unidriver/test-suite'; | ||
import { protractorUniDriver } from '.'; | ||
import { assert } from 'chai'; | ||
|
||
import { port } from './protractor.conf'; | ||
|
||
const setup: SetupFn = async (data) => { | ||
await browser.get(`http://localhost:${port}${getTestAppUrl(data)}`); | ||
const driver = protractorUniDriver(() => Promise.resolve($('body'))); | ||
await browser.get(`http://localhost:${port}${getTestAppUrl(data)}`); | ||
const driver = protractorUniDriver(() => Promise.resolve($('body'))); | ||
const tearDown = async () => {}; | ||
return {driver, tearDown}; | ||
return { driver, tearDown }; | ||
}; | ||
|
||
describe('protractor', () => { | ||
|
||
runTestSuite({setup}); | ||
|
||
runTestSuite({ setup }); | ||
}); | ||
|
||
describe('protractor specific tests', () => { | ||
|
||
it(`doesn't attempt to clear value when shouldClear is false`, async () => { | ||
const { driver } = await setup({ items: [], initialText: 'hello' }); | ||
await driver | ||
.$('header input') | ||
.enterValue(' world!', { shouldClear: false }); | ||
assert.equal(await driver.$('header input').value(), 'hello world!'); | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,64 @@ | ||
import * as puppeteer from 'puppeteer'; | ||
import {Browser, Page} from 'puppeteer'; | ||
import {getTestAppUrl, startTestAppServer, SetupFn, runTestSuite} from '@unidriver/test-suite'; | ||
import {pupUniDriver} from './'; | ||
import {Server} from 'http'; | ||
import { Browser, Page } from 'puppeteer'; | ||
import { | ||
getTestAppUrl, | ||
startTestAppServer, | ||
SetupFn, | ||
runTestSuite, | ||
} from '@unidriver/test-suite'; | ||
import { pupUniDriver } from './'; | ||
import { Server } from 'http'; | ||
import { assert } from 'chai'; | ||
|
||
const port = require('find-free-port-sync')(); | ||
|
||
let server: Server; | ||
let browser: Browser; | ||
let page: Page; | ||
|
||
const before = async () => { | ||
const beforeFn = async () => { | ||
const args = process.env.CI ? ['--no-sandbox'] : []; | ||
const headless = !!process.env.CI; | ||
server = await startTestAppServer(port); | ||
browser = await puppeteer.launch({headless, args}); | ||
browser = await puppeteer.launch({ | ||
headless, | ||
args, | ||
}); | ||
page = await browser.newPage(); | ||
}; | ||
|
||
const after = async () => { | ||
const afterFn = async () => { | ||
server.close(); | ||
await page.close(); | ||
await browser.close(); | ||
}; | ||
|
||
const setup: SetupFn = async (params) => { | ||
await page.goto(`http://localhost:${port}${getTestAppUrl(params)}`); | ||
const driver = pupUniDriver({ | ||
page, | ||
selector: 'body' | ||
}); | ||
await page.goto(`http://localhost:${port}${getTestAppUrl(params)}`); | ||
const driver = pupUniDriver({ | ||
page, | ||
selector: 'body', | ||
}); | ||
|
||
const tearDown = async () => {}; | ||
const tearDown = async () => {}; | ||
|
||
return {driver, tearDown}; | ||
return { driver, tearDown }; | ||
}; | ||
|
||
describe('puppeteer', () => { | ||
runTestSuite({setup, before, after}); | ||
runTestSuite({ setup, before: beforeFn, after: afterFn }); | ||
}); | ||
|
||
describe('puppeteer specific tests', () => { | ||
|
||
before(beforeFn); | ||
after(afterFn); | ||
describe('enterValue', () => { | ||
it(`doesn't attempt to clear value when shouldClear is false`, async () => { | ||
const { driver } = await setup({ items: [], initialText: 'hello' }); | ||
await driver | ||
.$('header input') | ||
.enterValue(' world!', { shouldClear: false }); | ||
assert.equal(await driver.$('header input').value(), 'hello world!'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters