Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#8815 E2E test for sidebar partner auth #8862

Merged
merged 11 commits into from
Jul 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { test, expect } from "../../fixtures/testBase";
import { getSidebarPage } from "../../utils";
import { test, expect } from "../../../fixtures/testBase";
import { getSidebarPage } from "../../../utils";
// @ts-expect-error -- https://youtrack.jetbrains.com/issue/AQUA-711/Provide-a-run-configuration-for-Playwright-tests-in-specs-with-fixture-imports-only
import { type Page, test as base } from "@playwright/test";

Expand Down
82 changes: 82 additions & 0 deletions end-to-end-tests/tests/runtime/sidebar/sidebarAuth.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (C) 2024 PixieBrix, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { test, expect } from "../../../fixtures/testBase";
// @ts-expect-error -- https://youtrack.jetbrains.com/issue/AQUA-711/Provide-a-run-configuration-for-Playwright-tests-in-specs-with-fixture-imports-only
import { type Page, test as base } from "@playwright/test";
import { getBaseExtensionConsoleUrl } from "../../../pageObjects/constants";
import { ActivateModPage } from "../../../pageObjects/extensionConsole/modsPage";
import { getSidebarPage, runModViaQuickBar } from "../../../utils";

test("Connect action in partner auth sidebar takes user to the Extension Console", async ({
page,
extensionId,
context,
chromiumChannel,
}) => {
const modId = "@e2e-testing/open-sidebar-via-quickbar";
const modActivationPage = new ActivateModPage(page, extensionId, modId);
await modActivationPage.goto();
await modActivationPage.clickActivateAndWaitForModsPageRedirect();

await page.goto(`${getBaseExtensionConsoleUrl(extensionId)}#/settings`);
await expect(
page.getByRole("heading", { name: "Extension Settings" }),
).toBeVisible();

await page.fill('input[id="partnerId"]', "automation-anywhere");
await page.fill('input[id="authMethod"]', "partner-oauth2");

// Trigger onBlur event to persist the new settings
await page.getByText("Advanced Settings").click();

await page.goto("/");
await runModViaQuickBar(page, "Open Sidebar");
const sidebarPage = await getSidebarPage(page, extensionId);
await expect(
sidebarPage.getByText("Connect your Automation Co-Pilot account"),
).toBeVisible();
const connectLink = sidebarPage.getByRole("link", {
name: "Connect Account",
});
await expect(connectLink).toBeVisible();

const consolePagePromise = context.waitForEvent("page");

try {
await connectLink.click();
} catch {
// There is a known issue with Edge where clicking external links in the sidebar will implicitly cause the sidebar to be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to consider is to only conditionally swallow the error if this test is being run in msedge.

// closed see https://github.com/w3c/webextensions/issues/588
//
// The sidebar closing prematurely causes the click to fail in playwright, despite the tab being opened correctly
// as a result of following the external link. Ignore the error and continue; expect the console page to be opened correctly.
}

const extensionConsolePage = await consolePagePromise;

// eslint-disable-next-line playwright/no-conditional-in-test -- msedge bug
if (chromiumChannel === "msedge") {
// Another msedge bug causes the browser to fail to open the extension console page from the sidebar until you refresh the page.
// "Error: This script should only be loaded in a browser extension."
await extensionConsolePage.reload();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I copied this logic from another test because I'm not sure how to extract it neatly into a POM since it spans two POMs (the sidebar and the extension console)

This is also only the second time we've had to do this so I propose waiting until we see this at least one more time before extracting


await expect(
extensionConsolePage.getByText("Set up your account"),
).toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { test, expect } from "../../fixtures/testBase";
import { ActivateModPage } from "../../pageObjects/extensionConsole/modsPage";
import { test, expect } from "../../../fixtures/testBase";
import { ActivateModPage } from "../../../pageObjects/extensionConsole/modsPage";
// @ts-expect-error -- https://youtrack.jetbrains.com/issue/AQUA-711/Provide-a-run-configuration-for-Playwright-tests-in-specs-with-fixture-imports-only
import { type Page, test as base } from "@playwright/test";
import { getSidebarPage, isSidebarOpen, runModViaQuickBar } from "../../utils";
import {
getSidebarPage,
isSidebarOpen,
runModViaQuickBar,
} from "../../../utils";

test.describe("sidebar controller", () => {
test("can open sidebar immediately from iframe without focus dialog", async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { test, expect } from "../../fixtures/testBase";
import { ActivateModPage } from "../../pageObjects/extensionConsole/modsPage";
import { test, expect } from "../../../fixtures/testBase";
import { ActivateModPage } from "../../../pageObjects/extensionConsole/modsPage";
// @ts-expect-error -- https://youtrack.jetbrains.com/issue/AQUA-711/Provide-a-run-configuration-for-Playwright-tests-in-specs-with-fixture-imports-only
import { type Page, test as base } from "@playwright/test";
import { getSidebarPage, runModViaQuickBar } from "../../utils";
import { SERVICE_URL } from "../../env";
import { getSidebarPage, runModViaQuickBar } from "../../../utils";
import { SERVICE_URL } from "../../../env";

test("sidebar mod panels are persistent during navigation", async ({
page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { test, expect } from "../../fixtures/testBase";
import { ActivateModPage } from "../../pageObjects/extensionConsole/modsPage";
import { getSidebarPage, runModViaQuickBar } from "../../utils";
import { test, expect } from "../../../fixtures/testBase";
import { ActivateModPage } from "../../../pageObjects/extensionConsole/modsPage";
import { getSidebarPage, runModViaQuickBar } from "../../../utils";

test("custom sidebar theme css file is applied to all levels of sidebar document", async ({
page,
Expand Down
Loading