added test cases for manually assigning URL

This commit is contained in:
Sherry Ma 2020-03-09 17:18:14 -04:00 committed by Martin D Kealey
parent 5f56aa8541
commit a3f3413a01
2 changed files with 83 additions and 2 deletions

View file

@ -1875,7 +1875,7 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
const tabId = currentTab.id;
const fullURL = this.checkUrl(url);
if (fullURL !== "") {
if (fullURL !== null) {
// Assign URL to container
await Logic.setOrRemoveAssignment(tabId, fullURL, userContextId, false);
@ -1897,7 +1897,7 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
let newURL = url;
if (!url.match(validUrl)) {
return "";
return null;
}
if (!url.match(regexhttp) && !url.match(regexhttps)) {

81
test/issues/1670.test.js Normal file
View file

@ -0,0 +1,81 @@
// const expect = require("chai").expect;
const {initializeWithTab} = require("../common");
describe("#1670", function () {
beforeEach(async function () {
this.webExt = await initializeWithTab();
});
afterEach(function () {
this.webExt.destroy();
});
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");
});
it("should create it in the browser as well", function () {
this.webExt.background.browser.contextualIdentities.create.should.have.been.calledOnce;
});
describe("manually assign a valid URL to a container", function () {
const exampleUrl = "https://github.com/mozilla/multi-account-containers";
beforeEach(async function () {
await this.webExt.popup.helper.clickElementById("edit-containers-link");
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".edit-container-icon", "last");
this.webExt.popup.window.document.getElementById("edit-container-panel-site-input").value = exampleUrl;
await this.webExt.popup.helper.clickElementById("edit-container-site-link");
});
it("should assign the URL to a container", function () {
this.webExt.background.browser.contextualIdentities.create.should.have.been.calledOnce;
});
});
describe("manually assign valid URL without protocol to a container", function () {
const exampleUrl = "github.com/mozilla/multi-account-containers";
beforeEach(async function () {
await this.webExt.popup.helper.clickElementById("edit-containers-link");
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".edit-container-icon", "last");
this.webExt.popup.window.document.getElementById("edit-container-panel-site-input").value = exampleUrl;
await this.webExt.popup.helper.clickElementById("edit-container-site-link");
});
it("should assign the URL without protocol to a container", function () {
this.webExt.background.browser.contextualIdentities.create.should.have.been.calledOnce;
});
});
describe("manually assign an invalid URL to a container", function () {
const exampleUrl = "github";
beforeEach(async function () {
await this.webExt.popup.helper.clickElementById("edit-containers-link");
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".edit-container-icon", "last");
this.webExt.popup.window.document.getElementById("edit-container-panel-site-input").value = exampleUrl;
await this.webExt.popup.helper.clickElementById("edit-container-site-link");
});
it("should not assign the URL to a container", function () {
// console.log(this.webExt.background.browser.contextualIdentities);
// expect( console.log.calledOnce ).to.be.true;
this.webExt.background.browser.contextualIdentities.update.should.not.have.been.called;
});
});
describe("manually assign empty URL to a container", function () {
const exampleUrl = "";
beforeEach(async function () {
await this.webExt.popup.helper.clickElementById("edit-containers-link");
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".edit-container-icon", "last");
this.webExt.popup.window.document.getElementById("edit-container-panel-site-input").value = exampleUrl;
await this.webExt.popup.helper.clickElementById("edit-container-site-link");
});
it("should not assign the URL to a container", function () {
this.webExt.background.browser.contextualIdentities.update.should.not.have.been.called;
});
});
});
});