mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 11:24:37 +00:00
test: remove low-value template settings and browser samples (#42492)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -4800,7 +4800,7 @@
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/browser/network/client-routes/browser-client-network-route-registry.test.ts src/main/browser/client-hosts/lifecycle/paired-runtime-browser-client-host-composition.test.ts src/main/browser/client-hosts/lifecycle/paired-runtime-browser-client-host-reconnect.test.ts src/main/browser/network/execution-routes/paired-runtime-browser-network-route.test.ts src/main/runtime/browser-host/commands/browser-host-command-ledger.test.ts src/main/runtime/browser-host/commands/browser-host-command-ledger-capacity.test.ts src/main/runtime/browser-host/leases/browser-host-lease-registry.test.ts src/main/runtime/rpc/methods/browser/browser-client-host.test.ts",
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/browser/network/client-routes/browser-client-network-route-registry.test.ts src/main/browser/client-hosts/lifecycle/paired-runtime-browser-client-host-composition.test.ts src/main/browser/client-hosts/lifecycle/paired-runtime-browser-client-host-registry.test.ts src/main/browser/client-pages/execution/browser-client-page-command-executor.test.ts",
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/browser-host/commands/browser-host-command-ledger.test.ts src/main/runtime/browser-host/commands/browser-host-command-ledger-capacity.test.ts src/main/runtime/browser-host/leases/browser-host-lease-registry.test.ts src/main/runtime/rpc/methods/browser/browser-client-host.test.ts",
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/browser-host/leases/browser-host-lease-registry.test.ts src/main/browser/network/execution-routes/browser-network-deferred-socket.test.ts src/main/browser/network/execution-routes/browser-network-execution-route.test.ts src/main/browser/network/execution-routes/paired-runtime-browser-network-route.test.ts src/main/runtime/rpc/methods/browser/browser-network-tunnel.test.ts src/main/browser/network/execution-routes/ssh-browser-network-execution-route.test.ts src/main/browser/network/tunnels/system-ssh-socks-client-socket.test.ts src/main/ssh/system-transport/forwarding/system-ssh-dynamic-forward-process.test.ts src/main/ssh/system-transport/forwarding/system-ssh-forward-process.test.ts src/main/ssh/system-transport/system-ssh-operations.test.ts src/main/ssh/port-forwarding/ssh-port-forward.test.ts",
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/browser-host/leases/browser-host-lease-registry.test.ts src/main/browser/network/execution-routes/browser-network-deferred-socket.test.ts src/main/browser/network/execution-routes/paired-runtime-browser-network-route.test.ts src/main/runtime/rpc/methods/browser/browser-network-tunnel.test.ts src/main/browser/network/execution-routes/ssh-browser-network-execution-route.test.ts src/main/browser/network/tunnels/system-ssh-socks-client-socket.test.ts src/main/ssh/system-transport/forwarding/system-ssh-dynamic-forward-process.test.ts src/main/ssh/system-transport/forwarding/system-ssh-forward-process.test.ts src/main/ssh/system-transport/system-ssh-operations.test.ts src/main/ssh/port-forwarding/ssh-port-forward.test.ts",
|
||||
"ORCA_RUN_DOCKER_SSH_BROWSER_E2E=1 pnpm exec vitest run --config config/vitest.config.ts tests/e2e/ssh-browser-network-execution-route.docker.unit.test.ts",
|
||||
"ORCA_RUN_DOCKER_SSH_BROWSER_E2E=1 node_modules/.bin/vitest run --config config/vitest.config.ts tests/e2e/ssh-browser-network-execution-route.docker.unit.test.ts"
|
||||
],
|
||||
@@ -4828,7 +4828,6 @@
|
||||
"src/main/browser/network/tunnels/browser-network-tunnel-client.test.ts",
|
||||
"src/main/browser/network/tunnels/browser-network-tunnel-outbound-memory-budget.test.ts",
|
||||
"src/main/browser/network/execution-routes/browser-network-deferred-socket.test.ts",
|
||||
"src/main/browser/network/execution-routes/browser-network-execution-route.test.ts",
|
||||
"src/main/browser/network/execution-routes/paired-runtime-browser-network-route.test.ts",
|
||||
"src/main/browser/network/execution-routes/ssh-browser-network-execution-route.test.ts",
|
||||
"src/main/browser/network/tunnels/system-ssh-socks-client-socket.test.ts",
|
||||
@@ -5002,13 +5001,6 @@
|
||||
"source close after destroy cannot emit duplicate wrapper close"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "src/main/browser/network/execution-routes/browser-network-execution-route.test.ts",
|
||||
"assertions": [
|
||||
"execution-host route keys cannot collide on delimiter-containing identities",
|
||||
"native routing accepts only the exact runtime revision without retaining an invalidation callback"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "src/main/browser/network/execution-routes/ssh-browser-network-execution-route.test.ts",
|
||||
"assertions": [
|
||||
@@ -5116,6 +5108,7 @@
|
||||
"Prove an Electron partition routes loopback, DNS, HTTP, HTTPS, WebSocket, workers, and speculative traffic without desktop fallback."
|
||||
],
|
||||
"knownGaps": [
|
||||
"Audit5472 deletes the complete browser-network-execution-route suite and removes its active command token, test selector and assertion reference here. Structural execution-host identity/current-revision alarms are intentionally lost without equivalent replacement. Dated receipts and historical strings retain their original values; no fresh full-gate execution or renewed coverage is claimed.",
|
||||
"Audit4014 removes the complete browser client page command integration suite and its active command token, test selector and assertion reference. Its synthetic guest lifecycle still exercised real executor/dispatcher/Session/WebContents registry composition: navigation normalization, generation reclaim, spontaneous destruction inventory revocation, and exactly-once route/policy retirement alarms are intentionally lost. Electron guest navigation, proxy resolution and renderer lifecycle were supplied test ports; no equivalent replacement or fresh execution is claimed. The three unrelated active dated receipts and all prior historical strings remain unchanged. Historical prior account (preserved verbatim):",
|
||||
"Audit2133 current-parent preparation (988 authored removals; independently reviewed2099/2107/2115/2116 decisions; upstream clear-buffer and recovery-image regressions retained): Intentionally retire these low-value alarms without replacement: src/main/ssh/system-transport/system-ssh-forward-process.test.ts: spawns exactly the argv the orphan matcher is given, LogLevel=INFO included; runs port forwards unmultiplexed even when ssh_config disables muxing; preserves manual target port and identity options in the forwarded ssh command; does not spawn ssh when the requested local forward port is already in use; spawns ssh after the requested local forward port preflight succeeds; resolves startup after the grace period when ssh keeps running; sends SIGTERM then SIGKILL when the process does not exit; does not resolve stop until the process exits. src/main/ssh/port-forwarding/ssh-port-forward.test.ts: reports the port the OS bound when an ssh2 forward asks for port 0; adds an ssh2 port forward and returns entry; adds a system SSH port forward when no ssh2 client is available; reports the port a system SSH forward resolved when asked for port 0; passes resolved OpenSSH config to system SSH port forwards; disposes a system SSH tunnel when removing the forward; lists forwards filtered by connectionId; removes a forward by id; awaits forward close when removing a forward for user actions; returns null when removing nonexistent forward; removes all forwards for a connection; dispose removes all forwards; stores label in the entry; preserves the existing id when updating a forward succeeds. Current changed source bytes, wrapper registrations and reduced selectors have no fresh execution or red/green credit. Unrelated surviving receipt objects keep their original narrow scope; current literal graph reachability does not establish historical import closure or equivalent replacement coverage. Current conservative command/import graph reaches src/main/ssh/port-forwarding/ssh-port-forward.test.ts, src/main/ssh/system-transport/system-ssh-forward-process.test.ts. Unresolved local/computed edges remain explicit debt. Retired active assertionRefs (raw original objects retained as historical only): {\n \"file\": \"src/main/ssh/port-forwarding/ssh-port-forward.test.ts\",\n \"assertions\": [\n \"static system-SSH forwards receive the connection's complete resolved build options\"\n ]\n }",
|
||||
"Audit1709 removes low-value test definitions and retires affected assertion or execution-receipt claims without equivalent replacement coverage. Per-source reviews bound retained behavior and injected/native/remote limits. Unchanged assertions and receipts keep their original scope; gates lacking current active evidence are downgraded.",
|
||||
@@ -5354,7 +5347,7 @@
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/browser/client-pages/runtime-browser-client-page-creation.test.ts src/main/runtime/browser-host/commands/browser-host-command-ledger.test.ts",
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/shared/remote-runtime/remote-runtime-client.test.ts src/main/ipc/runtime-environments/browser-hosting/runtime-environment-browser-client-host-handler.test.ts",
|
||||
"SKIP_BUILD=1 ORCA_CROSS_VERSION_PACKAGED_EXECUTABLE=/Applications/Orca.app/Contents/MacOS/Orca pnpm exec playwright test tests/e2e/packaged-mixed-version-browser-placement.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1",
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/browser/network/browser-network-tunnel-paired-runtime.integration.test.ts src/main/browser/network/execution-routes/paired-runtime-browser-network-route.test.ts src/main/browser/network/execution-routes/browser-network-execution-route.test.ts src/main/browser/network/execution-routes/wsl-browser-network-execution-route.test.ts src/main/browser/network/execution-routes/wsl-browser-network-relay-launch.test.ts src/main/runtime/browser/network/runtime-browser-network-execution-host.test.ts",
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/browser/network/browser-network-tunnel-paired-runtime.integration.test.ts src/main/browser/network/execution-routes/paired-runtime-browser-network-route.test.ts src/main/browser/network/execution-routes/wsl-browser-network-execution-route.test.ts src/main/runtime/browser/network/runtime-browser-network-execution-host.test.ts",
|
||||
"pnpm exec vitest run --config config/vitest.config.ts src/main/browser/cdp/screencast/browser-screencast-stream.test.ts",
|
||||
"ORCA_RUN_DOCKER_SSH_BROWSER_E2E=1 pnpm exec vitest run --config config/vitest.config.ts tests/e2e/ssh-browser-network-execution-route.docker.unit.test.ts",
|
||||
"Manual iOS 26.5 simulator: pair current mobile code to packaged Orca 1.4.184; create Browser; navigate to https://example.com; require one visible Example Domain tab on the server-hosted surface",
|
||||
@@ -5369,9 +5362,7 @@
|
||||
"tests/e2e/packaged-mixed-version-browser-placement.spec.ts",
|
||||
"src/main/runtime/browser/network/browser-network-tunnel-paired-runtime.integration.test.ts",
|
||||
"src/main/browser/network/execution-routes/paired-runtime-browser-network-route.test.ts",
|
||||
"src/main/browser/network/execution-routes/browser-network-execution-route.test.ts",
|
||||
"src/main/browser/network/execution-routes/wsl-browser-network-execution-route.test.ts",
|
||||
"src/main/browser/network/execution-routes/wsl-browser-network-relay-launch.test.ts",
|
||||
"src/main/runtime/browser/network/runtime-browser-network-execution-host.test.ts",
|
||||
"src/main/browser/cdp/screencast/browser-screencast-stream.test.ts",
|
||||
"tests/e2e/ssh-browser-network-execution-route.docker.unit.test.ts"
|
||||
@@ -5474,6 +5465,7 @@
|
||||
"Complete fresh architecture, compatibility, lifecycle, security, performance, and test reviews on the rebased landing stack."
|
||||
],
|
||||
"knownGaps": [
|
||||
"Audit5472 deletes the complete browser-network-execution-route and WSL relay installer smoke suites and removes their active command tokens and test selectors here. Structural identity/current-revision and exact binary bundle/version marker alarms are intentionally lost without equivalent replacement. The WSL case exercised a real local POSIX shell, not WSL or relay launch. Dated receipts and historical strings retain their original values; no fresh full-gate execution or renewed coverage is claimed.",
|
||||
"Audit1709 removes low-value test definitions and retires affected assertion or execution-receipt claims without equivalent replacement coverage. Per-source reviews bound retained behavior and injected/native/remote limits. Unchanged assertions and receipts keep their original scope; gates lacking current active evidence are downgraded.",
|
||||
"Audit1687 removes low-value test projections, mock wiring, private-state assertions, inventories and duplicate examples without equivalent replacement coverage. Per-source reviews record retained public behavior and refusal boundaries with injected/native/remote limits. Affected historical receipts are retired; gates without active current evidence are downgraded.",
|
||||
"Audit1686 removes low-value test projections, mock wiring, private-state assertions, inventories and duplicate examples without equivalent replacement coverage. Per-source reviews record retained public behavior and refusal boundaries with injected/native/remote limits. Affected historical receipts are retired; gates without active current evidence are downgraded.",
|
||||
|
||||
@@ -353,12 +353,9 @@
|
||||
"src/cli/orchestration-structured-session-no-identity.test.ts": 424,
|
||||
"src/cli/plugin-authoring/plugin-editor-check-loader-rules.test.ts": 3428,
|
||||
"src/cli/plugin-authoring/plugin-editor-check.test.ts": 959,
|
||||
"src/cli/plugin-authoring/plugin-editor-template.test.ts": 1006,
|
||||
"src/cli/plugin-authoring/plugin-hook-template.test.ts": 662,
|
||||
"src/cli/plugin-authoring/plugin-release-entry.test.ts": 730,
|
||||
"src/cli/plugin-authoring/plugin-test-runner.test.ts": 6256,
|
||||
"src/cli/plugin-authoring/plugin-type-files-symlink.test.ts": 743,
|
||||
"src/cli/plugin-authoring/plugin-worker-panel-template.test.ts": 1469,
|
||||
"src/cli/plugin-dev-watch/plugin-dev-watch-approval.test.ts": 544,
|
||||
"src/cli/plugin-dev-watch/plugin-dev-watch-check.test.ts": 427,
|
||||
"src/cli/plugin-dev-watch/plugin-dev-watch-loop.test.ts": 543,
|
||||
@@ -793,7 +790,6 @@
|
||||
"src/main/browser/client-pages/lifecycle/browser-client-page-upload-routing.test.ts": 303,
|
||||
"src/main/browser/client-hosts/file-transfers/browser-client-upload-buffer-retention.test.ts": 736,
|
||||
"src/main/browser/client-hosts/file-transfers/browser-client-upload-staging.test.ts": 140,
|
||||
"src/main/browser/client-hosts/file-transfers/browser-client-upload-transfer.test.ts": 93,
|
||||
"src/main/browser/guest-lifecycle/find/browser-find-frame-traversal.electron.test.ts": 1807,
|
||||
"src/main/browser/cookies/browser-google-cookie-clear-target.test.ts": 6235,
|
||||
"src/main/browser/element-grab/browser-grab-payload.test.ts": 55,
|
||||
@@ -817,7 +813,6 @@
|
||||
"src/main/browser/guest-lifecycle/manager/popups/browser-manager-popup-routing.test.ts": 575,
|
||||
"src/main/browser/guest-lifecycle/manager/viewport/browser-manager-tab-identity.test.ts": 619,
|
||||
"src/main/browser/network/execution-routes/browser-network-deferred-socket.test.ts": 101,
|
||||
"src/main/browser/network/execution-routes/browser-network-execution-route.test.ts": 272,
|
||||
"src/main/browser/network/tunnels/browser-network-tunnel-client.test.ts": 127,
|
||||
"src/main/browser/network/tunnels/browser-network-tunnel-conformance.test.ts": 136,
|
||||
"src/main/browser/network/tunnels/browser-network-tunnel-outbound-memory-budget.test.ts": 66,
|
||||
@@ -826,7 +821,6 @@
|
||||
"src/main/browser/network/tunnels/browser-network-tunnel-session-aggregate-memory.test.ts": 76,
|
||||
"src/main/browser/network/tunnels/browser-network-tunnel-session-stream-scoped-failure.test.ts": 74,
|
||||
"src/main/browser/network/tunnels/browser-network-tunnel-session.test.ts": 157,
|
||||
"src/main/browser/guest-lifecycle/popups/browser-page-initiated-tab-budget.test.ts": 43,
|
||||
"src/main/browser/routing/input-ownership/browser-page-input-credit.test.ts": 50,
|
||||
"src/main/browser/guest-lifecycle/prompts/browser-page-prompts.test.ts": 74,
|
||||
"src/main/browser/identity/browser-process-user-agent.test.ts": 45,
|
||||
@@ -861,7 +855,6 @@
|
||||
"src/main/browser/webauthn/browser-webauthn-account-picker.test.ts": 78,
|
||||
"src/main/browser/webauthn/browser-webauthn-profile-delete.test.ts": 358,
|
||||
"src/main/browser/cdp/commands/cdp-bridge-integration.test.ts": 28361,
|
||||
"src/main/browser/cdp/commands/cdp-print-to-pdf.test.ts": 68,
|
||||
"src/main/browser/cdp/commands/cdp-screenshot.test.ts": 415,
|
||||
"src/main/browser/cdp/transport/cdp-ws-proxy-host-admission.test.ts": 576,
|
||||
"src/main/browser/cdp/transport/cdp-ws-proxy-origin.test.ts": 262,
|
||||
@@ -896,7 +889,6 @@
|
||||
"src/main/browser/extensions/actions/browser-extension-action-icon.test.ts": 62,
|
||||
"src/main/browser/extensions/api-runtime/browser-extension-api-host.test.ts": 894,
|
||||
"src/main/browser/extensions/api/browser-extension-api-namespaces.test.ts": 832,
|
||||
"src/main/browser/extensions/installation/browser-extension-archive.test.ts": 72,
|
||||
"src/main/browser/extensions/context-menus/browser-extension-context-menu-host.test.ts": 68,
|
||||
"src/main/browser/extensions/context-menus/browser-extension-context-menu-model.test.ts": 57,
|
||||
"src/main/browser/extensions/installation/browser-extension-crx.test.ts": 214,
|
||||
@@ -927,7 +919,6 @@
|
||||
"src/main/browser/extensions/tabs-and-windows/browser-extension-tab-model.test.ts": 324,
|
||||
"src/main/browser/extensions/tabs-and-windows/browser-extension-tab-query.test.ts": 48,
|
||||
"src/main/browser/extensions/tabs-and-windows/browser-extension-tab-resolution.test.ts": 320,
|
||||
"src/main/browser/extensions/installation/browser-extension-web-accessible-resources.test.ts": 43,
|
||||
"src/main/browser/extensions/web-store/browser-extension-webstore-bridge-host.test.ts": 258,
|
||||
"src/main/browser/extensions/web-store/browser-extension-webstore-download.test.ts": 64,
|
||||
"src/main/browser/extensions/web-store/browser-extension-webstore-install-flow.test.ts": 290,
|
||||
@@ -961,7 +952,6 @@
|
||||
"src/main/browser/network/execution-routes/ssh-browser-network-execution-route.test.ts": 643,
|
||||
"src/main/browser/network/tunnels/system-ssh-socks-client-socket.test.ts": 53,
|
||||
"src/main/browser/network/execution-routes/wsl-browser-network-execution-route.test.ts": 678,
|
||||
"src/main/browser/network/execution-routes/wsl-browser-network-relay-launch.test.ts": 146,
|
||||
"src/main/browser/routing/local-host-partitions/wsl-host-browser-route-partition.test.ts": 753,
|
||||
"src/main/claude-accounts/sign-in/claude-account-folder.test.ts": 153,
|
||||
"src/main/claude-accounts/claude-account-service.test.ts": 1207,
|
||||
@@ -4754,7 +4744,6 @@
|
||||
"src/renderer/src/components/settings/accounts/providers/AntigravityAccountsSection.test.tsx": 2722,
|
||||
"src/renderer/src/components/settings/browser/profiles/BrowserProfileRow.google-cookie-clear.test.tsx": 27636,
|
||||
"src/renderer/src/components/settings/browser/BrowserSitePermissionsSetting.test.tsx": 739,
|
||||
"src/renderer/src/components/settings/browser/BrowserUserAgentSetting.test.tsx": 2325,
|
||||
"src/renderer/src/components/settings/chat/ChatNamingSetting.test.tsx": 2454,
|
||||
"src/renderer/src/components/settings/chat/ChatSettingsSection.test.tsx": 2718,
|
||||
"src/renderer/src/lib/skills/runtime/skill-runtime-command.test.ts": 1670,
|
||||
@@ -4769,16 +4758,13 @@
|
||||
"src/renderer/src/components/plugins/list/PluginsSettingsSection.lifecycle.test.tsx": 5402,
|
||||
"src/renderer/src/components/settings/runtime-environments/pairing/RuntimePairingGeneratorForm.test.tsx": 461,
|
||||
"src/renderer/src/components/settings/appearance/fonts/FontAutocomplete.test.tsx": 1202,
|
||||
"src/renderer/src/components/settings/form-controls/SettingsFormControls.segmented-control.test.tsx": 730,
|
||||
"src/renderer/src/components/settings/shortcuts/ShortcutsPane.provenance.test.tsx": 2302,
|
||||
"src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.test.tsx": 744,
|
||||
"src/renderer/src/components/settings/ssh/server-actions/SshHostDeltaMoveDialog.test.tsx": 438,
|
||||
"src/renderer/src/components/settings/ssh/server-actions/SshHostRecoverServerAction.test.tsx": 669,
|
||||
"src/renderer/src/components/settings/ssh/targets/SshTargetList.test.tsx": 2093,
|
||||
"src/renderer/src/components/settings/tasks/TaskSourceSimpleSetup.test.tsx": 527,
|
||||
"src/renderer/src/components/settings/TerminalAppearanceSection.ghostty.test.ts": 549,
|
||||
"src/renderer/src/components/settings/terminal/session-management/TerminalLimitSetting.test.tsx": 1015,
|
||||
"src/renderer/src/components/settings/developer-permissions/TerminalTccAttributionNotice.test.tsx": 401,
|
||||
"src/renderer/src/components/settings/voice/VoiceMicrophoneSetting.test.tsx": 957,
|
||||
"src/renderer/src/components/settings/voice/VoicePane.test.tsx": 1042,
|
||||
"src/renderer/src/components/settings/accounts/sign-in/account-add-cancel-target.test.ts": 217,
|
||||
@@ -4796,7 +4782,6 @@
|
||||
"src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupsSection.settings-entry.test.tsx": 2007,
|
||||
"src/renderer/src/components/settings/repository/worktrees/RepositoryWorktreeDefaultsSection.test.tsx": 495,
|
||||
"src/renderer/src/components/settings/repository/identity/RepositoryIconPicker.github-avatar-refresh.test.tsx": 615,
|
||||
"src/renderer/src/components/settings/runtime-environments/pairing/runtime-share-computer-button.test.tsx": 2092,
|
||||
"src/renderer/src/components/settings/navigation/settings-project-list.test.ts": 99,
|
||||
"src/renderer/src/components/settings/source-control/source-control-action-card-layout.test.tsx": 4551,
|
||||
"src/renderer/src/components/settings/source-control/source-control-action-permission-draft.test.tsx": 6938,
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { mkdtemp, rm } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { createPluginFromTemplate } from './plugin-create'
|
||||
import { checkPluginEditors } from './plugin-editor-check'
|
||||
import { findPluginTestFiles, runPluginTests } from './plugin-test-runner'
|
||||
|
||||
const roots: string[] = []
|
||||
afterEach(async () => {
|
||||
await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })))
|
||||
})
|
||||
|
||||
async function editorPlugin(): Promise<string> {
|
||||
const root = await mkdtemp(join(tmpdir(), 'orca-editor-template-'))
|
||||
roots.push(root)
|
||||
const dir = join(root, 'sketch')
|
||||
await createPluginFromTemplate({ dir, template: 'editor' })
|
||||
return dir
|
||||
}
|
||||
|
||||
describe('orca plugin create --template editor', () => {
|
||||
it(
|
||||
'passes plugin check and plugin test as generated',
|
||||
async () => {
|
||||
const dir = await editorPlugin()
|
||||
const [check] = await checkPluginEditors(dir)
|
||||
expect(check?.issues).toEqual([])
|
||||
expect(check?.files).toEqual(['editor/main.ts', 'editor/sync.ts'])
|
||||
const files = await findPluginTestFiles(dir)
|
||||
expect(files).toEqual(['editor/sync.test.ts'])
|
||||
expect(await runPluginTests({ dir, files, quietStdout: true })).toMatchObject({ code: 0 })
|
||||
},
|
||||
// The test run starts its own Node process and transpiles the plugin.
|
||||
60_000
|
||||
)
|
||||
})
|
||||
@@ -1,44 +0,0 @@
|
||||
import { mkdtemp, realpath, rm } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { createPluginFromTemplate } from './plugin-create'
|
||||
import { findPluginTestFiles, runPluginTests } from './plugin-test-runner'
|
||||
|
||||
const roots: string[] = []
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })))
|
||||
})
|
||||
|
||||
async function hookPlugin(): Promise<string> {
|
||||
const root = await realpath(await mkdtemp(join(tmpdir(), 'orca-hook-template-')))
|
||||
roots.push(root)
|
||||
const dir = join(root, 'guard')
|
||||
await createPluginFromTemplate({ dir, template: 'hook' })
|
||||
return dir
|
||||
}
|
||||
|
||||
describe('orca plugin create --template hook', () => {
|
||||
it(
|
||||
"passes its own worker test under `orca plugin test` on Orca's runtime",
|
||||
async () => {
|
||||
const dir = await hookPlugin()
|
||||
const files = await findPluginTestFiles(dir)
|
||||
expect(files).toEqual(['src/worker.test.ts'])
|
||||
const orca = {
|
||||
program: process.execPath,
|
||||
env: { ELECTRON_RUN_AS_NODE: '1' },
|
||||
source: 'orca' as const,
|
||||
version: process.version
|
||||
}
|
||||
expect(await runPluginTests({ dir, files, quietStdout: true, node: orca })).toEqual({
|
||||
runner: 'node',
|
||||
code: 0,
|
||||
node: 'orca'
|
||||
})
|
||||
},
|
||||
// Starts its own Node process and transpiles the plugin.
|
||||
60_000
|
||||
)
|
||||
})
|
||||
@@ -1,65 +0,0 @@
|
||||
import { mkdtemp, realpath, rm } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join, resolve } from 'node:path'
|
||||
import { runProcess } from '@orca/process-host'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { createPluginFromTemplate } from './plugin-create'
|
||||
import { findPluginTestFiles, runPluginTests } from './plugin-test-runner'
|
||||
|
||||
const TSC = resolve(__dirname, '../../../../node_modules/typescript/bin/tsc')
|
||||
const roots: string[] = []
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })))
|
||||
})
|
||||
|
||||
async function workerPanelPlugin(): Promise<string> {
|
||||
const root = await realpath(await mkdtemp(join(tmpdir(), 'orca-worker-panel-')))
|
||||
roots.push(root)
|
||||
const dir = join(root, 'counter')
|
||||
await createPluginFromTemplate({ dir, template: 'worker-panel' })
|
||||
return dir
|
||||
}
|
||||
|
||||
describe('orca plugin create --template worker-panel', () => {
|
||||
it(
|
||||
"passes its own panel and worker tests under `orca plugin test` on Orca's runtime",
|
||||
async () => {
|
||||
const dir = await workerPanelPlugin()
|
||||
const files = await findPluginTestFiles(dir)
|
||||
expect(files).toEqual(['src/panel.test.tsx', 'src/worker.test.ts'])
|
||||
const orca = {
|
||||
program: process.execPath,
|
||||
env: { ELECTRON_RUN_AS_NODE: '1' },
|
||||
source: 'orca' as const,
|
||||
version: process.version
|
||||
}
|
||||
expect(await runPluginTests({ dir, files, quietStdout: true, node: orca })).toEqual({
|
||||
runner: 'node',
|
||||
code: 0,
|
||||
node: 'orca'
|
||||
})
|
||||
},
|
||||
// Starts its own Node process and transpiles the plugin.
|
||||
60_000
|
||||
)
|
||||
|
||||
it(
|
||||
'type-checks against the typings it writes',
|
||||
async () => {
|
||||
const dir = await workerPanelPlugin()
|
||||
const result = await runProcess({
|
||||
program: process.execPath,
|
||||
args: [TSC, '-p', dir],
|
||||
cwd: dir,
|
||||
env: { ...process.env, PWD: dir },
|
||||
timeoutMs: 60_000,
|
||||
maxOutputBytes: 256 * 1024
|
||||
})
|
||||
expect(result.timedOut).toBe(false)
|
||||
expect(result.code, `${result.stdout}${result.stderr}`).toBe(0)
|
||||
},
|
||||
// Runs real tsc over the scaffold and Orca's typings, which takes a while on CI.
|
||||
90_000
|
||||
)
|
||||
})
|
||||
@@ -1,15 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { assertAgentBrowserPassthroughStaysOnPage } from './agent-browser-passthrough-arguments'
|
||||
|
||||
describe('assertAgentBrowserPassthroughStaysOnPage', () => {
|
||||
it.each([
|
||||
[['batch', 'c\\onnect 9222']],
|
||||
[['batch', 'close\\']],
|
||||
[['batch', 'batch "tab new"']],
|
||||
[['batch', 'get url --cdp 9222']]
|
||||
])('refuses %j', (args) => {
|
||||
expect(() => assertAgentBrowserPassthroughStaysOnPage(args)).toThrow(
|
||||
expect.objectContaining({ code: 'invalid_argument' })
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,43 +0,0 @@
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest'
|
||||
import { CdpPdfStreamStore } from './cdp-print-to-pdf'
|
||||
const TTL_MS = 5 * 60 * 1000
|
||||
|
||||
describe('CdpPdfStreamStore', () => {
|
||||
afterEach(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
it('reads sequential chunks and reports eof', () => {
|
||||
const store = new CdpPdfStreamStore()
|
||||
const handle = store.create(Buffer.from('abcdef'))
|
||||
|
||||
expect(store.read({ handle, size: 2 })).toEqual({
|
||||
data: Buffer.from('ab').toString('base64'),
|
||||
eof: false
|
||||
})
|
||||
expect(store.read({ handle })).toEqual({
|
||||
data: Buffer.from('cdef').toString('base64'),
|
||||
eof: true
|
||||
})
|
||||
})
|
||||
|
||||
it('evicts an abandoned stream after the TTL', () => {
|
||||
vi.useFakeTimers()
|
||||
const store = new CdpPdfStreamStore()
|
||||
const handle = store.create(Buffer.from('abc'))
|
||||
|
||||
vi.advanceTimersByTime(TTL_MS + 1)
|
||||
expect(store.read({ handle })).toBeNull()
|
||||
})
|
||||
|
||||
it('refreshes the TTL on each read', () => {
|
||||
vi.useFakeTimers()
|
||||
const store = new CdpPdfStreamStore()
|
||||
const handle = store.create(Buffer.from('abcdef'))
|
||||
|
||||
vi.advanceTimersByTime(TTL_MS - 1)
|
||||
expect(store.read({ handle, size: 1 })).not.toBeNull()
|
||||
vi.advanceTimersByTime(TTL_MS - 1)
|
||||
expect(store.read({ handle, size: 1 })).not.toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -1,25 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type { BrowserClientHostCommandEvent } from '../../../../shared/browser/client-hosting/browser-client-host-protocol'
|
||||
import { fetchBrowserClientUploadFiles } from './browser-client-upload-transfer'
|
||||
|
||||
const event = {
|
||||
authorityRuntimeId: 'runtime-1',
|
||||
authorityEpoch: 'epoch-1',
|
||||
browserHostClientId: 'host-1',
|
||||
browserHostGeneration: 2,
|
||||
browserPageId: 'page-1',
|
||||
pageHostGeneration: 3
|
||||
} as BrowserClientHostCommandEvent
|
||||
|
||||
describe('fetchBrowserClientUploadFiles', () => {
|
||||
it('stops instead of looping forever on a host that never reports eof', async () => {
|
||||
await expect(
|
||||
fetchBrowserClientUploadFiles({
|
||||
request: async () => ({ contentBase64: '', bytesRead: 0, totalBytes: 0, eof: false }),
|
||||
event,
|
||||
remotePaths: ['a.txt']
|
||||
})
|
||||
).rejects.toThrow('browser_client_upload_transfer_stalled')
|
||||
})
|
||||
})
|
||||
@@ -1,41 +0,0 @@
|
||||
import { existsSync, mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { strToU8, zipSync } from 'fflate'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import {
|
||||
readBrowserExtensionArchive,
|
||||
writeBrowserExtensionArchive
|
||||
} from './browser-extension-archive'
|
||||
|
||||
let parent: string
|
||||
let target: string
|
||||
|
||||
beforeEach(() => {
|
||||
parent = mkdtempSync(join(tmpdir(), 'orca-extension-archive-'))
|
||||
target = join(parent, 'target')
|
||||
})
|
||||
afterEach(() => {
|
||||
rmSync(parent, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
describe('browser extension archives', () => {
|
||||
it('rejects an archive with an entry that escapes the folder before writing anything', () => {
|
||||
const archive = zipSync({ 'manifest.json': strToU8('{}'), '../evil.js': strToU8('pwned') })
|
||||
|
||||
expect(() => readBrowserExtensionArchive(archive)).toThrow('unsafe file name')
|
||||
expect(existsSync(join(parent, 'evil.js'))).toBe(false)
|
||||
})
|
||||
|
||||
it('re-checks each path when writing', async () => {
|
||||
await expect(
|
||||
writeBrowserExtensionArchive([{ path: '../evil.js', data: strToU8('pwned') }], target)
|
||||
).rejects.toThrow('unsafe file name')
|
||||
expect(existsSync(join(parent, 'evil.js'))).toBe(false)
|
||||
})
|
||||
|
||||
it('refuses to overwrite an existing file', async () => {
|
||||
const entry = { path: 'a.js', data: strToU8('1') }
|
||||
await expect(writeBrowserExtensionArchive([entry, entry], target)).rejects.toThrow()
|
||||
})
|
||||
})
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { withPrivateFilesHiddenFromWebAccessibleResources } from './browser-extension-web-accessible-resources'
|
||||
|
||||
describe('withPrivateFilesHiddenFromWebAccessibleResources', () => {
|
||||
const packageFiles = ['popup.html', 'assets/app.js', 'assets/deep/icon.png', 'Secret.json']
|
||||
// Stands in for the file system: any spelling of the private file names it.
|
||||
const isPrivate = (resource: string) => resource.toLowerCase() === 'secret.json'
|
||||
|
||||
it('lists the package files a pattern matches, minus private ones', () => {
|
||||
const manifest = { web_accessible_resources: [{ resources: ['*'], matches: ['<all_urls>'] }] }
|
||||
expect(
|
||||
withPrivateFilesHiddenFromWebAccessibleResources(manifest, packageFiles, isPrivate)
|
||||
).toEqual({
|
||||
web_accessible_resources: [
|
||||
{
|
||||
resources: ['popup.html', 'assets/app.js', 'assets/deep/icon.png'],
|
||||
matches: ['<all_urls>']
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps named resources unless they are a private file in another spelling', () => {
|
||||
const manifest = {
|
||||
web_accessible_resources: [
|
||||
{ resources: ['SECRET.JSON', 'popup.html', '/assets/*.js'], matches: ['<all_urls>'] }
|
||||
]
|
||||
}
|
||||
expect(
|
||||
withPrivateFilesHiddenFromWebAccessibleResources(manifest, packageFiles, isPrivate)
|
||||
.web_accessible_resources
|
||||
).toEqual([{ resources: ['popup.html', 'assets/app.js'], matches: ['<all_urls>'] }])
|
||||
})
|
||||
})
|
||||
@@ -1,13 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createPageInitiatedTabBudget } from './browser-page-initiated-tab-budget'
|
||||
|
||||
describe('page-initiated tab budget', () => {
|
||||
it('slides rather than resetting, so a paced flood cannot outrun the cap', () => {
|
||||
const budget = createPageInitiatedTabBudget(2, 1_000)
|
||||
|
||||
expect(budget.tryConsume(0)).toBe(true)
|
||||
expect(budget.tryConsume(900)).toBe(true)
|
||||
expect(budget.tryConsume(1_000)).toBe(true)
|
||||
expect(budget.tryConsume(1_100)).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,48 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { resolveNativeBrowserNetworkExecutionRoute } from './browser-network-execution-route'
|
||||
import { browserNetworkExecutionHostKey } from '../../../../shared/browser/client-hosting/browser-network-execution-host'
|
||||
|
||||
describe('browser network execution route', () => {
|
||||
it('uses structural keys for delimiter-containing execution-host identities', () => {
|
||||
const first = browserNetworkExecutionHostKey({
|
||||
kind: 'ssh',
|
||||
targetId: 'a:b',
|
||||
providerEpoch: 'c',
|
||||
connectionGeneration: 2
|
||||
})
|
||||
const second = browserNetworkExecutionHostKey({
|
||||
kind: 'ssh',
|
||||
targetId: 'a',
|
||||
providerEpoch: 'b:c',
|
||||
connectionGeneration: 2
|
||||
})
|
||||
|
||||
expect(first).not.toBe(second)
|
||||
expect(
|
||||
browserNetworkExecutionHostKey({
|
||||
kind: 'wsl',
|
||||
runtimeId: 'runtime-a',
|
||||
revision: 2,
|
||||
distro: 'Ubuntu:Dev'
|
||||
})
|
||||
).toBe('["wsl","runtime-a",2,"Ubuntu:Dev"]')
|
||||
})
|
||||
|
||||
it('accepts only this runtime native revision', () => {
|
||||
const route = resolveNativeBrowserNetworkExecutionRoute({
|
||||
executionHost: { kind: 'native', runtimeId: 'runtime-a', revision: 2 },
|
||||
runtimeId: 'runtime-a',
|
||||
runtimeRevision: 2
|
||||
})
|
||||
|
||||
expect(route.key).toBe('["native","runtime-a",2]')
|
||||
expect(route.whenInvalidated).toBeUndefined()
|
||||
expect(() =>
|
||||
resolveNativeBrowserNetworkExecutionRoute({
|
||||
executionHost: { kind: 'native', runtimeId: 'runtime-a', revision: 1 },
|
||||
runtimeId: 'runtime-a',
|
||||
runtimeRevision: 2
|
||||
})
|
||||
).toThrow('browser_tunnel_execution_host_mismatch')
|
||||
})
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { buildWslBrowserNetworkGuestInstallScript } from './wsl-browser-network-relay-launch'
|
||||
|
||||
const roots: string[] = []
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs()
|
||||
for (const root of roots.splice(0)) {
|
||||
rmSync(root, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
describe('WSL browser network relay launch', () => {
|
||||
it('installs exact bundle bytes and version marker', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'orca-wsl-browser-network-'))
|
||||
roots.push(root)
|
||||
const bundle = Buffer.from([0, 1, 2, 3, 255])
|
||||
const version = '0.1.0+bundle'
|
||||
const script = buildWslBrowserNetworkGuestInstallScript(bundle, version)
|
||||
|
||||
execFileSync('sh', ['-s'], { input: script, env: { ...process.env, HOME: root } })
|
||||
|
||||
const installDir = join(root, '.orca-wsl', 'browser-network', version)
|
||||
expect(readFileSync(join(installDir, 'wsl-browser-network-relay.js'))).toEqual(bundle)
|
||||
expect(readFileSync(join(installDir, '.browser-network-version'), 'utf8')).toBe(version)
|
||||
})
|
||||
})
|
||||
@@ -1,86 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
// @vitest-environment happy-dom
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../../../../shared/execution-host'
|
||||
import { TooltipProvider } from '../../ui/tooltip'
|
||||
import { BrowserUserAgentSetting } from './BrowserUserAgentSetting'
|
||||
|
||||
const identityGet = vi.fn()
|
||||
const identitySet = vi.fn()
|
||||
|
||||
function renderFor(hostId: ExecutionHostId): void {
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<BrowserUserAgentSetting hostId={hostId} />
|
||||
</TooltipProvider>
|
||||
)
|
||||
}
|
||||
|
||||
function statusFor(
|
||||
mode: 'clean' | 'native',
|
||||
overrides: Record<string, unknown> = {}
|
||||
): Record<string, unknown> {
|
||||
return {
|
||||
identity: {
|
||||
state: 'valid',
|
||||
appliedMode: mode,
|
||||
configuredMode: mode,
|
||||
explicitSelection: true,
|
||||
migrationNoticePending: false,
|
||||
restartRequired: false,
|
||||
...overrides
|
||||
},
|
||||
migrationNotice: null
|
||||
}
|
||||
}
|
||||
|
||||
describe('BrowserUserAgentSetting', () => {
|
||||
beforeEach(() => {
|
||||
identityGet.mockReset()
|
||||
identitySet.mockReset()
|
||||
Object.defineProperty(window, 'api', {
|
||||
configurable: true,
|
||||
value: { browser: { identityGet, identitySet } }
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
it('commits the chosen mode and reports that a restart is required', async () => {
|
||||
identityGet.mockResolvedValue(statusFor('clean'))
|
||||
identitySet.mockResolvedValue({
|
||||
ok: true,
|
||||
identity: {
|
||||
state: 'valid',
|
||||
appliedMode: 'clean',
|
||||
configuredMode: 'native',
|
||||
explicitSelection: true,
|
||||
migrationNoticePending: false,
|
||||
restartRequired: true
|
||||
}
|
||||
})
|
||||
|
||||
renderFor(LOCAL_EXECUTION_HOST_ID)
|
||||
fireEvent.click(await screen.findByRole('radio', { name: 'Native' }))
|
||||
|
||||
await waitFor(() => expect(screen.getByText(/restart required/i)).toBeTruthy())
|
||||
expect(identitySet).toHaveBeenCalledWith('native')
|
||||
expect(screen.getByRole('radio', { name: 'Native' }).getAttribute('aria-checked')).toBe('true')
|
||||
})
|
||||
|
||||
it('surfaces a refused write instead of showing the mode as changed', async () => {
|
||||
identityGet.mockResolvedValue(statusFor('clean'))
|
||||
identitySet.mockResolvedValue({
|
||||
ok: false,
|
||||
error: { code: 'browser_identity_reset_required', message: 'Identity data is corrupt' },
|
||||
identity: statusFor('clean').identity
|
||||
})
|
||||
|
||||
renderFor(LOCAL_EXECUTION_HOST_ID)
|
||||
fireEvent.click(await screen.findByRole('radio', { name: 'Native' }))
|
||||
|
||||
await waitFor(() => expect(screen.getByText('Identity data is corrupt')).toBeTruthy())
|
||||
expect(screen.getByRole('radio', { name: 'Cleaned' }).getAttribute('aria-checked')).toBe('true')
|
||||
})
|
||||
})
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
// @vitest-environment happy-dom
|
||||
import { act } from 'react'
|
||||
import { createRoot, type Root } from 'react-dom/client'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { TerminalTccAttributionNotice } from './TerminalTccAttributionNotice'
|
||||
|
||||
const openSettingsTarget = vi.fn()
|
||||
const openSettingsPage = vi.fn()
|
||||
const setSettingsSearchQuery = vi.fn()
|
||||
|
||||
vi.mock('../../../store/index', () => ({
|
||||
useAppStore: {
|
||||
getState: () => ({ openSettingsTarget, openSettingsPage, setSettingsSearchQuery })
|
||||
}
|
||||
}))
|
||||
|
||||
let container: HTMLDivElement
|
||||
let root: Root
|
||||
|
||||
function stubAttributionHealth(health: 'intact' | 'severed' | 'unknown'): void {
|
||||
Object.assign(window, {
|
||||
api: {
|
||||
pty: {
|
||||
management: {
|
||||
macTccAttribution: vi.fn(async () => ({ health }))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
openSettingsTarget.mockClear()
|
||||
openSettingsPage.mockClear()
|
||||
setSettingsSearchQuery.mockClear()
|
||||
container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
root = createRoot(container)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await act(async () => root.unmount())
|
||||
container.remove()
|
||||
Reflect.deleteProperty(window, 'api')
|
||||
})
|
||||
|
||||
it('refreshes the warning after the daemon restart remedy settles', async () => {
|
||||
stubAttributionHealth('severed')
|
||||
await act(async () => {
|
||||
root.render(<TerminalTccAttributionNotice refreshRevision={0} />)
|
||||
})
|
||||
expect(container.querySelector('[role="alert"]')).not.toBeNull()
|
||||
|
||||
stubAttributionHealth('intact')
|
||||
await act(async () => {
|
||||
root.render(<TerminalTccAttributionNotice refreshRevision={1} />)
|
||||
})
|
||||
expect(container.querySelector('[role="alert"]')).toBeNull()
|
||||
})
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
// @vitest-environment happy-dom
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { TooltipProvider } from '../../ui/tooltip'
|
||||
import { SettingsSegmentedControl } from './SettingsFormControls'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
function renderControl(onChange = vi.fn()): { onChange: ReturnType<typeof vi.fn> } {
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<SettingsSegmentedControl<string>
|
||||
value="stable"
|
||||
onChange={onChange}
|
||||
options={[
|
||||
{ value: 'stable', label: 'Stable' },
|
||||
{
|
||||
value: 'hourly',
|
||||
label: 'Hourly',
|
||||
disabled: true,
|
||||
ariaLabel: 'Hourly (macOS and Windows only)',
|
||||
tooltip: 'Hourly builds are produced only for macOS and Windows.'
|
||||
}
|
||||
]}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
)
|
||||
return { onChange }
|
||||
}
|
||||
|
||||
describe('SettingsSegmentedControl unavailable options', () => {
|
||||
// Native disabled buttons leave tab order and make their explanatory tooltips unreachable.
|
||||
it('marks unavailable options aria-disabled so their tooltip stays reachable', async () => {
|
||||
renderControl()
|
||||
|
||||
const hourly = screen.getByRole('radio', { name: 'Hourly (macOS and Windows only)' })
|
||||
expect(hourly.hasAttribute('disabled')).toBe(false)
|
||||
expect(hourly.getAttribute('aria-disabled')).toBe('true')
|
||||
|
||||
fireEvent.focus(hourly)
|
||||
expect(
|
||||
await screen.findAllByText('Hourly builds are produced only for macOS and Windows.')
|
||||
).not.toHaveLength(0)
|
||||
})
|
||||
|
||||
it('ignores clicks on unavailable options', () => {
|
||||
const { onChange } = renderControl()
|
||||
|
||||
fireEvent.click(screen.getByRole('radio', { name: 'Hourly (macOS and Windows only)' }))
|
||||
expect(onChange).not.toHaveBeenCalled()
|
||||
|
||||
fireEvent.click(screen.getByRole('radio', { name: 'Stable' }))
|
||||
expect(onChange).toHaveBeenCalledWith('stable')
|
||||
})
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { SettingsSearchableSelect } from './SettingsSearchableSelect'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
it('closes when disabled and does not reopen when enabled again', () => {
|
||||
const picker = (disabled: boolean) => (
|
||||
<SettingsSearchableSelect
|
||||
ariaLabel="Language"
|
||||
value="ko"
|
||||
groups={[{ key: 'languages', options: [{ value: 'ko', label: 'Korean' }] }]}
|
||||
onValueChange={vi.fn()}
|
||||
searchPlaceholder="Search languages…"
|
||||
disabled={disabled}
|
||||
/>
|
||||
)
|
||||
const { rerender } = render(picker(false))
|
||||
fireEvent.click(screen.getByRole('combobox', { name: 'Language' }))
|
||||
expect(screen.getByRole('combobox', { name: 'Search languages…' })).toBeTruthy()
|
||||
|
||||
rerender(picker(true))
|
||||
const trigger = screen.getByRole('combobox', { name: 'Language' })
|
||||
expect(trigger.getAttribute('disabled')).not.toBeNull()
|
||||
expect(screen.queryByRole('combobox', { name: 'Search languages…' })).toBeNull()
|
||||
|
||||
rerender(picker(false))
|
||||
expect(screen.queryByRole('combobox', { name: 'Search languages…' })).toBeNull()
|
||||
})
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
// @vitest-environment happy-dom
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { RuntimeShareComputerButton } from './runtime-share-computer-button'
|
||||
|
||||
vi.mock('./RuntimePairingUrlGenerator', () => ({ RuntimePairingUrlGenerator: () => null }))
|
||||
vi.mock('../../../machine-identity/MachineNameField', () => ({
|
||||
MachineNameField: () => <div>machine-name-field</div>
|
||||
}))
|
||||
vi.mock('../../../machine-identity/use-published-machine-name', () => ({
|
||||
usePublishedMachineName: () => 'Studio'
|
||||
}))
|
||||
|
||||
const listRuntimeAccessGrants = vi.fn(async () => ({ grants: [{ deviceId: 'a' }] }))
|
||||
|
||||
beforeEach(() => {
|
||||
listRuntimeAccessGrants.mockClear()
|
||||
Object.assign(window, { api: { ...window.api, mobile: { listRuntimeAccessGrants } } })
|
||||
})
|
||||
afterEach(cleanup)
|
||||
|
||||
it('closes through Done like any other dismissal', async () => {
|
||||
render(<RuntimeShareComputerButton />)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Share this computer' }))
|
||||
await waitFor(() => expect(screen.queryByText('1 active link')).not.toBeNull())
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'Edit' }))
|
||||
expect(screen.queryByText('machine-name-field')).not.toBeNull()
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Done' }))
|
||||
await waitFor(() => expect(listRuntimeAccessGrants).toHaveBeenCalledTimes(2))
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Share this computer' }))
|
||||
expect(await screen.findByRole('button', { name: 'Edit' })).not.toBeNull()
|
||||
expect(screen.queryByText('machine-name-field')).toBeNull()
|
||||
})
|
||||
@@ -1,42 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
// @vitest-environment happy-dom
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { isListOwnSelectAllTarget } from './SshTargetList'
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
function mount(html: string): HTMLElement {
|
||||
const list = document.createElement('div')
|
||||
list.innerHTML = html
|
||||
document.body.append(list)
|
||||
return list
|
||||
}
|
||||
|
||||
describe('⌘/Ctrl-A on the SSH host list', () => {
|
||||
it('selects hosts from a row control inside the list', () => {
|
||||
const list = mount('<button id="row">Connect</button>')
|
||||
expect(isListOwnSelectAllTarget(list, list.querySelector('#row'))).toBe(true)
|
||||
})
|
||||
|
||||
// React bubbles keydown through portals, so a row dialog's event reaches the list handler.
|
||||
it('ignores events from portalled dialogs and menus outside the list', () => {
|
||||
const list = mount('<button>Connect</button>')
|
||||
const dialog = document.createElement('div')
|
||||
dialog.setAttribute('role', 'dialog')
|
||||
dialog.innerHTML = '<button id="inside">Restart</button>'
|
||||
document.body.append(dialog)
|
||||
expect(isListOwnSelectAllTarget(list, dialog.querySelector('#inside'))).toBe(false)
|
||||
})
|
||||
|
||||
it('leaves text selection alone in fields, menus and detail text inside the list', () => {
|
||||
const list = mount(
|
||||
'<input id="field" /><div role="menu"><div id="item">Edit</div></div><pre id="detail">log</pre>'
|
||||
)
|
||||
for (const id of ['field', 'item', 'detail']) {
|
||||
expect(isListOwnSelectAllTarget(list, list.querySelector(`#${id}`))).toBe(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user