Files
puter/src/puter-js/tests/e2e/specs/attachCustomDomain.spec.js
T
Neal Shah 25a574b57d
Notify HeyPuter / notify (push) Canceled after 0s
release-please / release-please (push) Canceled after 0s
Backend Tests / changes (push) Canceled after 0s
Backend Tests / typecheck (push) Canceled after 0s
Backend Tests / test shard 1/4 (push) Canceled after 0s
Backend Tests / test shard 2/4 (push) Canceled after 0s
Backend Tests / test shard 3/4 (push) Canceled after 0s
Backend Tests / test shard 4/4 (push) Canceled after 0s
Backend Tests / test (main) (push) Canceled after 0s
Backend Tests / coverage (push) Canceled after 0s
Maintain Release Merge PR / update-release-pr (push) Canceled after 0s
GUI for custom domains (#4355)
* PUT-2226

* modifications'

* routing fixes

* secondary custom domain verification
2026-10-27 15:54:02 -04:00

71 lines
3.0 KiB
JavaScript

import { test, expect } from '@playwright/test';
import { registerTestApp, deleteTestApp, gotoTestApp, waitForPuterReady, FIXTURE_URL } from '../helpers/testApp.js';
const ATTACH_FIXTURE_URL = FIXTURE_URL.replace(
'menubar-contextmenu.html',
'attach-custom-domain.html',
);
// The test instance runs without the custom domains backend, so the dialog
// shows its unavailable pane. Picking and adding domains needs that backend
// and is covered by the extension's own tests.
test.describe('puter.hosting.attach (env=app)', () => {
test('the desktop hosts the dialog and closing it resolves null', async ({ page }) => {
const appName = await registerTestApp(page, { fixtureURL: ATTACH_FIXTURE_URL });
try {
const appFrame = await gotoTestApp(page, appName);
await appFrame.locator('#attach').click();
const dialog = page.locator('.custom-domain-overlay');
await expect(dialog).toBeVisible();
// The site and the requesting app are named from the GUI's own
// records, not from anything the app can style.
await expect(dialog.locator('.custom-domain-intro')).toContainText('e2e-attach-site.');
await expect(dialog.locator('.custom-domain-requester')).toContainText(appName);
await expect(dialog.locator('[data-pane="unavailable"]')).toBeVisible({ timeout: 15_000 });
await dialog.locator('.app-feedback-x').click();
await expect(appFrame.locator('#log [data-entry="attach:null"]')).toBeVisible();
await expect(dialog).toBeHidden();
} finally {
await deleteTestApp(page, appName);
}
});
});
test.describe('puter.hosting.attach (env=gui)', () => {
test('rejects on the Puter desktop itself', async ({ page }) => {
await page.goto('/');
await waitForPuterReady(page);
const code = await page.evaluate(() =>
window.puter.hosting.attach('e2e-attach-site').then(() => 'resolved', (e) => e?.code));
expect(code).toBe('not_available');
});
});
test.describe('puter.hosting.attach (env=web popup)', () => {
test('popup hosts the dialog, resolves null on close, and never hands the opener a token', async ({ page }) => {
await page.goto('/');
await page.waitForFunction(() => !!window.puter?.authToken, null, { timeout: 60_000 });
await page.goto(ATTACH_FIXTURE_URL);
await page.locator('body.ready').waitFor({ timeout: 60_000 });
const [popup] = await Promise.all([
page.waitForEvent('popup'),
page.locator('#attach').click(),
]);
const dialog = popup.locator('.custom-domain-overlay');
await expect(dialog).toBeVisible({ timeout: 60_000 });
await popup.close();
await expect(page.locator('#log [data-entry="attach:null"]')).toBeVisible({ timeout: 15_000 });
// attach-custom-domain is a NON_AUTH popup action.
const authToken = await page.evaluate(() => window.puter.authToken ?? null);
expect(authToken).toBeNull();
});
});