Fix: Update iframe selector to use 'preview-iframe' class#1453
Conversation
The 'Open in New Tab' button was not working because it was looking for an iframe with class 'preview', but the UI revamp changed it to 'preview-iframe'. This updates the JavaScript selector to match. - Update to in open-preview click handler - Update to in refreshPreview function Fixes the bug where clicking 'Open in New Tab' opened a blank page.
|
@ricardo-devis-agullo I was tempted to write a unit test like this in it('should have matching iframe element and JavaScript selector for preview functionality', () => {
const hasIframeElement = result.includes('class="preview-iframe"');
const hasMatchingJavaScript = result.includes("$('.preview-iframe')");
expect(hasIframeElement).to.be.true;
expect(hasMatchingJavaScript).to.be.true;
});However, I feel this test would be quite specific and fragile, testing implementation details (JS/HTML/CSS class matching) rather than the actual functionality. I'm not sure if it's worthwhile. |
|
thanks for the fix! I'd say we can merge this. Doing e2e tests to test the whole UI is nice but is a bigger story than this fix. There is technically a new file in preview/uiPreview.ts that you can run with Bun that starts a mocked local registry that you could attach playwright too, but its something that I might take on myself so no worries! |
|
Cool, sounds good! |
The 'Open in New Tab' button was not working because it was looking for an iframe with class 'preview', but the UI revamp changed it to 'preview-iframe'. This updates the JavaScript selector to match.
Fixes the bug where clicking 'Open in New Tab' opened a blank page.
Closing issues: #1452