From 9002e3b3a2a3c5724e1851b8fc35020f91818ddd Mon Sep 17 00:00:00 2001 From: Kendall Werts Date: Tue, 25 Feb 2020 14:34:33 -0600 Subject: [PATCH] All tests work except the confirm page test --- src/js/popup.js | 8 -------- test/common.js | 8 ++++++++ test/features/assignment.test.js | 8 ++++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/js/popup.js b/src/js/popup.js index ea3eb44..9291eb5 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -534,7 +534,6 @@ Logic.registerPanel(P_CONTAINERS_LIST, { async initialize() { Utils.addEnterHandler(document.querySelector("#manage-containers-link"), (e) => { if (!e.target.classList.contains("disable-edit-containers")) { - console.log("manage clicked") Logic.showPanel(MANAGE_CONTAINERS_PICKER); } }); @@ -545,7 +544,6 @@ Logic.registerPanel(P_CONTAINERS_LIST, { Logic.showPanel(REOPEN_IN_CONTAINER_PICKER); }); Utils.addEnterHandler(document.querySelector("#always-open-in"), () => { - console.log("clicked always-open-in"); Logic.showPanel(ALWAYS_OPEN_IN_PICKER); }); Utils.addEnterHandler(document.querySelector("#info-icon"), () => { @@ -942,7 +940,6 @@ Logic.registerPanel(MANAGE_CONTAINERS_PICKER, { `; Utils.addEnterHandler(document.querySelector("#new-container"), () => { - console.log("new-container-clicked") Logic.showPanel(P_CONTAINER_EDIT, { name: Logic.generateIdentityName() }); }); @@ -966,7 +963,6 @@ Logic.registerPanel(MANAGE_CONTAINERS_PICKER, { tr.appendChild(td); Utils.addEnterHandler(tr, () => { - console.log("manage indentity:", identity) pickedFunction(identity); }); }); @@ -996,7 +992,6 @@ Logic.registerPanel(REOPEN_IN_CONTAINER_PICKER, { document.getElementById("picker-title").textContent = "Reopen This Site in"; const fragment = document.createDocumentFragment(); const currentTab = await Utils.currentTab(); - console.log("currentTab",currentTab); const pickedFunction = function (identity) { const newUserContextId = Utils.userContextId(identity.cookieStoreId); Utils.reloadInContainer( @@ -1112,7 +1107,6 @@ Logic.registerPanel(ALWAYS_OPEN_IN_PICKER, { tr.appendChild(td); Utils.addEnterHandler(tr, () => { - console.log("clicked"); Utils.alwaysOpenInContainer(identity); window.close(); }); @@ -1310,7 +1304,6 @@ Logic.registerPanel(P_CONTAINER_EDIT, { const deleteButton = document.getElementById("delete-container-button"); Utils.addEnterHandler(deleteButton, () => { - console.log("delete button clicked") Logic.showPanel(P_CONTAINER_DELETE, identity); }); return Promise.resolve(null); @@ -1333,7 +1326,6 @@ Logic.registerPanel(P_CONTAINER_DELETE, { Logic.showPreviousPanel(); }); Utils.addEnterHandler(document.querySelector("#delete-container-ok-link"), async () => { - console.log("delete ok clicked", Logic.currentIdentity().cookieStoreId) /* This promise wont resolve if the last tab was removed from the window. as the message async callback stops listening, this isn't an issue for us however it might be in future if you want to do anything post delete do it in the background script. diff --git a/test/common.js b/test/common.js index 8640afa..9f01b02 100644 --- a/test/common.js +++ b/test/common.js @@ -70,6 +70,13 @@ const buildPopupDom = popup => { }); }; +const buildConfirmPage = async (url) => { + const webExtension = await webExtensionsJSDOM.fromFile(url); + + webExtension.browser.runtime.onMessage = window.browser.runtime.sendMessage; + return webExtension; +}; + const initializeWithTab = async (details = { cookieStoreId: "firefox-default" }) => { @@ -108,4 +115,5 @@ module.exports = { sinon, expect, nextTick, + buildConfirmPage }; \ No newline at end of file diff --git a/test/features/assignment.test.js b/test/features/assignment.test.js index 2ab858b..ebb38dd 100644 --- a/test/features/assignment.test.js +++ b/test/features/assignment.test.js @@ -1,4 +1,5 @@ const {initializeWithTab} = require("../common"); +const {buildConfirmPage} = require("../common"); describe("Assignment Reopen Feature", function () { const url = "http://example.com"; @@ -88,8 +89,11 @@ describe("Assignment Comfirm Page Feature", function () { describe("Set assignment to 'never ask' ", function () { beforeEach(async function () { // click confirm page to always open in container - await this.webExt.document.getElementById("never-ask").click(); - await this.webExt.document.getElementById("confirm").click(); + const confirmPage = await buildConfirmPage("moz-extension://fake/confirm-page.html?" + + `url=${encodeURIComponent(url)}` + + `&cookieStoreId=${this.webExt.tab.cookieStoreId}`); + await confirmPage.document.getElementById("never-ask").click(); + await confirmPage.document.getElementById("confirm").click(); }); describe("open new Tab with url set to 'never ask' ", function () {