From 0505b954ada030302ae3c1873bb98f824234d466 Mon Sep 17 00:00:00 2001 From: Martin D Kealey Date: Mon, 30 Aug 2021 17:54:15 +1000 Subject: [PATCH] Fixing stale tests --- test/features/containers.test.js | 72 ++++++++++++++++++++++++++++---- test/issues/1670.test.js | 4 +- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/test/features/containers.test.js b/test/features/containers.test.js index 8d18c39de..85515171e 100644 --- a/test/features/containers.test.js +++ b/test/features/containers.test.js @@ -10,9 +10,11 @@ describe("Containers Management", function () { }); describe("creating a new container", function () { + const testContainerName = "This Is A Test Container"; beforeEach(async function () { await this.webExt.popup.helper.clickElementById("manage-containers-link"); await this.webExt.popup.helper.clickElementById("new-container"); + this.webExt.popup.window.document.getElementById("edit-container-panel-name-input").value = testContainerName; await this.webExt.popup.helper.clickElementById("create-container-ok-link"); }); @@ -20,17 +22,73 @@ describe("Containers Management", function () { this.webExt.background.browser.contextualIdentities.create.should.have.been.calledOnce; }); - describe("removing it afterwards", function () { + 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("manage-containers-link"); - 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"); + 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 remove it in the browser as well", function () { - this.webExt.background.browser.contextualIdentities.remove.should.have.been.calledOnce; + it("should assign the URL to a container", function () { + this.webExt.background.browser.contextualIdentities.update.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("manage-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.update.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("manage-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; + }); + + describe("manually assign empty URL to a container", function () { + const exampleUrl = ""; + beforeEach(async function () { + await this.webExt.popup.helper.clickElementById("manage-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; + }); + + describe("removing it afterwards", function () { + beforeEach(async function () { + await this.webExt.popup.helper.clickElementById("manage-containers-link"); + 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"); + }); + + it("should remove it in the browser as well", function () { + this.webExt.background.browser.contextualIdentities.remove.should.have.been.calledOnce; + }); + }); + }); + }); }); }); }); -}); \ No newline at end of file +}); diff --git a/test/issues/1670.test.js b/test/issues/1670.test.js index 1fa71ba8b..92efcdd51 100644 --- a/test/issues/1670.test.js +++ b/test/issues/1670.test.js @@ -11,7 +11,7 @@ describe("#1670", 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("manage-containers-link"); await this.webExt.popup.helper.clickElementById("edit-container-ok-link"); }); @@ -75,4 +75,4 @@ describe("#1670", function () { }); }); }); -}); \ No newline at end of file +});