From 181e73f3c99561d613fe652d5c3208c2740b92ee Mon Sep 17 00:00:00 2001 From: JackUait Date: Sun, 16 Nov 2025 07:32:01 +0300 Subject: [PATCH] test: add missing test coverage --- .cursor/rules/fix-problems.mdc | 1 + .windsurf/rules/do-not-modify-configs.mdc | 23 + .windsurf/rules/fix-problems.mdc | 24 + .../rules/src/frontend/accessibility.mdc | 119 ++++ .../rules/src/frontend/code-style-eslint.mdc | 27 + .../src/frontend/fix-typescript-errors.mdc | 22 + .../src/frontend/frontend-simplicity.mdc | 69 ++ .../rules/src/frontend/lint-fix-policy.mdc | 24 + .windsurf/rules/test/e2e-best-practices.mdc | 37 + .yarn/install-state.gz | Bin 852421 -> 867165 bytes package.json | 5 +- src/components/polyfills.ts | 2 +- src/components/utils/notifier.ts | 4 +- src/components/utils/promise-queue.ts | 33 +- src/components/utils/resolve-aliases.ts | 10 +- .../block-tunes/block-tune-delete.test.ts | 70 ++ test/unit/components/block/block.test.ts | 355 ++++++++++ .../events/FakeCursorAboutToBeToggled.test.ts | 26 + .../components/events/block-settings.test.ts | 33 + test/unit/components/flipper.test.ts | 394 +++++++++++ test/unit/components/i18n/index.test.ts | 80 +++ .../inline-tools/inline-tool-convert.test.ts | 239 +++++++ .../inline-tools/inline-tool-link.test.ts | 293 ++++++++ test/unit/components/module-base.test.ts | 136 ++++ .../unit/components/modules/api/caret.test.ts | 218 ++++++ .../components/modules/api/events.test.ts | 78 +++ .../modules/api/inlineToolbar.test.ts | 67 ++ .../components/modules/api/listeners.test.ts | 89 +++ .../components/modules/api/readonly.test.ts | 92 +++ .../components/modules/api/sanitizer.test.ts | 48 ++ .../components/modules/api/selection.test.ts | 88 +++ .../unit/components/modules/api/tools.test.ts | 58 ++ .../components/modules/api/tooltip.test.ts | 93 +++ test/unit/components/modules/api/ui.test.ts | 91 +++ .../modules/toolbar/blockSettings.test.ts | 653 ++++++++++++++++++ test/unit/components/tools/factory.test.ts | 321 +++++++++ test/unit/components/utils/hint.test.ts | 68 ++ test/unit/components/utils/keyboard.test.ts | 72 ++ test/unit/components/utils/notifier.test.ts | 186 +++++ .../components/utils/popover-header.test.ts | 127 ++++ .../components/utils/resolve-aliases.test.ts | 63 ++ test/unit/components/utils/tools.test.ts | 60 ++ test/unit/tools/block-tune-adapter.test.ts | 156 +++++ test/unit/tools/stub.test.ts | 115 +++ test/unit/utils/api.test.ts | 85 +++ test/unit/utils/popover-item-html.test.ts | 157 +++++ .../unit/utils/popover-item-separator.test.ts | 35 + .../unit/utils/popover-states-history.test.ts | 82 +++ test/unit/utils/promise-queue.test.ts | 61 ++ yarn.lock | 172 ++++- 50 files changed, 5335 insertions(+), 26 deletions(-) create mode 100644 .windsurf/rules/do-not-modify-configs.mdc create mode 100644 .windsurf/rules/fix-problems.mdc create mode 100644 .windsurf/rules/src/frontend/accessibility.mdc create mode 100644 .windsurf/rules/src/frontend/code-style-eslint.mdc create mode 100644 .windsurf/rules/src/frontend/fix-typescript-errors.mdc create mode 100644 .windsurf/rules/src/frontend/frontend-simplicity.mdc create mode 100644 .windsurf/rules/src/frontend/lint-fix-policy.mdc create mode 100644 .windsurf/rules/test/e2e-best-practices.mdc create mode 100644 test/unit/components/block-tunes/block-tune-delete.test.ts create mode 100644 test/unit/components/block/block.test.ts create mode 100644 test/unit/components/events/FakeCursorAboutToBeToggled.test.ts create mode 100644 test/unit/components/events/block-settings.test.ts create mode 100644 test/unit/components/flipper.test.ts create mode 100644 test/unit/components/i18n/index.test.ts create mode 100644 test/unit/components/inline-tools/inline-tool-convert.test.ts create mode 100644 test/unit/components/inline-tools/inline-tool-link.test.ts create mode 100644 test/unit/components/module-base.test.ts create mode 100644 test/unit/components/modules/api/caret.test.ts create mode 100644 test/unit/components/modules/api/events.test.ts create mode 100644 test/unit/components/modules/api/inlineToolbar.test.ts create mode 100644 test/unit/components/modules/api/listeners.test.ts create mode 100644 test/unit/components/modules/api/readonly.test.ts create mode 100644 test/unit/components/modules/api/sanitizer.test.ts create mode 100644 test/unit/components/modules/api/selection.test.ts create mode 100644 test/unit/components/modules/api/tools.test.ts create mode 100644 test/unit/components/modules/api/tooltip.test.ts create mode 100644 test/unit/components/modules/api/ui.test.ts create mode 100644 test/unit/components/modules/toolbar/blockSettings.test.ts create mode 100644 test/unit/components/tools/factory.test.ts create mode 100644 test/unit/components/utils/hint.test.ts create mode 100644 test/unit/components/utils/keyboard.test.ts create mode 100644 test/unit/components/utils/notifier.test.ts create mode 100644 test/unit/components/utils/popover-header.test.ts create mode 100644 test/unit/components/utils/resolve-aliases.test.ts create mode 100644 test/unit/components/utils/tools.test.ts create mode 100644 test/unit/tools/block-tune-adapter.test.ts create mode 100644 test/unit/tools/stub.test.ts create mode 100644 test/unit/utils/api.test.ts create mode 100644 test/unit/utils/popover-item-html.test.ts create mode 100644 test/unit/utils/popover-item-separator.test.ts create mode 100644 test/unit/utils/popover-states-history.test.ts create mode 100644 test/unit/utils/promise-queue.test.ts diff --git a/.cursor/rules/fix-problems.mdc b/.cursor/rules/fix-problems.mdc index 2964987d..c7518773 100644 --- a/.cursor/rules/fix-problems.mdc +++ b/.cursor/rules/fix-problems.mdc @@ -12,6 +12,7 @@ VERY IMPORTANT: When encountering ANY problem in the code—such as TypeScript e - **Investigate root causes**: Use tools like debugging, logging, or code searches to understand why the problem occurs before fixing it. - **Align with existing rules**: Follow related policies such as the Fix TypeScript Errors Policy (adapt for other languages), ESLint configurations, and accessibility guidelines. - **Test the fix**: After fixing, verify with tests, linting runs (e.g., `yarn lint:fix`), or manual checks to ensure the problem is truly resolved without introducing new issues. +- **Terminal commands**: if you run a command in the terminal make sure to set timeout so the command is not being executed indefinitely ## When to Apply - During any code editing, reviewing, or generation task. diff --git a/.windsurf/rules/do-not-modify-configs.mdc b/.windsurf/rules/do-not-modify-configs.mdc new file mode 100644 index 00000000..bc24d21d --- /dev/null +++ b/.windsurf/rules/do-not-modify-configs.mdc @@ -0,0 +1,23 @@ +--- +alwaysApply: true +--- + +# Rule: DO NOT MODIFY configuration files unless explicitly instructed + +## Description +You MUST **never modify any configuration files** (such as `vite.config.ts`, `tsconfig.json`, `.eslintrc`, `package.json`, `.env`, etc.) **unless explicitly told to do so** in the current request or accompanying instructions. + +## Examples + +✅ **Allowed** +- Editing TypeScript source files, tests, or component code. +- Updating imports, logic, or styles within non-config files. +- Adding configuration changes **only when explicitly requested** (e.g., “Add a new alias in `vite.config.ts`”). + +❌ **Not Allowed** +- Modifying or creating any config files without explicit instruction. +- Automatically adding dependencies or changing build/test settings. +- Altering environment variables or global project settings without being told to. + +## Enforcement +If you believe a configuration change might be required, **ask for confirmation first** before proceeding. diff --git a/.windsurf/rules/fix-problems.mdc b/.windsurf/rules/fix-problems.mdc new file mode 100644 index 00000000..561e6f14 --- /dev/null +++ b/.windsurf/rules/fix-problems.mdc @@ -0,0 +1,24 @@ +--- +alwaysApply: true +--- + +# Fix Problems Policy + +## Core Principle +VERY IMPORTANT: When encountering ANY problem in the code—such as TypeScript errors, linting issues, runtime bugs, accessibility violations, or performance problems—you or any other problem MUST find a proper way to fix it. Do NOT silence, suppress, or avoid the problem using workarounds like `// @ts-ignore`, `any` types, or ignoring linter warnings. + +## Preferred Approaches +- **Refactor for correctness**: Resolve issues by improving the code structure, using precise types, type guards, proper error handling, and best practices. +- **Investigate root causes**: Use tools like debugging, logging, or code searches to understand why the problem occurs before fixing it. +- **Align with existing rules**: Follow related policies such as the Fix TypeScript Errors Policy (adapt for other languages), ESLint configurations, and accessibility guidelines. +- **Test the fix**: After fixing, verify with tests, linting runs (e.g., `yarn lint:fix`), or manual checks to ensure the problem is truly resolved without introducing new issues. + +## When to Apply +- During any code editing, reviewing, or generation task. +- Proactively scan for and fix problems in affected files using available tools (e.g., read_lints, grep, codebase_search). +- If a problem persists after reasonable efforts, document it clearly and suggest next steps rather than suppressing it. +- **Terminal commands**: if you run a command in the terminal make sure to set timeout so the command is not being executed indefinitely + +## Notes +- This policy promotes robust, high-quality code that is easier to maintain and less prone to future issues. +- If unsure how to fix a problem, use tools to gather more information or break it into smaller, solvable parts rather than bypassing it. diff --git a/.windsurf/rules/src/frontend/accessibility.mdc b/.windsurf/rules/src/frontend/accessibility.mdc new file mode 100644 index 00000000..085ff843 --- /dev/null +++ b/.windsurf/rules/src/frontend/accessibility.mdc @@ -0,0 +1,119 @@ +--- +alwaysApply: true +description: Enforce accessibility best practices so all users can use the application +--- + +### Accessibility guidance (must follow) + +- Semantics first + - Prefer semantic HTML (`button`, `a`, `nav`, `main`, `header`, `footer`, `ul/ol/li`, `table/th/td`) over generic `div`/`span`. + - Use `button` for actions and `a`/`Link` for navigation. Do not use click handlers on non-interactive elements. If unavoidable, add `role="button"`, `tabIndex={0}`, and keyboard handlers for Enter/Space. + +- Keyboard support + - All interactive controls must be reachable via Tab and operable via keyboard. + - Do not remove focus outlines. If customizing, ensure visible `:focus-visible` styles with sufficient contrast. + - Preserve a logical tab order; avoid `tabIndex` > 0. + +- Focus management + - On opening modals/drawers/popovers: move focus inside, trap focus, and restore focus to the trigger on close. + - Provide a skip link to main content (e.g., `href="#main"`) and landmark roles (`
`, `