e2e: repair popup specs stranded by the 1.9.3 UI and the tab-hosted-popup harness

Three specs still tested the pre-1.9.3 popup (#open-page-overlay FAB,
'Open Chat Panel' label) — the Extension E2E jobs have been red on them
since the FAB was killed. Repointed at the current contract
(#overlay-enabled + #open-panel, 'Open Chat').

The interaction specs (overlay show, picker tool, console tool) all
funnel through the popup's active-tab lookup, which cannot work when the
harness hosts the popup as a tab: the popup IS the active tab, so the
privileged-tab guard always takes the fallback. Each spec now sends the
exact message its button sends (page.overlay.show / tool.picker.start /
tool.console.start), explicitly targeted at the example.com tab, so the
background relay and content-script surfaces are still exercised end to
end. CI's file set (popup, popup-tools, sidebar): 30/30 locally.
This commit is contained in:
hanzo-dev
2026-07-02 23:04:29 -07:00
parent b3f718dfce
commit c783b89c35
2 changed files with 38 additions and 16 deletions
+15 -9
View File
@@ -119,12 +119,16 @@ test.describe('Popup Tools', () => {
await popup.goto(`chrome-extension://${extensionId}/popup.html`);
await popup.waitForTimeout(500);
// #tool-picker resolves the active tab and chrome.tabs.sendMessage's it
// tool.picker.start. In this harness the popup is itself the active tab
// (privileged), so the lookup can never reach example.com — send the
// same message the button sends, explicitly targeted.
const pickerBtn = popup.locator('#tool-picker');
await expect(pickerBtn).toBeVisible();
await pickerBtn.click();
// Wait for message to propagate before popup closes
await popup.waitForTimeout(800);
await popup.evaluate(async () => {
const tabs = await chrome.tabs.query({ url: 'https://example.com/' });
await chrome.tabs.sendMessage(tabs[0]!.id!, { action: 'tool.picker.start' });
});
// Switch to target and wait for picker to mount
await target.bringToFront();
@@ -155,12 +159,14 @@ test.describe('Popup Tools', () => {
await popup.goto(`chrome-extension://${extensionId}/popup.html`);
await popup.waitForTimeout(500);
// Same active-tab harness limitation as the picker test above — send
// the message #tool-console sends, explicitly targeted.
const consoleBtn = popup.locator('#tool-console');
await expect(consoleBtn).toBeVisible();
await consoleBtn.click();
// Wait for message to propagate before popup closes
await popup.waitForTimeout(800);
await popup.evaluate(async () => {
const tabs = await chrome.tabs.query({ url: 'https://example.com/' });
await chrome.tabs.sendMessage(tabs[0]!.id!, { action: 'tool.console.start' });
});
await target.bringToFront();
await target.waitForTimeout(1000);
@@ -194,7 +200,7 @@ test.describe('Popup Tools', () => {
const openPanel = page.locator('#open-panel');
await expect(openPanel).toBeVisible();
await expect(openPanel).toContainText('Open Chat Panel');
await expect(openPanel).toContainText('Open Chat');
await expect(openPanel).toBeEnabled();
});
});
+23 -7
View File
@@ -78,13 +78,16 @@ test.describe('Popup', () => {
await expect(openPanel).toBeAttached();
});
test('on-page overlay toggle button exists', async ({ context, extensionId }) => {
test('on-page overlay toggle exists', async ({ context, extensionId }) => {
// 1.9.3 killed the on-page FAB (#open-page-overlay). The on-page surface
// is now controlled by the #overlay-enabled checkbox (overlay vs new
// tab) and opened via the single #open-panel button.
const page = await context.newPage();
await page.goto(`chrome-extension://${extensionId}/popup.html`);
const openOverlay = page.locator('#open-page-overlay');
await expect(openOverlay).toBeAttached();
await expect(openOverlay).toContainText('Overlay');
const overlayEnabled = page.locator('#overlay-enabled');
await expect(overlayEnabled).toBeAttached();
await expect(overlayEnabled).toBeChecked();
});
test('toggles on-page overlay on a live webpage', async ({ context, extensionId }) => {
@@ -98,9 +101,22 @@ test.describe('Popup', () => {
const popupPage = await context.newPage();
await popupPage.goto(`chrome-extension://${extensionId}/popup.html`);
const toggleOverlayBtn = popupPage.locator('#open-page-overlay');
await expect(toggleOverlayBtn).toBeVisible();
await toggleOverlayBtn.click();
// #open-panel resolves the active tab and relays page.overlay.show to
// its content script. In this harness the popup is itself the active
// tab (a privileged chrome-extension:// page), so the active-tab lookup
// can never reach example.com — drive the same relay the button sends,
// explicitly targeted, and let background + content script do the rest.
const openPanelBtn = popupPage.locator('#open-panel');
await expect(openPanelBtn).toBeVisible();
await popupPage.evaluate(async () => {
const tabs = await chrome.tabs.query({ url: 'https://example.com/' });
await chrome.runtime.sendMessage({
action: 'page.overlay.show',
tabId: tabs[0]?.id,
side: 'right',
width: 'default',
});
});
await targetPage.bringToFront();
const overlayRoot = targetPage.locator('#hanzo-page-overlay-root');