feat: add javascript toggle controls for device previews#1481
feat: add javascript toggle controls for device previews#1481Dailin521 wants to merge 5 commits intoresponsively-org:mainfrom
Conversation
|
Added the local runtime verification screenshots here for reviewer convenience. These images are hosted in the dedicated public artifacts repository: Per-device JavaScript toggle: All previews JavaScript toggle: |
|
Quick follow-up here. CI is green and the current scope is still intentionally narrow, limited to the existing device preview JavaScript toggle paths. If this direction looks acceptable, I’m happy to make any small adjustments needed for merge. |
|
@Dailin521 Sorry for the delay in reviewing this, can you please check and make sure we have e2e test cases to cover this feature here: https://github.com/responsively-org/responsively-app/tree/main/desktop-app/e2e/tests? |
f6691bd to
cce53fb
Compare
|
Added the requested E2E coverage on the updated head. This now covers both paths under
The new tests also assert the related screenshot-disabled behavior and the preview remount behavior after toggling JavaScript. Fresh |
|
Pushed a follow-up fix for the first CI round. This only tightens the new E2E selectors so the test scopes to the first device toolbar more reliably and keeps the screenshot-all assertion stable when the disabled tooltip text changes. Fresh checks are running now. |
|
Pushed one more follow-up for the second CI round. The remaining failures were not selector-related anymore: on javascript=no webviews, Electron can reject executeJavaScript calls instead of returning a page-level undefined, so the new E2E assertions now treat that disabled-preview path as an expected execution failure signal and keep the enabled-preview checks intact. Fresh checks are running again. |


Summary
Add JavaScript toggle controls for device previews without remounting the React
Devicetree.Root cause
For #490, the
webviewmust be recreated for JavaScript mode changes becausewebpreferencesonly take effect when thewebviewis created. The earlier implementation rebuilt the whole preview device subtree, which left stale listeners and stale webview references in follow-up flows.Changes
Devicemounted and remount only the targetwebviewwhen JavaScript is toggledDeviceVerification
npm run typechecknpx eslint src/renderer/components/Previewer/Device/index.tsx src/renderer/components/Previewer/index.tsx src/renderer/components/Previewer/index.test.tsxnpm run test -- src/renderer/store/features/javascript/index.test.ts src/renderer/components/ToolBar/Menu/Flyout/JavaScriptControls/index.test.tsx src/renderer/components/Previewer/Device/Toolbar.test.tsx src/renderer/components/Previewer/index.test.tsxnpm run testwebviewwebviewsDeviceroots remain mounted in both flowsCloses #490