-
Notifications
You must be signed in to change notification settings - Fork 152
test(behavior): SDT right-arrow + shift-right navigation parity (SD-3237/SD-3218) #3561
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
Merged
Merged
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { test, expect, type SuperDocFixture } from '../../fixtures/superdoc.js'; | ||
| import { getInlineSdtRange, getInlineSdtSnapshot, caretLocation } from '../../helpers/sdt.js'; | ||
|
|
||
| /** | ||
| * Right-arrow at the inline SDT trailing edge. Word parity contract | ||
| * sdt/inline-right-arrow-trailing, Word 16.0 (lock-invariant) | ||
| * One press moves the caret from inside the control to just after it | ||
| * (inside-cc -> after-cc); navigation does not depend on lock mode. | ||
| * | ||
| * First consumer of the parity axis helper caretLocation(). | ||
| */ | ||
|
|
||
| test.use({ config: { toolbar: 'full', showSelection: true } }); | ||
|
|
||
| const DIR = path.dirname(fileURLToPath(import.meta.url)); | ||
| const FIXTURE = { | ||
| unlocked: path.resolve(DIR, 'fixtures/sd3237-inline-unlocked.docx'), | ||
| contentLocked: path.resolve(DIR, 'fixtures/sd3237-inline-contentlocked.docx'), | ||
| } as const; | ||
|
|
||
| test.describe('SDT Right-arrow at the trailing edge - Word parity', () => { | ||
| for (const mode of ['unlocked', 'contentLocked'] as const) { | ||
| test(`${mode}: one Right-arrow moves the caret from inside the SDT to after it`, async ({ superdoc }) => { | ||
| await superdoc.loadDocument(FIXTURE[mode]); | ||
| await superdoc.waitForStable(); | ||
| const sdt = await getInlineSdtRange(superdoc.page); | ||
| expect(sdt).not.toBeNull(); | ||
|
|
||
| await superdoc.setTextSelection(sdt!.end); // last position inside the content | ||
| await superdoc.page.evaluate(() => (window as any).editor.view.focus()); | ||
| await superdoc.waitForStable(); | ||
| expect(caretLocation(await getInlineSdtSnapshot(superdoc.page, sdt!.id), sdt!)).toBe('inside-cc'); | ||
|
|
||
| await superdoc.press('ArrowRight'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| const after = await getInlineSdtSnapshot(superdoc.page, sdt!.id); | ||
| expect(caretLocation(after, sdt!)).toBe('after-cc'); // exited in one press | ||
| expect(after.sdtExists).toBe(true); // navigation does not mutate | ||
| }); | ||
| } | ||
| }); |
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,55 @@ | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { test, expect, type SuperDocFixture } from '../../fixtures/superdoc.js'; | ||
| import { getInlineSdtRange, getInlineSdtSnapshot, selectionScope, type SelectionScope } from '../../helpers/sdt.js'; | ||
|
|
||
| /** | ||
| * Shift+Right extending a selection across the inline SDT leading boundary. | ||
| * Word parity contract sdt/inline-shift-right-boundary, Word 16.0 (lock-invariant). | ||
| * | ||
| * The parity fact: selection crosses into the control character-by-character | ||
| * (the scope progresses outside-cc -> cc-and-beyond), it never snaps to the | ||
| * whole control as a unit (whole-content-control). Lock-invariant. | ||
| * | ||
| * Consumes the parity axis helper selectionScope(). | ||
| */ | ||
|
|
||
| test.use({ config: { toolbar: 'full', showSelection: true } }); | ||
|
|
||
| const DIR = path.dirname(fileURLToPath(import.meta.url)); | ||
| const FIXTURE = { | ||
| unlocked: path.resolve(DIR, 'fixtures/sd3237-inline-unlocked.docx'), | ||
| contentLocked: path.resolve(DIR, 'fixtures/sd3237-inline-contentlocked.docx'), | ||
| } as const; | ||
|
|
||
| test.describe('SDT Shift+Right across the leading boundary - Word parity', () => { | ||
| for (const mode of ['unlocked', 'contentLocked'] as const) { | ||
| test(`${mode}: Shift+Right crosses into the SDT character-by-character, not atomically`, async ({ superdoc }) => { | ||
| await superdoc.loadDocument(FIXTURE[mode]); | ||
| await superdoc.waitForStable(); | ||
| const sdt = await getInlineSdtRange(superdoc.page); | ||
| expect(sdt).not.toBeNull(); | ||
|
|
||
| // Anchor in the text just before the SDT (mirrors the contract's | ||
| // outside-leading placement); a collapsed caret exactly on the node | ||
| // boundary steps into the node instead of extending. | ||
| await superdoc.setTextSelection(sdt!.pos - 2); | ||
| await superdoc.page.evaluate(() => (window as any).editor.view.focus()); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| const scopes: SelectionScope[] = []; | ||
| for (let i = 0; i < 6; i++) { | ||
| await superdoc.press('Shift+ArrowRight'); | ||
| await superdoc.waitForStable(); | ||
| scopes.push(selectionScope(await getInlineSdtSnapshot(superdoc.page, sdt!.id), sdt!)); | ||
| } | ||
|
|
||
| // Crossed into the content (overlaps + extends past the leading edge)... | ||
| expect(scopes).toContain('cc-and-beyond'); | ||
| // ...but never selected the whole control as a unit - character-granular. | ||
| expect(scopes).not.toContain('whole-content-control'); | ||
| // non-destructive | ||
| expect((await getInlineSdtSnapshot(superdoc.page, sdt!.id)).sdtExists).toBe(true); | ||
| }); | ||
| } | ||
| }); | ||
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.
When a regression makes
Shift+ArrowRightjump-select the entire content control while the anchor remains before the SDT (from < range.posandto === range.nodeEnd),selectionScope()classifies that selection ascc-and-beyond, so this assertion still passes even though the contract says the boundary is crossed character-by-character rather than atomically. Please assert the firstcc-and-beyondsnapshot stops inside the control, or otherwise capture per-step positions, before accepting this state.Useful? React with 👍 / 👎.