-
Notifications
You must be signed in to change notification settings - Fork 768
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test): migrate
invisible-prehydration-false
to wdio (#5597)
* move test to wdio (not passing) * inject iframe
- Loading branch information
1 parent
f107e0f
commit 404d2ba
Showing
17 changed files
with
87 additions
and
109 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 was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
test/karma/test-app/invisible-prehydration-false/karma.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
test/karma/test-invisible-prehydration/stencil.invisiblePrehydrationFalse.config.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
import type { Config } from '../../internal/index.js'; | ||
|
||
export const config: Config = { | ||
namespace: 'TestInvisiblePrehydrationFalse', | ||
tsconfig: 'tsconfig-invisible-prehydration.json', | ||
invisiblePrehydration: false, | ||
outputTargets: [ | ||
{ | ||
type: 'www', | ||
empty: false, | ||
serviceWorker: null, | ||
dir: 'www-invisible-prehydration', | ||
}, | ||
], | ||
srcDir: 'invisible-prehydration', | ||
}; |
File renamed without changes.
File renamed without changes.
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,6 @@ | ||
<!doctype html> | ||
<meta charset="utf8" /> | ||
<script src="./build/testinvisibleprehydrationfalse.esm.js" type="module"></script> | ||
<script src="./build/testinvisibleprehydrationfalse.js" nomodule></script> | ||
|
||
<prehydrated-styles></prehydrated-styles> |
50 changes: 50 additions & 0 deletions
50
test/wdio/invisible-prehydration/invisible-prehydration.test.tsx
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,50 @@ | ||
/** | ||
* Note: this file is meant to be run in the browser, not in Node.js. WebdriverIO | ||
* injects some basic polyfills for Node.js to make the following possible. | ||
*/ | ||
import path from 'node:path'; | ||
|
||
async function setupTest(htmlFile: string): Promise<Document> { | ||
if (document.querySelector('iframe')) { | ||
document.body.removeChild(document.querySelector('iframe')); | ||
} | ||
|
||
const htmlFilePath = path.resolve( | ||
path.dirname(globalThis.__wdioSpec__), | ||
'..', | ||
'www-invisible-prehydration', | ||
htmlFile.slice(htmlFile.startsWith('/') ? 1 : 0), | ||
); | ||
const iframe = document.createElement('iframe'); | ||
|
||
/** | ||
* Note: prefixes the absolute path to the html file with `/@fs` is a ViteJS (https://vitejs.dev/) | ||
* feature which allows to serve static content from files this way | ||
*/ | ||
iframe.src = `/@fs${htmlFilePath}`; | ||
iframe.width = '600px'; | ||
iframe.height = '600px'; | ||
document.body.appendChild(iframe); | ||
|
||
/** | ||
* wait for the iframe to load | ||
*/ | ||
await new Promise((resolve) => (iframe.onload = resolve)); | ||
return iframe.contentDocument; | ||
} | ||
|
||
describe('invisible-prehydration-false', () => { | ||
let iframe: Document; | ||
|
||
beforeEach(async () => { | ||
iframe = await setupTest('index.html'); | ||
|
||
// Tried using the `browser.waitUntil()` pattern here, but it was flakey and throwing errors on occasion | ||
await browser.pause(100); | ||
}); | ||
|
||
it('the style element will not be placed in the head', async () => { | ||
expect(iframe.body.querySelector('prehydrated-styles').innerHTML).toEqual('<div>prehydrated-styles</div>'); | ||
expect(iframe.head.querySelectorAll('style[data-styles]').length).toBe(0); | ||
}); | ||
}); |
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,5 @@ | ||
{ | ||
"extends": "./tsconfig-stencil.json", | ||
"include": ["invisible-prehydration"], | ||
"exclude": ["invisible-prehydration/*.test.tsx"] | ||
} |
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