updates to make tests work

This commit is contained in:
Kendall Werts 2020-02-25 11:10:15 -06:00
parent a66cdbf0bd
commit 4920f478fb
4 changed files with 93 additions and 52 deletions

View file

@ -1,11 +1,11 @@
const {initializeWithTab} = require("../common");
describe("Assignment Feature", function () {
describe("Assignment Reopen Feature", function () {
const url = "http://example.com";
beforeEach(async function () {
this.webExt = await initializeWithTab({
cookieStoreId: "firefox-container-2",
cookieStoreId: "firefox-default",
url
});
});
@ -18,16 +18,44 @@ describe("Assignment Feature", function () {
beforeEach(async function () {
// popup click to set assignment for activeTab.url
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");
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item");
});
it("should open the page in the assigned container", async function () {
// should have created a new tab with the confirm page
this.webExt.background.browser.tabs.create.should.have.been.calledWithMatch({
active: true,
cookieStoreId: "firefox-container-4",
index: 1,
openerTabId: null,
url: "http://example.com"
});
});
});
});
describe("Assignment Comfirm Page Feature", function () {
const url = "http://example.com";
beforeEach(async function () {
this.webExt = await initializeWithTab({
cookieStoreId: "firefox-container-4",
url
});
});
afterEach(function () {
this.webExt.destroy();
});
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);
await this.webExt.popup.helper.clickElementById("always-open-in");
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item");
// new Tab opening activeTab.url in default container
newTab = await this.webExt.background.browser.tabs._create({
cookieStoreId: "firefox-default",
@ -37,14 +65,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: "http://example.com",
url: "moz-extension://fake/confirm-page.html?" +
`url=${encodeURIComponent(url)}` +
`&cookieStoreId=${this.webExt.tab.cookieStoreId}`,
cookieStoreId: undefined,
openerTabId: null,
index: 2,
@ -55,26 +83,35 @@ describe("Assignment Feature", function () {
it("should remove the new Tab that got opened in the default container", function () {
this.webExt.background.browser.tabs.remove.should.have.been.calledWith(newTab.id);
});
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();
});
describe("click the 'Always open in' checkbox in the popup again", function () {
describe("open new Tab with url set to 'never ask' ", function () {
beforeEach(async function () {
// popup click to remove assignment for activeTab.url
await this.webExt.popup.helper.clickElementById("container-page-assigned");
});
describe("open new Tab with the no longer assigned URL in the default container", function () {
beforeEach(async function () {
// new Tab opening activeTab.url in default container
// new Tab trying to open url in default container
await this.webExt.background.browser.tabs._create({
cookieStoreId: "firefox-default",
url
});
const tabs = await this.webExt.background.browser.tabs.query({});
console.log("tabs", tabs);
});
it("should not open the confirm page", async function () {
// should not have created a new tab
this.webExt.background.browser.tabs.create.should.not.have.been.called;
// should have created a new tab with the assigned url
this.webExt.background.browser.tabs.create.should.have.been.calledWithMatch({
url,
cookieStoreId: "firefox-container-4",
openerTabId: null,
index: 3,
active: true
});
});
});
});

View file

@ -23,7 +23,7 @@ describe("Containers Management", function () {
describe("removing it afterwards", function () {
beforeEach(async function () {
await this.webExt.popup.helper.clickElementById("manage-containers-link");
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".menu-item", "last");
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item", "last");
await this.webExt.popup.helper.clickElementById("delete-container-button");
await this.webExt.popup.helper.clickElementById("delete-container-ok-link");
});

View file

@ -5,11 +5,12 @@ describe("External Webextensions", function () {
beforeEach(async function () {
this.webExt = await initializeWithTab({
cookieStoreId: "firefox-container-1",
cookieStoreId: "firefox-container-4",
url
});
await this.webExt.popup.helper.clickElementById("container-page-assigned");
await this.webExt.popup.helper.clickElementById("always-open-in");
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item", "last");
});
afterEach(function () {
@ -17,7 +18,7 @@ describe("External Webextensions", function () {
});
describe("with contextualIdentities permissions", function () {
it.only("should be able to get assignments", async function () {
it("should be able to get assignments", async function () {
this.webExt.background.browser.management.get.resolves({
permissions: ["contextualIdentities"]
});
@ -32,7 +33,7 @@ describe("External Webextensions", function () {
const [promise] = this.webExt.background.browser.runtime.onMessageExternal.addListener.yield(message, sender);
const answer = await promise;
expect(answer.userContextId === "1").to.be.true;
expect(answer.userContextId === "4").to.be.true;
expect(answer.neverAsk === false).to.be.true;
expect(
Object.prototype.hasOwnProperty.call(

View file

@ -4,11 +4,12 @@ describe("#940", function () {
describe("when other onBeforeRequestHandlers are faster and redirect with the same requestId", function () {
it("should not open two confirm pages", async function () {
const webExtension = await initializeWithTab({
cookieStoreId: "firefox-container-1",
cookieStoreId: "firefox-container-4",
url: "http://example.com"
});
await webExtension.popup.helper.clickElementById("container-page-assigned");
await webExtension.popup.helper.clickElementById("always-open-in");
await webExtension.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item");
const responses = {};
await webExtension.background.browser.tabs._create({
@ -36,10 +37,12 @@ describe("#940", function () {
beforeEach(async function () {
this.webExt = await initializeWithTab({
cookieStoreId: "firefox-container-1",
cookieStoreId: "firefox-container-4",
url: "https://www.youtube.com"
});
await this.webExt.popup.helper.clickElementById("container-page-assigned");
await this.webExt.popup.helper.clickElementById("always-open-in");
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item");
global.clock = sinon.useFakeTimers();
this.redirectedRequest = async (options = {}) => {