Electron test (regression): select all in code editor does not actually select all, just what is visiable (#3540)
* select all in code editor does not actually select all, just what is visible #3175 * whops * fix test for linux
This commit is contained in:
2
.github/workflows/playwright.yml
vendored
2
.github/workflows/playwright.yml
vendored
@ -346,7 +346,7 @@ jobs:
|
|||||||
run: yarn build:wasm
|
run: yarn build:wasm
|
||||||
- name: build electron
|
- name: build electron
|
||||||
shell: bash
|
shell: bash
|
||||||
run: yarn electron:package
|
run: yarn tron:package
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
if: ${{ !cancelled() && (success() || failure()) }}
|
if: ${{ !cancelled() && (success() || failure()) }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
@ -101,7 +101,7 @@ This will start the application and hot-reload on changed.
|
|||||||
|
|
||||||
Devtools can be opened with the usual Cmd/Ctrl-Shift-I.
|
Devtools can be opened with the usual Cmd/Ctrl-Shift-I.
|
||||||
|
|
||||||
To build, run `yarn electron:package`.
|
To build, run `yarn tron:package`.
|
||||||
|
|
||||||
## Checking out commits / Bisecting
|
## Checking out commits / Bisecting
|
||||||
|
|
||||||
|
@ -1112,6 +1112,73 @@ test(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
test(
|
||||||
|
'select all in code editor does not actually select all, just what is visible (regression)',
|
||||||
|
{ tag: '@electron' },
|
||||||
|
async ({ browserName }, testInfo) => {
|
||||||
|
const { electronApp, page } = await setupElectron({
|
||||||
|
testInfo,
|
||||||
|
folderSetupFn: async (dir) => {
|
||||||
|
// src/wasm-lib/tests/executor/inputs/mike_stress_test.kcl
|
||||||
|
const name = 'mike_stress_test'
|
||||||
|
await fsp.mkdir(`${dir}/${name}`, { recursive: true })
|
||||||
|
await fsp.copyFile(
|
||||||
|
`src/wasm-lib/tests/executor/inputs/${name}.kcl`,
|
||||||
|
`${dir}/${name}/main.kcl`
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const u = await getUtils(page)
|
||||||
|
await page.setViewportSize({ width: 1200, height: 500 })
|
||||||
|
|
||||||
|
page.on('console', console.log)
|
||||||
|
|
||||||
|
await page.getByText('mike_stress_test').click()
|
||||||
|
|
||||||
|
const modifier =
|
||||||
|
process.platform === 'win32' || process.platform === 'linux'
|
||||||
|
? 'Control'
|
||||||
|
: 'Meta'
|
||||||
|
|
||||||
|
await test.step('select all in code editor, check its length', async () => {
|
||||||
|
await u.codeLocator.click()
|
||||||
|
// expect u.codeLocator to have some text
|
||||||
|
await expect(u.codeLocator).toContainText('line(')
|
||||||
|
await page.keyboard.down(modifier)
|
||||||
|
await page.keyboard.press('KeyA')
|
||||||
|
await page.keyboard.up(modifier)
|
||||||
|
|
||||||
|
// check the length of the selected text
|
||||||
|
const selectedText = await page.evaluate(() => {
|
||||||
|
const selection = window.getSelection()
|
||||||
|
return selection ? selection.toString() : ''
|
||||||
|
})
|
||||||
|
// even though if the user copied the text into their clipboard they would get the full text
|
||||||
|
// it seems that the selection is limited to what is visible
|
||||||
|
// we just want to check we did select something, and later we've verify it's empty
|
||||||
|
expect(selectedText.length).toBeGreaterThan(10)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('delete all the text, select again and verify there are no characters left', async () => {
|
||||||
|
await page.keyboard.press('Backspace')
|
||||||
|
|
||||||
|
await page.keyboard.down(modifier)
|
||||||
|
await page.keyboard.press('KeyA')
|
||||||
|
await page.keyboard.up(modifier)
|
||||||
|
|
||||||
|
// check the length of the selected text
|
||||||
|
const selectedText = await page.evaluate(() => {
|
||||||
|
const selection = window.getSelection()
|
||||||
|
return selection ? selection.toString() : ''
|
||||||
|
})
|
||||||
|
expect(selectedText.length).toBe(0)
|
||||||
|
await expect(u.codeLocator).toHaveText('')
|
||||||
|
})
|
||||||
|
|
||||||
|
await electronApp.close()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'Settings persist across restarts',
|
'Settings persist across restarts',
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
|
10
package.json
10
package.json
@ -92,11 +92,11 @@
|
|||||||
"xstate:typegen": "yarn xstate typegen \"src/**/*.ts?(x)\"",
|
"xstate:typegen": "yarn xstate typegen \"src/**/*.ts?(x)\"",
|
||||||
"make:dev": "make dev",
|
"make:dev": "make dev",
|
||||||
"generate:machine-api": "npx openapi-typescript ./openapi/machine-api.json -o src/lib/machine-api.d.ts",
|
"generate:machine-api": "npx openapi-typescript ./openapi/machine-api.json -o src/lib/machine-api.d.ts",
|
||||||
"electron:start": "electron-forge start",
|
"tron:start": "electron-forge start",
|
||||||
"electron:package": "electron-forge package",
|
"tron:package": "electron-forge package",
|
||||||
"electron:make": "electron-forge make",
|
"tron:make": "electron-forge make",
|
||||||
"electron:publish": "electron-forge publish",
|
"tron:publish": "electron-forge publish",
|
||||||
"electron:e2e:local": "NODE_ENV=development yarn playwright test --config=playwright.electron.config.ts --grep=@electron"
|
"tron:test": "NODE_ENV=development yarn playwright test --config=playwright.electron.config.ts --grep=@electron"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
|
Reference in New Issue
Block a user