-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some integration tests using puppeteer and Jasmine
* run with `gulp integrationtest`
- Loading branch information
1 parent
b194c82
commit cfe554f
Showing
6 changed files
with
301 additions
and
34 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* Copyright 2020 Mozilla Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
"use strict"; | ||
|
||
const Jasmine = require("jasmine"); | ||
|
||
async function runTests(results) { | ||
const jasmine = new Jasmine(); | ||
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; | ||
|
||
jasmine.loadConfig({ | ||
random: false, | ||
spec_dir: "integration", | ||
spec_files: ["scripting_spec.js", "annotation_spec.js"], | ||
}); | ||
|
||
jasmine.addReporter({ | ||
jasmineDone(suiteInfo) {}, | ||
jasmineStarted(suiteInfo) {}, | ||
specDone(result) { | ||
++results.runs; | ||
if (result.failedExpectations.length > 0) { | ||
++results.failures; | ||
console.log(`TEST-UNEXPECTED-FAIL | ${result.description}`); | ||
} else { | ||
console.log(`TEST-PASSED | ${result.description}`); | ||
} | ||
}, | ||
specStarted(result) {}, | ||
suiteDone(result) {}, | ||
suiteStarted(result) {}, | ||
}); | ||
|
||
return new Promise(resolve => { | ||
jasmine.onComplete(resolve); | ||
jasmine.execute(); | ||
}); | ||
} | ||
|
||
exports.runTests = runTests; |
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,63 @@ | ||
/* Copyright 2020 Mozilla Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
describe("Annotation highlight", () => { | ||
describe("annotation-highlight.pdf", () => { | ||
let pages; | ||
|
||
beforeAll(async () => { | ||
pages = await Promise.all( | ||
global.integrationSessions.map(async session => { | ||
const page = await session.browser.newPage(); | ||
await page.goto( | ||
`${global.integrationBaseUrl}?file=/test/pdfs/annotation-highlight.pdf` | ||
); | ||
await page.bringToFront(); | ||
await page.waitForSelector("[data-annotation-id='19R']", { | ||
timeout: 0, | ||
}); | ||
return page; | ||
}) | ||
); | ||
}); | ||
|
||
afterAll(async () => { | ||
await Promise.all( | ||
pages.map(async page => { | ||
await page.close(); | ||
}) | ||
); | ||
}); | ||
|
||
it("must show a popup on mouseover", async () => { | ||
await Promise.all( | ||
pages.map(async page => { | ||
let hidden = await page.$eval( | ||
"[data-annotation-id='21R']", | ||
el => el.hidden | ||
); | ||
expect(hidden).toEqual(true); | ||
await page.hover("[data-annotation-id='19R']"); | ||
await page.waitForTimeout(100); | ||
hidden = await page.$eval( | ||
"[data-annotation-id='21R']", | ||
el => el.hidden | ||
); | ||
expect(hidden).toEqual(false); | ||
}) | ||
); | ||
}); | ||
}); | ||
}); |
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,66 @@ | ||
/* Copyright 2020 Mozilla Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
describe("Interaction", () => { | ||
describe("in 160F-2019.pdf", () => { | ||
let pages; | ||
|
||
beforeAll(async () => { | ||
pages = await Promise.all( | ||
global.integrationSessions.map(async session => { | ||
const page = await session.browser.newPage(); | ||
await page.goto( | ||
`${global.integrationBaseUrl}?file=/test/pdfs/160F-2019.pdf` | ||
); | ||
await page.bringToFront(); | ||
await page.waitForSelector("#\\34 16R", { | ||
timeout: 0, | ||
}); | ||
return [session.name, page]; | ||
}) | ||
); | ||
}); | ||
|
||
afterAll(async () => { | ||
await Promise.all( | ||
pages.map(async ([_, page]) => { | ||
await page.close(); | ||
}) | ||
); | ||
}); | ||
|
||
it("must format the field with 2 digits and leave field with a click", async () => { | ||
await Promise.all( | ||
pages.map(async ([name, page]) => { | ||
await page.type("#\\34 16R", "3.14159", { delay: 200 }); | ||
await page.click("#\\34 19R"); | ||
const text = await page.$eval("#\\34 16R", el => el.value); | ||
expect(text).withContext(`In ${name}`).toEqual("3,14"); | ||
}) | ||
); | ||
}); | ||
|
||
it("must format the field with 2 digits and leave field with a TAB", async () => { | ||
await Promise.all( | ||
pages.map(async ([name, page]) => { | ||
await page.type("#\\34 22R", "2.7182818", { delay: 200 }); | ||
await page.keyboard.press("Tab"); | ||
const text = await page.$eval("#\\34 22R", el => el.value); | ||
expect(text).withContext(`In ${name}`).toEqual("2,72"); | ||
}) | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.