test(boardwalk): cover the build id, the reload banner and the chunk reload guard (quick-261028-rqb)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { DEFAULT_BASE, readBase, runtime } from '../../src/app/runtime'
|
||||
import { DEFAULT_BASE, readBase, readBuild, runtime } from '../../src/app/runtime'
|
||||
|
||||
function docWith(content: string | null): Document {
|
||||
const doc = document.implementation.createHTMLDocument('test')
|
||||
@@ -39,3 +39,36 @@ describe('runtime base', () => {
|
||||
expect(DEFAULT_BASE).toBe('/backend')
|
||||
})
|
||||
})
|
||||
|
||||
function docWithBuild(content: string | null): Document {
|
||||
const doc = document.implementation.createHTMLDocument('test')
|
||||
if (content !== null) {
|
||||
const meta = doc.createElement('meta')
|
||||
meta.setAttribute('name', 'summer-admin-build')
|
||||
meta.setAttribute('content', content)
|
||||
doc.head.appendChild(meta)
|
||||
}
|
||||
return doc
|
||||
}
|
||||
|
||||
describe('runtime build', () => {
|
||||
it('reads a hex build id from the served meta', () => {
|
||||
expect(readBuild(docWithBuild('0123456789ab'))).toBe('0123456789ab')
|
||||
expect(readBuild(docWithBuild(' 0123456789ab '))).toBe('0123456789ab')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['a missing meta', null],
|
||||
['an empty value', ''],
|
||||
['the unreplaced build token', '__SUMMER_ADMIN_BUILD__'],
|
||||
['uppercase hex', '0123456789AB'],
|
||||
['a value with markup', '<b>0123456789ab</b>'],
|
||||
['a 65-character hex value', 'a'.repeat(65)],
|
||||
])('is empty for %s', (_label, content) => {
|
||||
expect(readBuild(docWithBuild(content))).toBe('')
|
||||
})
|
||||
|
||||
it('is empty in the test document, which carries no build', () => {
|
||||
expect(runtime.build).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user