Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: test/firefox.js

Issue 29864561: Issue 6884 - Migrate from nodeunit to mocha (Closed)
Left Patch Set: Created Aug. 25, 2018, 5 p.m.
Right Patch Set: Inline reportElements() for better code locality Created Aug. 26, 2018, 7:09 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « package.json ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return driver.wait(() => 62 return driver.wait(() =>
63 driver.getAllWindowHandles().then(handles => handles[1]) 63 driver.getAllWindowHandles().then(handles => handles[1])
64 ).then(handle => 64 ).then(handle =>
65 driver.switchTo().window(handle) 65 driver.switchTo().window(handle)
66 ).then(() => 66 ).then(() =>
67 driver.executeScript("return location.origin;") 67 driver.executeScript("return location.origin;")
68 ).then(result => { origin = result; }); 68 ).then(result => { origin = result; });
69 }) 69 })
70 ); 70 );
71 71
72 after(() => driver.quit());
tlucas 2018/08/26 15:10:51 Nit: IMHO this should go after it(), to reflect th
Sebastian Noack 2018/08/26 19:02:00 Done. Though one could argue the other way around
73
74 function reportElements(success)
75 {
76 return driver.findElements(
77 By.css(`#qunit-tests ${success ? ".pass" : ".fail"} .test-name`)
78 ).then(elements => Promise.all(elements.map(elem =>
79 elem.getAttribute("innerHTML").then(data => assert.ok(success, data))
80 )));
81 }
82
83 it("qunit", () => 72 it("qunit", () =>
84 driver.navigate().to(origin + "/qunit/index.html").then(() => 73 driver.navigate().to(origin + "/qunit/index.html").then(() =>
tlucas 2018/08/26 15:10:51 Just FMI, why do you deem this more appropriate th
Sebastian Noack 2018/08/26 15:42:18 I need the extension URL prefix for the tests I'm
tlucas 2018/08/26 21:13:50 Thanks for clarifying.
85 // Wait for qunit-results to be present 74 // Wait for qunit-results to be present
86 driver.wait(until.elementLocated(By.id("qunit-testresult"))) 75 driver.wait(until.elementLocated(By.id("qunit-testresult")))
87 ).then(() => 76 ).then(() =>
88 // Wait for tests to finish 77 // Wait for tests to finish
89 driver.wait(() => 78 driver.wait(() =>
90 driver.findElement(By.id("qunit-testresult")) 79 driver.findElement(By.id("qunit-testresult"))
91 .getAttribute("innerHTML").then(data => 80 .getAttribute("innerHTML").then(data =>
92 data.includes("Tests completed"))) 81 data.includes("Tests completed")))
93 ).then(() => Promise.all([ 82 ).then(() => Promise.all([[true, ".pass"], [false, ".fail"]].map(
94 reportElements(true), 83 ([success, sel]) => driver.findElements(
95 reportElements(false) 84 By.css(`#qunit-tests ${sel} .test-name`)
96 ])) 85 ).then(elements => Promise.all(elements.map(elem =>
86 elem.getAttribute("textContent").then(data => assert.ok(success, data))
87 )))
88 )))
97 ); 89 );
90
91 after(() => driver.quit());
98 }); 92 });
LEFTRIGHT
« package.json ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld