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

#8206: playwright tests for MS Edge sidebar links #8216

Merged
merged 24 commits into from May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 64 additions & 0 deletions end-to-end-tests/tests/sidebar/sidebarLinks.spec.ts
@@ -0,0 +1,64 @@
/*
* 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/extensionBase";
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 { test as base } from "@playwright/test";
import { getSidebarPage } from "../../utils";

test("8206: clicking links doesn't crash browser", async ({
page,
extensionId,
}) => {
const modId = "@pixies/test/sidebar-links";

const modActivationPage = new ActivateModPage(page, extensionId, modId);
await modActivationPage.goto();

await modActivationPage.clickActivateAndWaitForModsPageRedirect();

await page.goto("/");

// The mod contains a trigger to open the sidebar on h1
await page.click("h1");

const sideBarPage = await getSidebarPage(page, extensionId);
await expect(
sideBarPage.getByRole("heading", { name: "Sidebar Links" }),
).toBeVisible();

await sideBarPage.getByTitle("Open Extension Console").click();

await sideBarPage.getByRole("link", { name: "Markdown Text Link" }).click();

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can also assert that the expected page was opened. See: https://playwright.dev/docs/pages#handling-popups

// Is a react-bootstrap button link variant
await sideBarPage.getByRole("button", { name: "Open a Tab Link" }).click();

await sideBarPage.getByRole("link", { name: "HTML Renderer Link" }).click();

await sideBarPage.getByRole("link", { name: "Embedded Form Link" }).click();

// FIXME: get these selectors working
// PixieBrix uses 2 layers of frames to get around the host page CSP. Test page has 2 layers
// const pixiebrixFrame = sideBarPage.frameLocator("iframe").first();
// const mainFrame = pixiebrixFrame.frameLocator("iframe").first();
// await expect(mainFrame.getByText("Alpha")).toBeVisible();
//
// const srcdocFrame = mainFrame.frameLocator("iframe").first();
// await srcdocFrame.getByRole("link", { name: "IFrame Link" }).click();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

During manual testing in MS Edge on Mac the browser crashes when clicking link in the iframe. (Because our interception logic does not intercept it)

});
1 change: 1 addition & 0 deletions src/sidebar/Header.tsx
Expand Up @@ -103,6 +103,7 @@ const Header: React.FunctionComponent = () => {
size="sm"
variant="link"
className={headerButtonClassName}
title="Open Extension Console"
>
<FontAwesomeIcon icon={faCog} />
</Button>
Expand Down
2 changes: 2 additions & 0 deletions src/sidebar/__snapshots__/Header.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/sidebar/__snapshots__/SidebarBody.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.