Skip to content

Re-organize test cases - #186

Merged
cyanzhong merged 1 commit into
mainfrom
develop
Sep 5, 2026
Merged

cyanzhong merged 1 commit into
mainfrom
develop

Conversation

@cyanzhong

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The split introduced a fragile teardown in tests/hiddenSyntax/support.ts and appears to have dropped the “keeps HTML source visible” regression test.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR reorganizes the previously monolithic tests/hiddenSyntax.test.ts into focused per-feature test files under tests/hiddenSyntax/, introducing shared test utilities/mocks to keep the suite maintainable and easier to navigate.

Changes:

  • Split tests/hiddenSyntax.test.ts into multiple targeted tests/hiddenSyntax/*.test.ts files (inline, links, headings, blockquotes, lists, selection, mode, blocks).
  • Added tests/hiddenSyntax/support.ts to centralize Mermaid mocking and shared DOM/editor helpers.
  • Fixed relative imports in tests/hiddenSyntax/hiddenSyntax.bench.ts after the directory reshuffle.
File summaries
File Description
tests/hiddenSyntax/unorderedList.test.ts New focused tests for unordered list + task-prefix interactions.
tests/hiddenSyntax/support.ts Shared Vitest hooks/helpers and Mermaid mocks for hidden-syntax tests.
tests/hiddenSyntax/selection.test.ts New focused tests for vertical motion and pointer selection behaviors.
tests/hiddenSyntax/mode.test.ts New focused tests for enabling/disabling syntax-hidden mode.
tests/hiddenSyntax/link.test.ts New focused tests for link/image hiding, icons, and navigation.
tests/hiddenSyntax/inline.test.ts New focused tests for inline code/strong/italic/strike and editing flows.
tests/hiddenSyntax/hiddenSyntax.bench.ts Updated import paths to match new test folder layout.
tests/hiddenSyntax/heading.test.ts New focused tests for ATX + Setext heading hiding/reveal rules.
tests/hiddenSyntax/blockquote.test.ts New focused tests for blockquote bars and GitHub alert markers.
tests/hiddenSyntax/block.test.ts New focused tests for inline images, block math, Mermaid blocks, and horizontal rules.
tests/hiddenSyntax.test.ts Removed monolithic hidden-syntax test file after split.
Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/hiddenSyntax/support.ts
Comment on lines +281 to +293
describe('Strikethrough syntax', () => {
test('hides both marks and reveals them when selected', () => {
const source = 'Before ~~deleted~~ after';
editor.setUp(source, hiddenSyntaxExtension);
window.editor.dispatch({ selection: { anchor: source.length } });

expect(editorText()).toBe('Before deleted after');
expect(window.editor.state.doc.toString()).toBe(source);

window.editor.dispatch({ selection: { anchor: 11 } });
expect(editorText()).toBe(source);
});
});

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The shared afterEach in tests/hiddenSyntax/support.ts unconditionally destroys window.editor, which can throw in tests that don’t create an editor (e.g., widget-only tests) and can break isolated test runs.

Review details

Suppressed comments (1)

tests/hiddenSyntax/support.ts:21

  • afterEach unconditionally calls window.editor.destroy(), but this file is imported by tests that don't create an editor (e.g. the widget-only ignoreEvent() tests in block.test.ts). Running those tests in isolation (or if setup fails early) will throw during teardown and mask the real failure. Guard the destroy call so teardown is safe when window.editor is absent.
afterEach(() => {
  vi.restoreAllMocks();
  window.editor.destroy();
  document.body.innerHTML = '';
});
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@cyanzhong
cyanzhong merged commit c97555e into main Sep 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants