diff options
author | Yuchen Pei <hi@ypei.me> | 2022-09-27 09:38:22 +1000 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-09-27 09:38:22 +1000 |
commit | db0013b57cce91cd516e0d9ecfa6f758f3d14d03 (patch) | |
tree | 5b0b3b159951f7c9f43fbf0e4e313e638289b376 | |
parent | 313633d1b84efa6d171c69cae0297f24f8f2931f (diff) |
disable contactfinder tests by default
It tends to time out. Also moved injectContactFinder
-rw-r--r-- | main_background.js | 21 | ||||
-rw-r--r-- | test/spec/LibreJSSpec.js | 59 |
2 files changed, 41 insertions, 39 deletions
diff --git a/main_background.js b/main_background.js index c983f2f..76cc8c4 100644 --- a/main_background.js +++ b/main_background.js @@ -322,6 +322,16 @@ async function connected(p) { } /** +* Loads the contact finder on the given tab ID. +*/ +async function injectContactFinder(tabId) { + await Promise.all([ + browser.tabs.insertCSS(tabId, { file: '/content/overlay.css', cssOrigin: 'user' }), + browser.tabs.executeScript(tabId, { file: '/content/contactFinder.js' }), + ]); +} + +/** * The callback for tab closings. * * Delete the info we are storing about this tab if there is any. @@ -890,15 +900,4 @@ async function init_addon() { } } - -/** -* Loads the contact finder on the given tab ID. -*/ -async function injectContactFinder(tabId) { - await Promise.all([ - browser.tabs.insertCSS(tabId, { file: '/content/overlay.css', cssOrigin: 'user' }), - browser.tabs.executeScript(tabId, { file: '/content/contactFinder.js' }), - ]); -} - init_addon(); diff --git a/test/spec/LibreJSSpec.js b/test/spec/LibreJSSpec.js index 62a44a0..77563d2 100644 --- a/test/spec/LibreJSSpec.js +++ b/test/spec/LibreJSSpec.js @@ -44,6 +44,7 @@ describe('LibreJS\' components', () => { let unknownLicensed = `// @license ${unknownLicense.magnet} ${unknownLicense.id}\n${nontrivial}\n// @license-end`; let malformedLicensed = `// @license\n${nontrivial}`; let tab, documentUrl; + const enableContactFinderTests = false; beforeAll(async () => { let url = browser.extension.getURL('/test/resources/index.html'); @@ -291,35 +292,37 @@ describe('LibreJS\' components', () => { }); }); - describe('The contact finder', () => { - it('should display the contact finder iframe', async (done) => { - await browser.runtime.connect({ name: "port-from-cs" }).postMessage({ invoke_contact_finder: 1 }); - // Direct await / async does not work as executeScript does not wait - // for the listener - setTimeout(async () => { - const frame = await browser.tabs.executeScript(tab.id, { - code: 'document.getElementById("_LibreJS_frame").outerHTML' - }) - expect(frame).toBeTruthy(); - done(); - }, 100); - }); - it('should display the correct contact info in the contact finder iframe', async (done) => { - await browser.runtime.connect({ name: "port-from-cs" }).postMessage({ invoke_contact_finder: 1 }); - // Direct await / async does not work as executeScript does not wait - // for the listener - setTimeout(async () => { - const [frameBody] = await browser.tabs.executeScript(tab.id, { - code: 'document.getElementById("_LibreJS_frame").contentWindow.document.body.innerHTML' - }); - expect(frameBody).not.toContain('About Us'); - expect(frameBody).toContain('Contact Us'); - expect(frameBody).toContain('Website Feedback'); - expect(frameBody).toContain('lib@re.js'); - done(); - }, 200); + if (enableContactFinderTests) { + describe('The contact finder', () => { + it('should display the contact finder iframe', async (done) => { + await browser.runtime.connect({ name: "port-from-cs" }).postMessage({ invoke_contact_finder: 1 }); + // Direct await / async does not work as executeScript does not wait + // for the listener + setTimeout(async () => { + const frame = await browser.tabs.executeScript(tab.id, { + code: 'document.getElementById("_LibreJS_frame").outerHTML' + }) + expect(frame).toBeTruthy(); + done(); + }, 100); + }); + it('should display the correct contact info in the contact finder iframe', async (done) => { + await browser.runtime.connect({ name: "port-from-cs" }).postMessage({ invoke_contact_finder: 1 }); + // Direct await / async does not work as executeScript does not wait + // for the listener + setTimeout(async () => { + const [frameBody] = await browser.tabs.executeScript(tab.id, { + code: 'document.getElementById("_LibreJS_frame").contentWindow.document.body.innerHTML' + }); + expect(frameBody).not.toContain('About Us'); + expect(frameBody).toContain('Contact Us'); + expect(frameBody).toContain('Website Feedback'); + expect(frameBody).toContain('lib@re.js'); + done(); + }, 200); + }); }); - }); + } describe('The prefs', () => { it('should have the defaults', async () => { |