|
@@ -162,6 +162,61 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
cy.findByRole('menu').should('not.exist')
|
|
cy.findByRole('menu').should('not.exist')
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it('should move the cursor when right-clicking a different position on the same line', function () {
|
|
|
|
|
+ grantClipboardPermissions()
|
|
|
|
|
+
|
|
|
|
|
+ const pasteContent = 'XX'
|
|
|
|
|
+ const scope = mockScope()
|
|
|
|
|
+
|
|
|
|
|
+ cy.mount(
|
|
|
|
|
+ <TestContainer>
|
|
|
|
|
+ <EditorProviders scope={scope}>
|
|
|
|
|
+ <CodeMirrorEditor />
|
|
|
|
|
+ </EditorProviders>
|
|
|
|
|
+ </TestContainer>
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ // Stub clipboard to return known content for pasting
|
|
|
|
|
+ cy.window().then(win => {
|
|
|
|
|
+ const getTypeStub = cy.stub()
|
|
|
|
|
+ getTypeStub
|
|
|
|
|
+ .withArgs('text/plain')
|
|
|
|
|
+ .resolves(new Blob([pasteContent], { type: 'text/plain' }))
|
|
|
|
|
+
|
|
|
|
|
+ cy.stub(win.navigator.clipboard, 'read').resolves([
|
|
|
|
|
+ {
|
|
|
|
|
+ types: ['text/plain'],
|
|
|
|
|
+ getType: getTypeStub,
|
|
|
|
|
+ },
|
|
|
|
|
+ ])
|
|
|
|
|
+ cy.stub(win.navigator.clipboard, 'readText').resolves(pasteContent)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ cy.get('.cm-line').eq(16).as('line')
|
|
|
|
|
+ cy.get('@line').click()
|
|
|
|
|
+ cy.get('@line').type('aaaa bbbb')
|
|
|
|
|
+
|
|
|
|
|
+ // Right-click the left side of the line — opens context menu with cursor near start
|
|
|
|
|
+ cy.get('@line').rightclick('left')
|
|
|
|
|
+ cy.findByRole('menu').should('be.visible')
|
|
|
|
|
+
|
|
|
|
|
+ // Right-click the right side of the same line while menu is still open —
|
|
|
|
|
+ // cursor should move to the end of the line
|
|
|
|
|
+ cy.get('@line').rightclick('right')
|
|
|
|
|
+ cy.findByRole('menu').should('be.visible')
|
|
|
|
|
+
|
|
|
|
|
+ // Paste via context menu — content goes wherever the cursor is
|
|
|
|
|
+ cy.findByRole('menu').within(() => {
|
|
|
|
|
+ cy.findByRole('menuitem', { name: pasteLabelMatcher }).click()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // If cursor moved: "aaaa bbbbXX" (pasted at end)
|
|
|
|
|
+ cy.get('@line').should($line => {
|
|
|
|
|
+ const text = $line.text()
|
|
|
|
|
+ expect(text).to.equal('aaaa bbbb' + pasteContent)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('should should close when clicking outside the editor', function () {
|
|
it('should should close when clicking outside the editor', function () {
|
|
|
const scope = mockScope()
|
|
const scope = mockScope()
|
|
|
const outsideEditorButtonName = 'Recompile'
|
|
const outsideEditorButtonName = 'Recompile'
|