Merge pull request #12724 from calixteman/follow-up-12707
Follow-up of #12707: Add an integration test for checkboxes as radio …
This commit is contained in:
		
						commit
						640a08444c
					
				| @ -13,49 +13,72 @@ | |||||||
|  * limitations under the License. |  * limitations under the License. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | const { closePages, loadAndWait } = require("./test_utils.js"); | ||||||
|  | 
 | ||||||
| describe("Annotation highlight", () => { | describe("Annotation highlight", () => { | ||||||
|   describe("annotation-highlight.pdf", () => { |   describe("annotation-highlight.pdf", () => { | ||||||
|     let pages; |     let pages; | ||||||
| 
 | 
 | ||||||
|     beforeAll(async () => { |     beforeAll(async () => { | ||||||
|       pages = await Promise.all( |       pages = await loadAndWait( | ||||||
|         global.integrationSessions.map(async session => { |         "annotation-highlight.pdf", | ||||||
|           const page = await session.browser.newPage(); |         "[data-annotation-id='19R']" | ||||||
|           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 () => { |     afterAll(async () => { | ||||||
|       await Promise.all( |       await closePages(pages); | ||||||
|         pages.map(async page => { |  | ||||||
|           await page.close(); |  | ||||||
|         }) |  | ||||||
|       ); |  | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it("must show a popup on mouseover", async () => { |     it("must show a popup on mouseover", async () => { | ||||||
|       await Promise.all( |       await Promise.all( | ||||||
|         pages.map(async page => { |         pages.map(async ([browserName, page]) => { | ||||||
|           let hidden = await page.$eval( |           let hidden = await page.$eval( | ||||||
|             "[data-annotation-id='21R']", |             "[data-annotation-id='21R']", | ||||||
|             el => el.hidden |             el => el.hidden | ||||||
|           ); |           ); | ||||||
|           expect(hidden).toEqual(true); |           expect(hidden).withContext(`In ${browserName}`).toEqual(true); | ||||||
|           await page.hover("[data-annotation-id='19R']"); |           await page.hover("[data-annotation-id='19R']"); | ||||||
|           await page.waitForTimeout(100); |           await page.waitForTimeout(100); | ||||||
|           hidden = await page.$eval( |           hidden = await page.$eval( | ||||||
|             "[data-annotation-id='21R']", |             "[data-annotation-id='21R']", | ||||||
|             el => el.hidden |             el => el.hidden | ||||||
|           ); |           ); | ||||||
|           expect(hidden).toEqual(false); |           expect(hidden).withContext(`In ${browserName}`).toEqual(false); | ||||||
|  |         }) | ||||||
|  |       ); | ||||||
|  |     }); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | describe("Checkbox annotation", () => { | ||||||
|  |   describe("issue12706.pdf", () => { | ||||||
|  |     let pages; | ||||||
|  | 
 | ||||||
|  |     beforeAll(async () => { | ||||||
|  |       pages = await loadAndWait("issue12706.pdf", "[data-annotation-id='63R']"); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     afterAll(async () => { | ||||||
|  |       await closePages(pages); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("must let checkboxes with the same name behave like radio buttons", async () => { | ||||||
|  |       const selectors = [63, 70, 79].map(n => `[data-annotation-id='${n}R']`); | ||||||
|  |       await Promise.all( | ||||||
|  |         pages.map(async ([browserName, page]) => { | ||||||
|  |           for (const selector of selectors) { | ||||||
|  |             await page.click(selector); | ||||||
|  |             for (const otherSelector of selectors) { | ||||||
|  |               const checked = await page.$eval( | ||||||
|  |                 `${otherSelector} > :first-child`, | ||||||
|  |                 el => el.checked | ||||||
|  |               ); | ||||||
|  |               expect(checked) | ||||||
|  |                 .withContext(`In ${browserName}`) | ||||||
|  |                 .toBe(selector === otherSelector); | ||||||
|  |             } | ||||||
|  |           } | ||||||
|         }) |         }) | ||||||
|       ); |       ); | ||||||
|     }); |     }); | ||||||
|  | |||||||
| @ -13,52 +13,38 @@ | |||||||
|  * limitations under the License. |  * limitations under the License. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | const { closePages, loadAndWait } = require("./test_utils.js"); | ||||||
|  | 
 | ||||||
| describe("Interaction", () => { | describe("Interaction", () => { | ||||||
|   describe("in 160F-2019.pdf", () => { |   describe("in 160F-2019.pdf", () => { | ||||||
|     let pages; |     let pages; | ||||||
| 
 | 
 | ||||||
|     beforeAll(async () => { |     beforeAll(async () => { | ||||||
|       pages = await Promise.all( |       pages = await loadAndWait("160F-2019.pdf", "#\\34 16R"); | ||||||
|         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 () => { |     afterAll(async () => { | ||||||
|       await Promise.all( |       await closePages(pages); | ||||||
|         pages.map(async ([_, page]) => { |  | ||||||
|           await page.close(); |  | ||||||
|         }) |  | ||||||
|       ); |  | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it("must format the field with 2 digits and leave field with a click", async () => { |     it("must format the field with 2 digits and leave field with a click", async () => { | ||||||
|       await Promise.all( |       await Promise.all( | ||||||
|         pages.map(async ([name, page]) => { |         pages.map(async ([browserName, page]) => { | ||||||
|           await page.type("#\\34 16R", "3.14159", { delay: 200 }); |           await page.type("#\\34 16R", "3.14159", { delay: 200 }); | ||||||
|           await page.click("#\\34 19R"); |           await page.click("#\\34 19R"); | ||||||
|           const text = await page.$eval("#\\34 16R", el => el.value); |           const text = await page.$eval("#\\34 16R", el => el.value); | ||||||
|           expect(text).withContext(`In ${name}`).toEqual("3,14"); |           expect(text).withContext(`In ${browserName}`).toEqual("3,14"); | ||||||
|         }) |         }) | ||||||
|       ); |       ); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it("must format the field with 2 digits and leave field with a TAB", async () => { |     it("must format the field with 2 digits and leave field with a TAB", async () => { | ||||||
|       await Promise.all( |       await Promise.all( | ||||||
|         pages.map(async ([name, page]) => { |         pages.map(async ([browserName, page]) => { | ||||||
|           await page.type("#\\34 22R", "2.7182818", { delay: 200 }); |           await page.type("#\\34 22R", "2.7182818", { delay: 200 }); | ||||||
|           await page.keyboard.press("Tab"); |           await page.keyboard.press("Tab"); | ||||||
|           const text = await page.$eval("#\\34 22R", el => el.value); |           const text = await page.$eval("#\\34 22R", el => el.value); | ||||||
|           expect(text).withContext(`In ${name}`).toEqual("2,72"); |           expect(text).withContext(`In ${browserName}`).toEqual("2,72"); | ||||||
|         }) |         }) | ||||||
|       ); |       ); | ||||||
|     }); |     }); | ||||||
|  | |||||||
							
								
								
									
										36
									
								
								test/integration/test_utils.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								test/integration/test_utils.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | |||||||
|  | /* 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. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | exports.loadAndWait = (filename, selector) => | ||||||
|  |   Promise.all( | ||||||
|  |     global.integrationSessions.map(async session => { | ||||||
|  |       const page = await session.browser.newPage(); | ||||||
|  |       await page.goto( | ||||||
|  |         `${global.integrationBaseUrl}?file=/test/pdfs/${filename}` | ||||||
|  |       ); | ||||||
|  |       await page.bringToFront(); | ||||||
|  |       await page.waitForSelector(selector, { | ||||||
|  |         timeout: 0, | ||||||
|  |       }); | ||||||
|  |       return [session.name, page]; | ||||||
|  |     }) | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  | exports.closePages = pages => | ||||||
|  |   Promise.all( | ||||||
|  |     pages.map(async ([_, page]) => { | ||||||
|  |       await page.close(); | ||||||
|  |     }) | ||||||
|  |   ); | ||||||
							
								
								
									
										1
									
								
								test/pdfs/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								test/pdfs/.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -331,6 +331,7 @@ | |||||||
| !issue5334.pdf | !issue5334.pdf | ||||||
| !annotation-caret-ink.pdf | !annotation-caret-ink.pdf | ||||||
| !bug1186827.pdf | !bug1186827.pdf | ||||||
|  | !issue12706.pdf | ||||||
| !issue215.pdf | !issue215.pdf | ||||||
| !issue5044.pdf | !issue5044.pdf | ||||||
| !issue1512r.pdf | !issue1512r.pdf | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								test/pdfs/issue12706.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								test/pdfs/issue12706.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user