working on mocha tests

This commit is contained in:
Kendall Werts 2020-02-24 16:14:17 -06:00
parent 88062b32b4
commit a66cdbf0bd
8 changed files with 31 additions and 17 deletions

View file

@ -11,7 +11,7 @@ const messageHandler = {
switch (m.method) {
case "getShortcuts":
console.log(identityState.keyboardShortcut);
console.log("getShortcuts", identityState.keyboardShortcut);
response = identityState.keyboardShortcut;
break;
case "setShortcut":
@ -91,7 +91,7 @@ const messageHandler = {
);
break;
}
console.log(response);
console.log(m.method, "response", response);
return response;
});

View file

@ -39,8 +39,8 @@ async function setupOptions() {
}
async function setupContainerShortcutSelects () {
const keyboardShortcut = browser.runtime.sendMessage({method: "getShortcuts"});
console.log(keyboardShortcut);
const keyboardShortcut = await browser.runtime.sendMessage({method: "getShortcuts"});
// console.log(keyboardShortcut);
const identities = await browser.contextualIdentities.query({});
const fragment = document.createDocumentFragment();
const noneOption = document.createElement("option");

View file

@ -534,6 +534,7 @@ 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);
}
});
@ -544,6 +545,7 @@ 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"), () => {
@ -940,6 +942,7 @@ Logic.registerPanel(MANAGE_CONTAINERS_PICKER, {
`;
Utils.addEnterHandler(document.querySelector("#new-container"), () => {
console.log("new-container-clicked")
Logic.showPanel(P_CONTAINER_EDIT, { name: Logic.generateIdentityName() });
});
@ -963,6 +966,7 @@ Logic.registerPanel(MANAGE_CONTAINERS_PICKER, {
tr.appendChild(td);
Utils.addEnterHandler(tr, () => {
console.log("manage indentity:", identity)
pickedFunction(identity);
});
});
@ -992,7 +996,7 @@ 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);
console.log("currentTab",currentTab);
const pickedFunction = function (identity) {
const newUserContextId = Utils.userContextId(identity.cookieStoreId);
Utils.reloadInContainer(
@ -1108,6 +1112,7 @@ Logic.registerPanel(ALWAYS_OPEN_IN_PICKER, {
tr.appendChild(td);
Utils.addEnterHandler(tr, () => {
console.log("clicked");
Utils.alwaysOpenInContainer(identity);
window.close();
});
@ -1305,6 +1310,7 @@ 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);
@ -1327,6 +1333,7 @@ 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.

View file

@ -71,7 +71,7 @@
"default_icon": "img/multiaccountcontainer-16.svg",
"default_title": "Always open this in a Container",
"default_popup": "pageActionPopup.html",
"pinned": true,
"pinned": false,
"show_matches": ["*://*/*"]
},
"background": {

View file

@ -5,7 +5,7 @@ describe("Assignment Feature", function () {
beforeEach(async function () {
this.webExt = await initializeWithTab({
cookieStoreId: "firefox-container-1",
cookieStoreId: "firefox-container-2",
url
});
});
@ -17,12 +17,17 @@ describe("Assignment Feature", function () {
describe("click the 'Always open in' checkbox in the popup", function () {
beforeEach(async function () {
// popup click to set assignment for activeTab.url
await this.webExt.popup.helper.clickElementById("container-page-assigned");
await this.webExt.popup.helper.clickElementById("always-open-in");
console.log("done");
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".menu-item");
//await this.webExt.popup.helper.clickElementById("container-page-assigned");
});
describe("open new Tab with the assigned URL in the default container", function () {
let newTab;
beforeEach(async function () {
let tabs = await this.webExt.background.browser.tabs.query({});
console.log("tabs", tabs);
// new Tab opening activeTab.url in default container
newTab = await this.webExt.background.browser.tabs._create({
cookieStoreId: "firefox-default",
@ -32,14 +37,14 @@ describe("Assignment Feature", function () {
webRequestError: true // because request is canceled due to reopening
}
});
tabs = await this.webExt.background.browser.tabs.query({});
console.log("tabs", tabs)
});
it("should open the confirm page", async function () {
// should have created a new tab with the confirm page
this.webExt.background.browser.tabs.create.should.have.been.calledWithMatch({
url: "moz-extension://fake/confirm-page.html?" +
`url=${encodeURIComponent(url)}` +
`&cookieStoreId=${this.webExt.tab.cookieStoreId}`,
url: "http://example.com",
cookieStoreId: undefined,
openerTabId: null,
index: 2,

View file

@ -11,8 +11,9 @@ describe("Containers Management", function () {
describe("creating a new container", function () {
beforeEach(async function () {
await this.webExt.popup.helper.clickElementById("container-add-link");
await this.webExt.popup.helper.clickElementById("edit-container-ok-link");
await this.webExt.popup.helper.clickElementById("manage-containers-link");
await this.webExt.popup.helper.clickElementById("new-container");
await this.webExt.popup.helper.clickElementById("create-container-ok-link");
});
it("should create it in the browser as well", function () {
@ -21,8 +22,9 @@ describe("Containers Management", function () {
describe("removing it afterwards", function () {
beforeEach(async function () {
await this.webExt.popup.helper.clickElementById("edit-containers-link");
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".delete-container-icon", "last");
await this.webExt.popup.helper.clickElementById("manage-containers-link");
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".menu-item", "last");
await this.webExt.popup.helper.clickElementById("delete-container-button");
await this.webExt.popup.helper.clickElementById("delete-container-ok-link");
});

View file

@ -17,7 +17,7 @@ describe("External Webextensions", function () {
});
describe("with contextualIdentities permissions", function () {
it("should be able to get assignments", async function () {
it.only("should be able to get assignments", async function () {
this.webExt.background.browser.management.get.resolves({
permissions: ["contextualIdentities"]
});

View file

@ -11,7 +11,7 @@ describe("Sync", function() {
delete this.syncHelper;
});
it.only("testIdentityStateCleanup", async function() {
it("testIdentityStateCleanup", async function() {
await this.syncHelper.stopSyncListeners();
await this.syncHelper.setState({}, LOCAL_DATA, TEST_CONTAINERS, []);