-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs/issue 1004 document latest status for non standard import formats (
#1166) * update documentation around custom imports * update test case descriptions and add placeholder prerender typescript test case * update test case descriptions
- Loading branch information
1 parent
73fa84c
commit 925527c
Showing
10 changed files
with
168 additions
and
5 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
107 changes: 107 additions & 0 deletions
107
...ages/plugin-typescript/test/cases/exp-prerender.serve.ssr/exp-prerender.serve.ssr.spec.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,107 @@ | ||
/* | ||
* Use Case | ||
* Run Greenwood with a prerender HTML page that imports TypeScript. | ||
* | ||
* User Result | ||
* Should generate a Greenwood build that correctly builds and bundles all assets. | ||
* | ||
* User Command | ||
* greenwood build | ||
* | ||
* User Config | ||
* { | ||
* prerender: true, | ||
* plugins: [ | ||
* greenwoodPluginTypeScript() | ||
* ] | ||
* } | ||
* | ||
* User Workspace | ||
* src/ | ||
* components/ | ||
* card.ts | ||
* pages/ | ||
* index.html | ||
*/ | ||
import chai from 'chai'; | ||
import { JSDOM } from 'jsdom'; | ||
import path from 'path'; | ||
import { getSetupFiles, getOutputTeardownFiles } from '../../../../../test/utils.js'; | ||
import request from 'request'; | ||
import { Runner } from 'gallinago'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const expect = chai.expect; | ||
|
||
// TODO - this should work after this issue is resolved | ||
// https://github.com/ProjectEvergreen/wcc/issues/122 | ||
xdescribe('Serve Greenwood With: ', function() { | ||
const LABEL = 'A Prerendered Application (SSR) with an HTML page importing a TypeScript component'; | ||
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js'); | ||
const outputPath = fileURLToPath(new URL('.', import.meta.url)); | ||
const hostname = 'http://127.0.0.1:8080'; | ||
let runner; | ||
|
||
before(async function() { | ||
this.context = { | ||
publicDir: path.join(outputPath, 'public'), | ||
hostname | ||
}; | ||
runner = new Runner(false, true); | ||
}); | ||
|
||
describe(LABEL, function() { | ||
|
||
before(async function() { | ||
await runner.setup(outputPath, getSetupFiles(outputPath)); | ||
await runner.runCommand(cliPath, 'build'); | ||
|
||
return new Promise(async (resolve) => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 10000); | ||
|
||
await runner.runCommand(cliPath, 'serve'); | ||
}); | ||
}); | ||
|
||
describe('Serve command with SSR prerender specific behaviors for an HTML page', function() { | ||
let response = {}; | ||
|
||
before(async function() { | ||
return new Promise((resolve, reject) => { | ||
request.get(`${hostname}/`, (err, res, body) => { | ||
if (err) { | ||
reject(); | ||
} | ||
|
||
response = res; | ||
response.body = body; | ||
fragmentsApiDom = new JSDOM(body); | ||
|
||
resolve(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should return a 200 status', function(done) { | ||
expect(response.statusCode).to.equal(200); | ||
done(); | ||
}); | ||
|
||
it('should return a custom status message', function(done) { | ||
expect(response.statusMessage).to.equal('OK'); | ||
done(); | ||
}); | ||
|
||
// it should return the correct h1 contents | ||
// it should return the correct app-card contents | ||
}); | ||
}); | ||
|
||
after(function() { | ||
runner.teardown(getOutputTeardownFiles(outputPath)); | ||
runner.stopCommand(); | ||
}); | ||
|
||
}); |
8 changes: 8 additions & 0 deletions
8
packages/plugin-typescript/test/cases/exp-prerender.serve.ssr/greenwood.config.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,8 @@ | ||
import { greenwoodPluginTypeScript } from '../../../src/index.js'; | ||
|
||
export default { | ||
prerender: true, | ||
plugins: [ | ||
greenwoodPluginTypeScript() | ||
] | ||
}; |
4 changes: 4 additions & 0 deletions
4
packages/plugin-typescript/test/cases/exp-prerender.serve.ssr/package.json
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,4 @@ | ||
{ | ||
"name": "test-plugin-exp-prerender-ts", | ||
"type": "module" | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/plugin-typescript/test/cases/exp-prerender.serve.ssr/src/components/card/card.ts
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,26 @@ | ||
export default class Card extends HTMLElement { | ||
|
||
selectItem() { | ||
alert(`selected item is => ${this.getAttribute('title')}!`); | ||
} | ||
|
||
connectedCallback() { | ||
if (!this.shadowRoot) { | ||
const thumbnail: String = this.getAttribute('thumbnail'); | ||
const title: String = this.getAttribute('title'); | ||
const template: any = document.createElement('template'); | ||
|
||
template.innerHTML = ` | ||
<div> | ||
<h3>${title}</h3> | ||
<img src="${thumbnail}" alt="${title}" loading="lazy" width="100%"> | ||
<button onclick="this.parentNode.parentNode.host.selectItem()">View Item Details</button> | ||
</div> | ||
`; | ||
this.attachShadow({ mode: 'open' }); | ||
this.shadowRoot.appendChild(template.content.cloneNode(true)); | ||
} | ||
} | ||
} | ||
|
||
customElements.define('app-card', Card); |
16 changes: 16 additions & 0 deletions
16
packages/plugin-typescript/test/cases/exp-prerender.serve.ssr/src/pages/index.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,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" prefix="og:http://ogp.me/ns#"> | ||
|
||
<head> | ||
<script type="module" src="../components/card/card.ts"></script> | ||
</head> | ||
|
||
<body> | ||
<h1>Hello World!</h1> | ||
<app-card | ||
title="foo" | ||
thumbnail="bar.png" | ||
></app-card> | ||
</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
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