forked from getopenscreen/openscreen
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: reset themed cursor when sidecar type is null or omitted #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+216
−22
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // @vitest-environment jsdom | ||
| import { cleanup, render, screen } from "@testing-library/react"; | ||
| import { afterEach, beforeEach, describe, expect, it } from "vitest"; | ||
| import { I18nProvider } from "@/contexts/I18nContext"; | ||
| import { LOCALE_STORAGE_KEY } from "@/i18n/config"; | ||
| import { CursorPane } from "./RightPanes"; | ||
|
|
||
| function stubStorage() { | ||
| const store = new Map<string, string>(); | ||
| const localStorage = { | ||
| getItem: (key: string) => store.get(key) ?? null, | ||
| setItem: (key: string, value: string) => { | ||
| store.set(key, value); | ||
| }, | ||
| removeItem: (key: string) => { | ||
| store.delete(key); | ||
| }, | ||
| clear: () => { | ||
| store.clear(); | ||
| }, | ||
| key: (index: number) => [...store.keys()][index] ?? null, | ||
| get length() { | ||
| return store.size; | ||
| }, | ||
| }; | ||
| Object.defineProperty(globalThis, "localStorage", { configurable: true, value: localStorage }); | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| stubStorage(); | ||
| window.localStorage.setItem(LOCALE_STORAGE_KEY, "en"); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| cleanup(); | ||
| }); | ||
|
|
||
| describe("CursorPane theme previews", () => { | ||
| it("full: hello-kitty-watermelon theme cell shows arrow and pointer", () => { | ||
| render( | ||
| <I18nProvider> | ||
| <CursorPane /> | ||
| </I18nProvider>, | ||
| ); | ||
| const cell = screen.getByRole("button", { name: "Hello Kitty & Watermelon" }); | ||
| expect(cell.querySelectorAll("img")).toHaveLength(2); | ||
| }); | ||
|
|
||
| it("empty: default theme cell shows a single preview img", () => { | ||
| render( | ||
| <I18nProvider> | ||
| <CursorPane /> | ||
| </I18nProvider>, | ||
| ); | ||
| const cell = screen.getByRole("button", { name: "Default" }); | ||
| expect(cell.querySelectorAll("img")).toHaveLength(1); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| CURSOR_THEMES, | ||
| type CursorTheme, | ||
| DEFAULT_CURSOR_SPRITES, | ||
| themePickerPreviewAssets, | ||
| } from "./cursorThemes"; | ||
|
|
||
| describe("themePickerPreviewAssets", () => { | ||
| it("hello-kitty-watermelon exposes distinct arrow and pointer", () => { | ||
| const theme = CURSOR_THEMES.find((t) => t.id === "hello-kitty-watermelon"); | ||
| if (!theme) { | ||
| throw new Error("hello-kitty-watermelon theme is missing from CURSOR_THEMES"); | ||
| } | ||
| const preview = themePickerPreviewAssets(theme); | ||
| expect(preview.arrow.length).toBeGreaterThan(0); | ||
| expect(preview.pointer).toBeTruthy(); | ||
| expect(preview.pointer).not.toBe(preview.arrow); | ||
| }); | ||
|
|
||
| it("arrow-only theme has no pointer preview", () => { | ||
| const theme: CursorTheme = { | ||
| id: "arrow-only", | ||
| name: "Arrow only", | ||
| assets: { | ||
| arrow: { | ||
| assetPath: "cursors/fake/arrow.png", | ||
| width: 32, | ||
| height: 32, | ||
| hotspotX: 0, | ||
| hotspotY: 0, | ||
| }, | ||
| }, | ||
| }; | ||
| const preview = themePickerPreviewAssets(theme); | ||
| expect(preview.arrow).toBe("cursors/fake/arrow.png"); | ||
| expect(preview.pointer).toBeNull(); | ||
| }); | ||
|
|
||
| it("default theme uses built-in arrow and pointer when they differ", () => { | ||
| const preview = themePickerPreviewAssets(null); | ||
| expect(preview.arrow).toBe(DEFAULT_CURSOR_SPRITES.arrow.assetPath); | ||
| if (DEFAULT_CURSOR_SPRITES.pointer.assetPath !== DEFAULT_CURSOR_SPRITES.arrow.assetPath) { | ||
| expect(preview.pointer).toBe(DEFAULT_CURSOR_SPRITES.pointer.assetPath); | ||
| } else { | ||
| expect(preview.pointer).toBeNull(); | ||
| } | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this changes cursor-state selection used by native compositor preview/export, the repository requires a cursor-focused manual E2E slice and a results-log row identifying the build, platform, and skipped coverage; I checked
technical-documentation/testing/manual-e2e-checklist.md, and there is no entry for this commit. Run the relevant native cursor preview/export checks on an available real platform and append the result, or log the checks as skipped with the environment reason, before treating the cross-platform behavior as verified.AGENTS.md reference: AGENTS.md:L86-L90
Useful? React with 👍 / 👎.