-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
330 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"tests": "./test/*_scenario.js", | ||
"timeout": 10000, | ||
"output": "./output", | ||
"helpers": { | ||
"Puppeteer": { | ||
"url": "http://localhost:5000/test" | ||
} | ||
}, | ||
"include": {}, | ||
"bootstrap": false, | ||
"mocha": {}, | ||
"name": "vue-the-mask" | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
assert = require('assert') | ||
|
||
async function assertCursorAt(I, input, expectedPosition) { | ||
let position = await I.grabAttributeFrom(input, 'selectionEnd') | ||
return assert.equal(position, expectedPosition + 1) | ||
} | ||
|
||
Feature('Keyboard') | ||
|
||
Scenario('Cursor Position', async I => { | ||
I.amOnPage('/') | ||
I.fillField('#input', '012') | ||
I.seeInField('#input', '+1 01.2') | ||
I.pressKey('ArrowLeft') | ||
I.pressKey('9') | ||
I.seeInField('#input', '+1 01.92') | ||
I.pressKey('8') | ||
I.seeInField('#input', '+1 01.98.2') | ||
I.seeInField('#cursor', '8') | ||
// assertCursorAt(I, '#input', 8) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const puppeteer = require('puppeteer') | ||
;(async () => { | ||
const browser = await puppeteer.launch({ headless: true }) | ||
const page = await browser.newPage() | ||
|
||
// Define a window.onCustomEvent function on the page. | ||
page.on('console', msg => console.log(msg.text())) | ||
|
||
await page.exposeFunction('onCustomEvent', e => { | ||
console.log(`${e.type} fired`, e.detail || '') | ||
}) | ||
|
||
/** | ||
* Attach an event listener to page to capture a custom event on page load/navigation. | ||
* @param {string} type Event name. | ||
* @return {!Promise} | ||
*/ | ||
function listenFor(type) { | ||
return page.evaluateOnNewDocument(type => { | ||
document.addEventListener(type, e => { | ||
window.onCustomEvent({ type, detail: e.detail }) | ||
}) | ||
}, type) | ||
} | ||
|
||
await listenFor('app-ready') // Listen for "app-ready" custom event on page load. | ||
|
||
await page.goto('http://localhost:5000/test/', { | ||
waitUntil: 'networkidle2' | ||
}) | ||
|
||
await page.type('#input', '0123') | ||
await page.keyboard.press('ArrowLeft') | ||
await page.keyboard.press('ArrowLeft') | ||
await page.keyboard.press('Backspace') | ||
await page.keyboard.press('Backspace') | ||
await page.type('#input', '98') | ||
await page.$eval('#input', input => | ||
console.log(input.value, input.selectionEnd) | ||
) | ||
await browser.close() | ||
})() |
Oops, something went wrong.