Load layouts and optional features from staged asset caches
This commit is contained in:
@@ -13,7 +13,7 @@ mkdirSync(publicDir);
|
||||
mkdirSync(dataDir);
|
||||
mkdirSync(join(publicDir, 'fonts'));
|
||||
mkdirSync(join(publicDir, 'icons'));
|
||||
writeFileSync(join(publicDir, 'index.html'), '<!doctype html><meta name="ytp-build" content="__BUILD_TAG__"><link rel="stylesheet" href="app.css"><script src="app.js"></script><script src="https://cdn.example/x.js"></script><link rel="stylesheet" href="/root.css">');
|
||||
writeFileSync(join(publicDir, 'index.html'), '<!doctype html><script type="application/json" id="ytp-assets">{}</script><meta name="ytp-build" content="__BUILD_TAG__"><link rel="stylesheet" href="app.css"><script src="app.js"></script><script src="https://cdn.example/x.js"></script><link rel="stylesheet" href="/root.css">');
|
||||
writeFileSync(join(publicDir, 'app.css'), 'body{}');
|
||||
writeFileSync(join(publicDir, 'app.js'), 'window.app=true;');
|
||||
writeFileSync(join(publicDir, 'root.css'), 'body{color:red}');
|
||||
@@ -219,6 +219,20 @@ describe('static delivery characterization', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('all index routes carry the identical embedded build-local map', async () => {
|
||||
const manifest=await (await fetch(`${server.base}/api/manifest`)).json();
|
||||
let expected;
|
||||
for(const path of ['/', '/index.html','/search','/playlist/x']) {
|
||||
const html=await (await fetch(`${server.base}${path}`)).text();
|
||||
const map=JSON.parse(html.match(/id="ytp-assets">([^<]+)<\/script>/)[1]);
|
||||
expect(map.buildTag).toBe(manifest.buildTag);
|
||||
expect(map.groups).toEqual(manifest.groups);
|
||||
expect(map.files['/app.js'].h).toBe(manifest.files['/app.js'].h);
|
||||
expect(map.files['/index.html']).toBeUndefined();
|
||||
if(expected)expect(html).toBe(expected);else expected=html;
|
||||
}
|
||||
});
|
||||
|
||||
test('SPA routes fall back to the stamped index', async () => {
|
||||
const { buildTag } = await (await fetch(`${server.base}/api/version`)).json();
|
||||
for (const path of ['/search', '/playlist/x']) {
|
||||
|
||||
Reference in New Issue
Block a user