@surrealdb/ui 1.2.4 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surrealdb/ui",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -1,8 +1,8 @@
1
1
  import { EditorView } from "@codemirror/view";
2
- import { page, userEvent } from "@vitest/browser/context";
3
2
  import { type ComponentType, createElement, type ReactElement } from "react";
4
3
  import { createRoot, type Root } from "react-dom/client";
5
4
  import { afterEach } from "vitest";
5
+ import { page, userEvent } from "vitest/browser";
6
6
 
7
7
  interface MountedStory {
8
8
  container: HTMLElement;
@@ -8,3 +8,25 @@ import * as projectAnnotations from "../../.storybook/preview";
8
8
  // vitest plugin does this for in-story `play` tests; the e2e project does it
9
9
  // here so cross-feature browser tests can mount existing stories verbatim.
10
10
  setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
11
+
12
+ // Vitest browser mode runs every e2e file in one shared Chromium page. The
13
+ // markdown fixtures render real anchors (`[link](https://…)`, `<Button href>`,
14
+ // autolinks) and clicking one navigates the whole page away. That kills the
15
+ // shared page for every following file — Vitest reports it on an unrelated file
16
+ // as "Cannot connect to the iframe … Did you change the location or submitted a
17
+ // form?" / "Failed to fetch dynamically imported module", which read as flaky
18
+ // cross-file failures on CI. These tests only assert caret/selection state, not
19
+ // real navigation, so neutralise the browser's default navigation while leaving
20
+ // the app's own click handlers (which place the caret) untouched.
21
+ if (typeof window !== "undefined" && !(window as { __e2eNavGuard?: boolean }).__e2eNavGuard) {
22
+ (window as { __e2eNavGuard?: boolean }).__e2eNavGuard = true;
23
+ window.addEventListener(
24
+ "click",
25
+ (event) => {
26
+ const anchor = (event.target as HTMLElement | null)?.closest?.("a[href]");
27
+ if (anchor) event.preventDefault();
28
+ },
29
+ true,
30
+ );
31
+ window.addEventListener("submit", (event) => event.preventDefault(), true);
32
+ }
@@ -1,8 +1,8 @@
1
1
  import { MantineProvider, Paper, v8CssVariablesResolver } from "@mantine/core";
2
2
  import { MarkdownEditor } from "@src/primitives/MarkdownEditor";
3
3
  import { MANTINE_THEME } from "@src/theme/mantine";
4
- import { page } from "@vitest/browser/context";
5
4
  import { describe, expect, it } from "vitest";
5
+ import { page } from "vitest/browser";
6
6
  import { getEditorView, mountStory, nextFrame } from "../../_setup/e2e-helpers";
7
7
 
8
8
  const DOC = 'Text with <Since v="1.5.0" /> inline here.\n';