-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 3791-switch-client-code-from-js-to-ts
- Loading branch information
Showing
7 changed files
with
127 additions
and
42 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
53 changes: 53 additions & 0 deletions
53
container/cypress/e2e/test-app/iframe/iframe-settings.cy.js
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,53 @@ | ||
describe('Iframe Container Test', () => { | ||
let stub; | ||
|
||
beforeEach(() => { | ||
cy.visit('http://localhost:8080/iframe/iframe-settings.html'); | ||
stub = cy.stub(); | ||
}); | ||
|
||
it('defer-init flag for iframe container', () => { | ||
cy.get('#defer-init-test').then(iframe => { | ||
const $body = iframe.contents().find('main'); | ||
expect($body.children()).to.have.length(0); | ||
|
||
// click button that calls container.init() | ||
cy.get('#init-button').click(); | ||
|
||
cy.get('#defer-init-test') | ||
.shadow() | ||
.get('iframe') | ||
.then(iframe => { | ||
const $body = iframe.contents().find('body'); | ||
cy.wrap($body) | ||
.contains('defer-init test for iframes') | ||
.should('exist'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('set sandbox rules by property', () => { | ||
cy.get('#init-button').click(); | ||
cy.get('button[id="sandbox-rules"]').click(); | ||
|
||
cy.get('#defer-init-test') | ||
.shadow() | ||
.get('iframe') | ||
.then(elements => { | ||
cy.get(elements.first()) | ||
.invoke('attr', 'sandbox') | ||
.should('eq', 'allow-modals allow-popups'); | ||
}); | ||
}); | ||
|
||
it('set sandbox rules by attribute', () => { | ||
cy.get('#sandbox-rules-test') | ||
.shadow() | ||
.get('iframe') | ||
.then(elements => { | ||
cy.get(elements.last()) | ||
.invoke('attr', 'sandbox') | ||
.should('eq', 'allow-scripts allow-same-origin'); | ||
}); | ||
}); | ||
}); |
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,51 @@ | ||
<html> | ||
<head> | ||
<script type="module"> | ||
import '../bundle.js'; | ||
</script> | ||
</head> | ||
<body> | ||
<h3> | ||
This page is used to test Container Luigi CLient API functionalities for web | ||
component based microfrontend | ||
</h3> | ||
<button id="init-button">container.init() defer-init enabled</button> | ||
<button id="sandbox-rules">Set sandboxRules</button> | ||
|
||
<!-- Luigi Container to test defer-init flag--> | ||
<div style="border: solid 1px red; height: 100px"> | ||
<luigi-container | ||
id="defer-init-test" | ||
data-test-id="defer-init-container" | ||
viewURL="./microfrontend-defer-init.html" | ||
defer-init="true" | ||
></luigi-container> | ||
</div> | ||
|
||
<!-- Luigi Container to test sandbox rules --> | ||
<div style="border: solid 1px red; height: 100px"> | ||
<luigi-container | ||
id="sandbox-rules-test" | ||
viewURL="./microfrontend-sandbox-rules.html" | ||
sandbox-rules='["allow-scripts", "allow-same-origin"]' | ||
></luigi-container> | ||
</div> | ||
|
||
<script type="module"> | ||
import Events from '../bundle.js'; | ||
|
||
const deferInitContainer = document.getElementById('defer-init-test'); | ||
const initButton = document.getElementById('init-button'); | ||
|
||
initButton.addEventListener('click', function() { | ||
deferInitContainer.init(); | ||
}); | ||
|
||
const sandboxRulesButton = document.getElementById('sandbox-rules'); | ||
|
||
sandboxRulesButton.addEventListener('click', () => { | ||
deferInitContainer.sandboxRules = ['allow-modals', 'allow-popups']; | ||
}); | ||
</script> | ||
</body> | ||
</html> |
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
14 changes: 14 additions & 0 deletions
14
container/test-app/iframe/microfrontend-sandbox-rules.html
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,14 @@ | ||
<!-- This microfrontend HTML file is used to test sandbox rules functionality --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title></title> | ||
<meta charset="utf-8" /> | ||
</head> | ||
|
||
<body style="border: solid blue 2px;"> | ||
<div> | ||
<h1>sandbox rules test for iframes</h1> | ||
</div> | ||
</body> | ||
</html> |
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