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

Side by Side Diff: test/wrappers/pages.js

Issue 29892560: Noissue - Moved subscription link test to separate test case (Closed)
Patch Set: Created Sept. 26, 2018, 11:31 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 driver.switchTo().window(goTo).then(() => 41 driver.switchTo().window(goTo).then(() =>
42 promiseFinally( 42 promiseFinally(
43 new Promise(resolve => resolve(callback && callback())), 43 new Promise(resolve => resolve(callback && callback())),
44 () => driver.close() 44 () => driver.close()
45 ) 45 )
46 ), 46 ),
47 () => driver.switchTo().window(returnTo) 47 () => driver.switchTo().window(returnTo)
48 ); 48 );
49 } 49 }
50 50
51 function testSubscribeLink(driver)
52 {
53 return driver.findElement(By.id("subscribe-button")).click().then(() =>
54 driver.wait(() =>
55 driver.getAllWindowHandles().then(handles =>
56 handles.length > 2 ? handles : null
57 ), 3000
58 )
59 ).then(handles =>
60 closeWindow(driver, handles[2], handles[1], () =>
61 driver.wait(until.ableToSwitchToFrame(0), 1000).then(() =>
62 driver.wait(until.elementLocated(By.id("dialog-content-predefined")),
63 1000)
64 ).then(dialog =>
65 Promise.all([
66 dialog.isDisplayed(),
67 dialog.findElement(By.css("h3")).getText()
68 ]).then(([displayed, title]) =>
69 {
70 assert.ok(displayed, "subscribe link: dialog shown");
71 assert.equal(title, "ABP Testcase Subscription",
72 "subscribe link: title shown in dialog");
73
74 return dialog.findElement(By.css("button")).click();
75 })
76 ).then(() =>
77 driver.executeAsyncScript(`
78 let callback = arguments[arguments.length - 1];
79 browser.runtime.sendMessage({type: "subscriptions.get",
80 ignoreDisabled: true,
81 downloadable: true}).then(subs =>
82 subs.some(s =>
83 s.url == "${TEST_PAGES_URL}abp-testcase-subscription.txt"
84 )
85 ).then(
86 res => callback([res, null]),
87 err => callback([null, err])
88 );
89 `)
90 ).then(([added, err]) =>
91 {
92 if (err)
93 throw err;
94 assert.ok(added, "subscribe link: subscription added");
95 })
96 )
97 );
98 }
99
100 function imageFromBase64(s) 51 function imageFromBase64(s)
101 { 52 {
102 return Jimp.read(Buffer.from(s, "base64")); 53 return Jimp.read(Buffer.from(s, "base64"));
103 } 54 }
104 55
105 function takeScreenshot(element) 56 function takeScreenshot(element)
106 { 57 {
107 return element.takeScreenshot().then( 58 return element.takeScreenshot().then(
108 imageFromBase64, 59 imageFromBase64,
109 60
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 99 }
149 100
150 it("test pages", function() 101 it("test pages", function()
151 { 102 {
152 return this.driver.navigate().to(TEST_PAGES_URL).then(() => 103 return this.driver.navigate().to(TEST_PAGES_URL).then(() =>
153 this.driver.findElements(By.css(".site-pagelist a")) 104 this.driver.findElements(By.css(".site-pagelist a"))
154 ).then(elements => 105 ).then(elements =>
155 Promise.all(elements.map(elem => elem.getAttribute("href"))) 106 Promise.all(elements.map(elem => elem.getAttribute("href")))
156 ).then(urls => 107 ).then(urls =>
157 { 108 {
158 let p1 = testSubscribeLink(this.driver); 109 let p1 = Promise.resolve();
159 for (let url of urls) 110 for (let url of urls)
160 p1 = p1.then(() => 111 p1 = p1.then(() =>
161 this.driver.navigate().to(url) 112 this.driver.navigate().to(url)
162 ).then(() => 113 ).then(() =>
163 Promise.all([ 114 Promise.all([
164 getSections(this.driver), 115 getSections(this.driver),
165 this.driver.findElement(By.css("h2")).getAttribute("textContent"), 116 this.driver.findElement(By.css("h2")).getAttribute("textContent"),
166 this.driver.executeScript("document.body.classList.add('expected');") 117 this.driver.executeScript("document.body.classList.add('expected');")
167 ]) 118 ])
168 ).then(([sections, pageTitle]) => 119 ).then(([sections, pageTitle]) =>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 title 196 title
246 ) 197 )
247 ); 198 );
248 }); 199 });
249 } 200 }
250 return p2; 201 return p2;
251 }); 202 });
252 return p1; 203 return p1;
253 }); 204 });
254 }); 205 });
206
207 it("subscribe link", function()
208 {
209 return this.driver.navigate().to(TEST_PAGES_URL).then(() =>
210 this.driver.findElement(By.id("subscribe-button")).click()
211 ).then(() =>
212 this.driver.wait(() =>
213 this.driver.getAllWindowHandles().then(handles =>
214 handles.length > 2 ? handles : null
215 ), 3000
216 )
217 ).then(handles =>
218 closeWindow(this.driver, handles[2], handles[1], () =>
219 this.driver.wait(until.ableToSwitchToFrame(0), 1000).then(() =>
220 this.driver.wait(
221 until.elementLocated(By.id("dialog-content-predefined")), 1000
222 )
223 ).then(dialog =>
224 Promise.all([
225 dialog.isDisplayed(),
226 dialog.findElement(By.css("h3")).getText()
227 ]).then(([displayed, title]) =>
228 {
229 assert.ok(displayed, "dialog shown");
230 assert.equal(title, "ABP Testcase Subscription", "title matches");
231
232 return dialog.findElement(By.css("button")).click();
233 })
234 ).then(() =>
235 this.driver.executeAsyncScript(`
236 let callback = arguments[arguments.length - 1];
237 browser.runtime.sendMessage({type: "subscriptions.get",
238 ignoreDisabled: true,
239 downloadable: true}).then(subs =>
240 subs.some(s =>
241 s.url == "${TEST_PAGES_URL}abp-testcase-subscription.txt"
242 )
243 ).then(
244 res => callback([res, null]),
245 err => callback([null, err])
246 );
247 `)
248 ).then(([added, err]) =>
249 {
250 if (err)
251 throw err;
252 assert.ok(added, "subscription added");
253 })
254 )
255 );
256 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld