-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test that inserts Chaperon iframe
- Loading branch information
1 parent
069919b
commit 88e40bd
Showing
5 changed files
with
122 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
<h1>Chaperon!</h1> |
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 @@ | ||
|
||
<h1>hApp!</h1> | ||
|
||
<div id="main-content">Hello World</div> | ||
|
||
<script type="text/javascript"> | ||
window.addEventListener( "message", function ( event ) { | ||
console.log( event ); | ||
console.log( event.origin ); | ||
console.log( event.source ); | ||
console.log( event.data ); | ||
}); | ||
</script> | ||
|
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,76 @@ | ||
const path = require('path'); | ||
const log = require('@whi/stdlog')(path.basename( __filename ), { | ||
level: process.env.LOG_LEVEL || 'fatal', | ||
}); | ||
|
||
const fs = require('fs'); | ||
const assert = require('assert'); | ||
const axios = require('axios'); | ||
const expect = require('chai').expect; | ||
const puppeteer = require('puppeteer'); | ||
|
||
const http_servers = require('../setup.js'); | ||
|
||
|
||
describe("Testing COMB", function() { | ||
|
||
it('should insert Chaperon iframe into hApp window', async function () { | ||
// const setup = http_servers(); | ||
// log.debug("Setup config: %s", setup ); | ||
|
||
// try { | ||
// const happ_url = `http://localhost:${setup.ports.happ}/index.html`; | ||
// log.info("Fetch: %s", happ_url ); | ||
// const happ_resp = await axios.get( happ_url ); | ||
|
||
// expect( happ_resp.status ).to.equal( 200 ); | ||
|
||
// const chap_url = `http://localhost:${setup.ports.chaperon}/index.html`; | ||
// log.info("Fetch: %s", chap_url ); | ||
// const chap_resp = await axios.get( chap_url ); | ||
|
||
// expect( chap_resp.status ).to.equal( 200 ); | ||
// } finally { | ||
// await setup.close(); | ||
// } | ||
|
||
const setup = http_servers(); | ||
log.debug("Setup config: %s", setup.ports ); | ||
const browser = await puppeteer.launch(); | ||
|
||
try { | ||
const happ_url = `http://localhost:${setup.ports.happ}/index.html`; | ||
const chap_url = `http://localhost:${setup.ports.chaperon}/index.html`; | ||
|
||
const page = await browser.newPage(); | ||
|
||
log.info("Go to: %s", happ_url ); | ||
await page.goto( happ_url ); | ||
|
||
log.info("Add Chaperon iFrame: %s", chap_url ); | ||
await page.evaluate(( url ) => { | ||
const container = document.createElement("div"); | ||
container.innerHTML = `<iframe src="${url}"></iframe>`; | ||
|
||
document.body.appendChild( container ); | ||
}, chap_url ); | ||
|
||
const parent = page.mainFrame(); | ||
const frames = parent.childFrames(); | ||
log.debug("Frames: %s", frames.length ); | ||
|
||
expect( frames.length ).to.equal( 1 ); | ||
|
||
const chap_frame = frames[0]; | ||
|
||
await chap_frame.waitForNavigation(); | ||
|
||
expect( frames[0].url() ).to.equal( chap_url ); | ||
|
||
} finally { | ||
await browser.close(); | ||
await setup.close(); | ||
} | ||
}); | ||
|
||
}); |
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