forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(UI): Script displayed in preview when using specific css (freeCod…
…eCamp#56570) Co-authored-by: Oliver Eyton-Williams <[email protected]>
- Loading branch information
1 parent
edfb4bb
commit 51161b6
Showing
8 changed files
with
59 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import translations from '../client/i18n/locales/english/translations.json'; | ||
import { focusEditor } from './utils/editor'; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto( | ||
'/learn/javascript-algorithms-and-data-structures-v8/build-a-cash-register-project/build-a-cash-register' | ||
); | ||
}); | ||
|
||
test.describe('Preventing Script From Displaying in Preview', () => { | ||
// this test is for inserting problematic <style> tag and checking if the preview is empty | ||
|
||
test('should render an empty preview after inserting CSS', async ({ | ||
page, | ||
isMobile | ||
}) => { | ||
await focusEditor({ page, isMobile }); | ||
|
||
// the pain in the butt <style> tag with display: block rule into the editor | ||
const styleTag = ` | ||
<style> | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
display: block; | ||
} | ||
</style>`; | ||
await page.keyboard.insertText(styleTag); | ||
|
||
if (isMobile) { | ||
await page | ||
.getByRole('tab', { name: translations.learn['editor-tabs'].preview }) | ||
.click(); | ||
} | ||
|
||
// Checks that the iframe preview is empty | ||
const frame = page.frameLocator('#fcc-main-frame').first(); | ||
|
||
// Make sure there are no visible elements inside the iframe's body | ||
await expect(frame.locator('body')).toBeEmpty(); | ||
}); | ||
}); |