Skip to content

Commit

Permalink
Fix bug with allowing external websites and update test
Browse files Browse the repository at this point in the history
  • Loading branch information
JackWilb committed Oct 7, 2024
1 parent 949297c commit ba8434a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion public/demo-html/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@
"max": 7
}
]
},
"external_website": {
"type": "website",
"path": "https://www.revisit.dev",
"response": []
}
},
"sequence": {
"order": "fixed",
"components": [
"introduction",
"barChart"
"barChart",
"external_website"
]
}
}
6 changes: 5 additions & 1 deletion src/controllers/IframeController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ export default function IframeController({ currentConfig }: { currentConfig: Web
return (
<iframe
ref={ref}
src={`${BASE_PREFIX}${currentConfig.path}?trialid=${currentComponent}&id=${iframeId}`}
src={
currentConfig.path.startsWith('http')
? currentConfig.path
: `${BASE_PREFIX}${currentConfig.path}?trialid=${currentComponent}&id=${iframeId}`
}
style={defaultStyle}
/>
);
Expand Down
5 changes: 5 additions & 0 deletions tests/demo-html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ test('html demo works as intended', async ({ page }) => {
// Click on the next button
await page.getByRole('button', { name: 'Next', exact: true }).click();

const iframeContent = await page.frameLocator('iframe').getByRole('link', { name: 'Try The Demo' });
await expect(iframeContent).toBeVisible();

await page.getByRole('button', { name: 'Next', exact: true }).click();

// Check that the end of study text renders
const endText = await page.getByText('Please wait while your answers are uploaded.');
await expect(endText).toBeVisible();
Expand Down

0 comments on commit ba8434a

Please sign in to comment.