Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
test: wait for share branch dialog readiness (#6578)
Nick Gomezac4eb97aa547
diff --git a/knip.config.ts b/knip.config.tsindex e43118957..eb9727af8 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -155,11 +155,15 @@ export default {'src/shadow-fixture-launch.test-helper.mjs',],project: 'src/**',- ignoreDependencies: ['@types/shell-quote'],+ ignoreDependencies: [+ '@types/shell-quote',+ ],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],- ignoreDependencies: ['yjs'],+ ignoreDependencies: [+ 'yjs',+ ],},'packages/desktop': {entry: [diff --git a/packages/app/src/components/ShareBranchSwitchDialog.dom.test.tsx b/packages/app/src/components/ShareBranchSwitchDialog.dom.test.tsxindex 4f4f51346..25536c906 100644--- a/packages/app/src/components/ShareBranchSwitchDialog.dom.test.tsx+++ b/packages/app/src/components/ShareBranchSwitchDialog.dom.test.tsx@@ -159,6 +159,22 @@ function projectBranchSwitchPayload(): Extract<};}+async function findEnabledButton(testId: string): Promise<HTMLButtonElement> {+ const btn = (await screen.findByTestId(testId)) as HTMLButtonElement;+ await waitFor(() => {+ expect(btn.disabled).toBe(false);+ });+ return btn;+}++function findEnabledSwitchButton(): Promise<HTMLButtonElement> {+ return findEnabledButton('share-branch-switch-switch');+}++function findEnabledWorktreeButton(): Promise<HTMLButtonElement> {+ return findEnabledButton('share-branch-switch-worktree');+}+describe('ShareBranchSwitchDialog — payload gating', () => {afterEach(() => {cleanup();@@ -357,13 +373,15 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);const switchBtn = await screen.findByTestId('share-branch-switch-switch');- const describedBy = switchBtn.getAttribute('aria-describedby');- expect((switchBtn as HTMLButtonElement).disabled).toBe(true);- expect(switchBtn.getAttribute('aria-disabled')).toBe('true');- expect(describedBy).toBe('share-receive-branch-conflict-files');- const conflictList = document.getElementById(describedBy ?? '');- expect(conflictList?.textContent).toContain('docs/notes.md');- expect(conflictList?.textContent).toContain('package.json');+ await waitFor(() => {+ const describedBy = switchBtn.getAttribute('aria-describedby');+ expect((switchBtn as HTMLButtonElement).disabled).toBe(true);+ expect(switchBtn.getAttribute('aria-disabled')).toBe('true');+ expect(describedBy).toBe('share-receive-branch-conflict-files');+ const conflictList = document.getElementById(describedBy ?? '');+ expect(conflictList?.textContent).toContain('docs/notes.md');+ expect(conflictList?.textContent).toContain('package.json');+ });});test('Switch click runs checkout, awaits CC1, then warm-focus-dispatches with pendingDeepLinkDoc + pendingBranch', async () => {@@ -379,7 +397,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const switchBtn = await screen.findByTestId('share-branch-switch-switch');+ const switchBtn = await findEnabledSwitchButton();await act(async () => {fireEvent.click(switchBtn);await Promise.resolve();@@ -433,7 +451,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()window.location.hash = '#before-switch';render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const switchBtn = await screen.findByTestId('share-branch-switch-switch');+ const switchBtn = await findEnabledSwitchButton();await act(async () => {fireEvent.click(switchBtn);await Promise.resolve();@@ -466,7 +484,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const switchBtn = await screen.findByTestId('share-branch-switch-switch');+ const switchBtn = await findEnabledSwitchButton();await act(async () => {fireEvent.click(switchBtn);await Promise.resolve();@@ -500,7 +518,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const switchBtn = await screen.findByTestId('share-branch-switch-switch');+ const switchBtn = await findEnabledSwitchButton();await act(async () => {fireEvent.click(switchBtn);await Promise.resolve();@@ -536,7 +554,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const switchBtn = await screen.findByTestId('share-branch-switch-switch');+ const switchBtn = await findEnabledSwitchButton();await act(async () => {fireEvent.click(switchBtn);await Promise.resolve();@@ -566,7 +584,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const switchBtn = await screen.findByTestId('share-branch-switch-switch');+ const switchBtn = await findEnabledSwitchButton();await act(async () => {fireEvent.click(switchBtn);await Promise.resolve();@@ -641,7 +659,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const switchBtn = await screen.findByTestId('share-branch-switch-switch');+ const switchBtn = await findEnabledSwitchButton();await act(async () => {fireEvent.click(switchBtn);await Promise.resolve();@@ -694,7 +712,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const firstSwitch = await screen.findByTestId('share-branch-switch-switch');+ const firstSwitch = await findEnabledSwitchButton();await act(async () => {fireEvent.click(firstSwitch);await Promise.resolve();@@ -733,7 +751,7 @@ describe('ShareBranchSwitchDialog — Switch path (runCheckout + CC1 gate)', ()store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const switchBtn = await screen.findByTestId('share-branch-switch-switch');+ const switchBtn = await findEnabledSwitchButton();await act(async () => {fireEvent.click(switchBtn);await Promise.resolve();@@ -1011,14 +1029,6 @@ describe('ShareBranchSwitchDialog — worktree leg', () => {return { payload, emit: (p: OkShareReceivedPayload) => emitShare(p) };}- async function findEnabledWorktreeButton(): Promise<HTMLButtonElement> {- const btn = (await screen.findByTestId('share-branch-switch-worktree')) as HTMLButtonElement;- await waitFor(() => {- expect(btn.disabled).toBe(false);- });- return btn;- }-const variantFixtures = [{ kind: 'A', label: 'target on current branch, clean tree', shareTargetExists: true },{ kind: 'B', label: 'target missing, clean tree', shareTargetExists: false },@@ -1176,8 +1186,7 @@ describe('ShareBranchSwitchDialog — worktree leg', () => {store.install({ bridge: fakeBridgeForStore });render(<ShareBranchSwitchDialog bridge={bridge} store={store} />);- const worktreeBtn = await screen.findByTestId('share-branch-switch-worktree');- expect((worktreeBtn as HTMLButtonElement).disabled).toBe(false);+ const worktreeBtn = await findEnabledWorktreeButton();await act(async () => {fireEvent.click(worktreeBtn);await Promise.resolve();diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex a50b00123..4549c74b3 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.tsindex 6fcdc23f2..4fc2c11f9 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { normalizeBridge } from '@inkeep/open-knowledge-core';import { updateYFragment } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.tsindex 40b5cdfd6..9f2f6feb6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.tsindex 93666af70..2a085742b 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.tsindex 867598d34..878d5196b 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.tsindex 0970ac12f..4ada3cf26 100644--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts@@ -1,3 +1,4 @@+import { randomUUID } from 'node:crypto';import { afterEach, describe, expect, test } from 'vitest';import { agentWriteMd, createTestServer, type TestServer } from './test-harness';diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.tsindex b632185e1..cbe2b705f 100644--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts@@ -1,3 +1,4 @@+import { execFileSync } from 'node:child_process';import { randomUUID } from 'node:crypto';import { join } from 'node:path';diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.tsindex c530ce4ba..89bc9b4d9 100644--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts@@ -1,3 +1,4 @@+import { randomUUID } from 'node:crypto';import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';import type * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.tsindex d3767adc9..a78aeb0e4 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,3 +1,4 @@+import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.tsindex b076f955c..e7cc69c3f 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,3 +1,4 @@+import { writeFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.tsindex 7935e35f8..9ddcd0730 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,3 +1,4 @@+import { prependFrontmatter } from '@inkeep/open-knowledge-core';import { Plugin, PluginKey } from '@tiptap/pm/state';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex f4cc8a286..2a597ec3d 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,3 +1,4 @@+import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex e7e63f43d..ffd8fce06 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,3 +1,4 @@+import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex fc267cbea..fb0ba5a7c 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex 861003fb4..ae8cb390b 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 4d3250d3a..8be632ba4 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,3 +1,4 @@+export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');