-
Notifications
You must be signed in to change notification settings - Fork 22
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
Changes from all commits
913e25f
06246ea
8f491eb
bfcdb99
c65b196
4afebf4
bb1f159
5ee0bd1
f33a0a5
5f376f2
bc42c69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
// 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(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
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.