Fix bug when slide number >= 10
This commit is contained in:
		
							parent
							
								
									87b0111915
								
							
						
					
					
						commit
						51a0f26d97
					
				
							
								
								
									
										26
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								index.js
									
									
									
									
									
								
							| @ -235,7 +235,14 @@ async function main() { | ||||
| 
 | ||||
|     for (let pageIndex = 1;; pageIndex++) { | ||||
| 
 | ||||
|         let root = await page.$('#\\3' + pageIndex); | ||||
|         let pageIndexStr = "" + pageIndex; | ||||
| 
 | ||||
|         let pageId = ""; | ||||
|         for (let c of pageIndexStr) { | ||||
|             pageId += "\\3" + c; | ||||
|         } | ||||
| 
 | ||||
|         let root = await page.$('#' + pageId); | ||||
|         if (root === null) { | ||||
|             break; | ||||
|         } | ||||
| @ -264,16 +271,19 @@ async function main() { | ||||
|         await page.screenshot({path: (outputDir === null ? __dirname : outputDir) + '/' + 'screenshot2.png'}); | ||||
| 
 | ||||
|         // Compare both screenshots
 | ||||
|         let file1 = await fs.readFile(__dirname + '/' + 'screenshot1.png'); | ||||
|         let file2 = await fs.readFile(__dirname + '/' + 'screenshot2.png'); | ||||
|         let file1 = await fs.readFile((outputDir === null ? __dirname : outputDir) + '/' + 'screenshot1.png'); | ||||
|         let file2 = await fs.readFile((outputDir === null ? __dirname : outputDir) + '/' + 'screenshot2.png'); | ||||
|         let filesAreSame = file1.map((x, i) => x === file2[i]).reduce((a, b) => a && b, true); | ||||
| 
 | ||||
|         if (!filesAreSame) { | ||||
|             // Check psnr
 | ||||
|             let psnr = await image.psnr(__dirname + '/' + 'screenshot1.png', __dirname + '/' + 'screenshot2.png'); | ||||
|             let psnr = await image.psnr( | ||||
|                 (outputDir === null ? __dirname : outputDir) + '/' + 'screenshot1.png', | ||||
|                 (outputDir === null ? __dirname : outputDir) + '/' + 'screenshot2.png' | ||||
|             ); | ||||
| 
 | ||||
|             // Crash if they're different
 | ||||
|             if (psnr > 70) { | ||||
|             if (psnr > 0) { | ||||
|                 warning(filename + " produced slight diff: psnr = " + psnr); | ||||
|             } else { | ||||
|                 await error("page edit changed the layout: psnr = " + psnr); | ||||
| @ -370,10 +380,12 @@ async function analyseElement(element, page, outputDir = null, threshold = undef | ||||
|     analyse.class = className; | ||||
| 
 | ||||
|     analyse.box = box; | ||||
|     if (box !== null) { | ||||
|         box.x /= size.width; | ||||
|         box.width /= size.width; | ||||
|         box.y /= size.height; | ||||
|         box.height /= size.height; | ||||
|     } | ||||
| 
 | ||||
|     if (outputDir !== null) { | ||||
|         analyse.uuid = uuid(); | ||||
| @ -412,6 +424,8 @@ async function analyseElement(element, page, outputDir = null, threshold = undef | ||||
|         analyse.text = textContent; | ||||
|     } | ||||
| 
 | ||||
|     if (tagName !== "svg") { | ||||
| 
 | ||||
|         // Select the children of this HTML element.
 | ||||
|         let children = await element.$$('> *'); | ||||
| 
 | ||||
| @ -420,6 +434,8 @@ async function analyseElement(element, page, outputDir = null, threshold = undef | ||||
|             analyse.children.push(await analyseElement(child, page, outputDir, threshold)); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     return analyse; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user