diff --git a/end-to-end-tests/fixtures/utils.ts b/end-to-end-tests/fixtures/utils.ts
index 49dde0ceee..58c58456b1 100644
--- a/end-to-end-tests/fixtures/utils.ts
+++ b/end-to-end-tests/fixtures/utils.ts
@@ -42,9 +42,6 @@ export const launchPersistentContextWithExtension = async (
],
slowMo: SLOWMO ? 3000 : undefined,
permissions: ["clipboard-read", "clipboard-write", "accessibility-events"],
- // Set the viewport to null because we rely on the real inner window width to detect when the sidepanel is open
- // See: https://github.com/microsoft/playwright/issues/11465 and https://github.com/pixiebrix/pixiebrix-extension/blob/b4b0a2efde2c3ac5e634220b555532a2875fe5da/src/contentScript/sidebarController.tsx#L78
- viewport: null,
});
};
diff --git a/end-to-end-tests/tests/runtime/screenshotTab.spec.ts b/end-to-end-tests/tests/runtime/screenshotTab.spec.ts
new file mode 100644
index 0000000000..3d68e1d2b5
--- /dev/null
+++ b/end-to-end-tests/tests/runtime/screenshotTab.spec.ts
@@ -0,0 +1,48 @@
+/*
+ * 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 .
+ */
+
+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 { test as base } from "@playwright/test";
+import { runModViaQuickBar } from "../../utils";
+
+test("screenshot tab brick functionality", async ({ page, extensionId }) => {
+ const modId = "@e2e-testing/test-screenshot";
+
+ const modActivationPage = new ActivateModPage(page, extensionId, modId);
+ await modActivationPage.goto();
+
+ await modActivationPage.clickActivateAndWaitForModsPageRedirect();
+
+ await page.goto("/advanced-fields/");
+
+ await runModViaQuickBar(page, "Screenshot");
+
+ const screenshotModalFrame = page.frameLocator(
+ 'iframe[title="Modal content"]',
+ );
+
+ await expect(
+ screenshotModalFrame.getByText("Screenshot modal"),
+ ).toBeVisible();
+
+ await expect(screenshotModalFrame.getByRole("img")).not.toHaveJSProperty(
+ "naturalWidth",
+ 0,
+ );
+});
diff --git a/playwright.config.ts b/playwright.config.ts
index f79c61f3a5..b99b0baf9e 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -75,6 +75,9 @@ export default defineConfig<{ chromiumChannel: string }>({
expect: {
/* Timeout for each assertion. If a particular interaction is timing out, adjust its specific timeout value rather than this global setting */
timeout: 5000,
+ toHaveScreenshot: {
+ maxDiffPixelRatio: 0.1,
+ },
},
reportSlowTests: null,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
diff --git a/src/bricks/transformers/screenshotTab.ts b/src/bricks/transformers/screenshotTab.ts
index 4f691de5ca..f4e805dd0e 100644
--- a/src/bricks/transformers/screenshotTab.ts
+++ b/src/bricks/transformers/screenshotTab.ts
@@ -46,12 +46,12 @@ export class ScreenshotTab extends TransformerABC {
override defaultOutputKey = "screenshot";
async transform(
- args: BrickArgs,
+ _args: BrickArgs,
{ platform }: BrickOptions,
- ): Promise {
+ ): Promise<{ data: string }> {
try {
return {
- data: platform.capture.captureScreenshot(),
+ data: await platform.capture.captureScreenshot(),
};
} catch (error) {
if (getErrorMessage(error).includes("activeTab")) {