aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-07-28 10:37:00 +1000
committerYuchen Pei <hi@ypei.me>2022-07-28 10:37:00 +1000
commit395df086e12e62ae55ebc7012d94896ca8958394 (patch)
treeb1c4c2fd20d65c4de780a76b76204806b6204009
parent2bdf1e590b70724f80beb5702ebb05331973bbc9 (diff)
adding a test for contact finder
-rw-r--r--test/resources/index.html5
-rw-r--r--test/spec/LibreJSSpec.js16
2 files changed, 21 insertions, 0 deletions
diff --git a/test/resources/index.html b/test/resources/index.html
index c5f364c..a011c30 100644
--- a/test/resources/index.html
+++ b/test/resources/index.html
@@ -34,5 +34,10 @@
<script src="app-trilicensed.js"></script>
<script src="proprietary.js"></script>
<script src="tracker.js"></script>
+<div>
+ <a href="bar">About Us</a>
+ <a href="foo">Contact Us</a><span> at lib@re.js.</span>
+ <a href="quux">Website Feedback</a>
+</div>
</body>
</html>
diff --git a/test/spec/LibreJSSpec.js b/test/spec/LibreJSSpec.js
index aa5c167..1bb47ab 100644
--- a/test/spec/LibreJSSpec.js
+++ b/test/spec/LibreJSSpec.js
@@ -296,6 +296,22 @@ describe('LibreJS\' components', () => {
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'
+ })
+ console.log(frameBody);
+ expect(frameBody).not.toContain('About Us');
+ expect(frameBody).toContain('Contact Us');
+ expect(frameBody).toContain('Website Feedback');
+ expect(frameBody).toContain('lib@re.js');
+ done();
+ }, 200);
+ });
});
afterAll(async () => {