The tag is a mandatory part of index.html - it carries serverUrl, serverType and the rest of the adapter config - so the missing-tag branch (deactivateApp plus an abort modal) goes. A missing tag is reported on the tag step itself instead, which is where the rest of the boot diagnostics already live, and the settings parse is null-safe so nothing throws on the way there.
94 lines
2.6 KiB
TypeScript
94 lines
2.6 KiB
TypeScript
import {
|
|
getSasjsTagDetails,
|
|
SASJS_TAG_STEP,
|
|
StartupCheckService
|
|
} from './startup-check.service'
|
|
|
|
describe('StartupCheckService', () => {
|
|
let service: StartupCheckService
|
|
|
|
beforeEach(() => {
|
|
service = new StartupCheckService()
|
|
})
|
|
|
|
it('includes a SASjs tag step after the startup checks', () => {
|
|
const steps = service.steps$.value
|
|
|
|
expect(steps.length).toBe(SASJS_TAG_STEP + 1)
|
|
expect(steps[SASJS_TAG_STEP].label).toBe('SASjs tag')
|
|
expect(steps[SASJS_TAG_STEP].status).toBe('pending')
|
|
})
|
|
|
|
it('shows the tag contents against the SASjs tag step', () => {
|
|
service.setTagDetails([{ name: 'serverType', value: 'SASVIYA' }])
|
|
|
|
expect(service.steps$.value[SASJS_TAG_STEP]).toEqual({
|
|
label: 'SASjs tag',
|
|
status: 'done',
|
|
details: [{ name: 'serverType', value: 'SASVIYA' }]
|
|
})
|
|
})
|
|
|
|
it('flags a missing tag on the SASjs tag step', () => {
|
|
service.updateStep(SASJS_TAG_STEP, 'error', 'SASJS TAG MISSING!!')
|
|
|
|
expect(service.steps$.value[SASJS_TAG_STEP]).toEqual({
|
|
label: 'SASjs tag',
|
|
status: 'error',
|
|
detail: 'SASJS TAG MISSING!!'
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('getSasjsTagDetails', () => {
|
|
const tagWith = (attributes: Record<string, string>) => {
|
|
const element = document.createElement('sasjs')
|
|
|
|
Object.entries(attributes).forEach(([name, value]) =>
|
|
element.setAttribute(name, value)
|
|
)
|
|
|
|
return element
|
|
}
|
|
|
|
it('reads the tag attributes as name/value pairs', () => {
|
|
const details = getSasjsTagDetails(
|
|
tagWith({ serverType: 'SASVIYA', debug: 'false', useComputeApi: 'true' })
|
|
)
|
|
|
|
expect(details).toEqual([
|
|
{ name: 'serverType', value: 'SASVIYA' },
|
|
{ name: 'debug', value: 'false' },
|
|
{ name: 'useComputeApi', value: 'true' }
|
|
])
|
|
})
|
|
|
|
it('keeps attributes the parser does not know about', () => {
|
|
expect(getSasjsTagDetails(tagWith({ serverTyp: 'SASJS' }))).toEqual([
|
|
{ name: 'servertyp', value: 'SASJS' }
|
|
])
|
|
})
|
|
|
|
it('shows every attribute, including the admin group and the licence key', () => {
|
|
const details = getSasjsTagDetails(
|
|
tagWith({
|
|
serverType: 'SASJS',
|
|
adminGroup: 'SASAdministrators',
|
|
hotLicenceKey: 'non-commercial-and-evaluation'
|
|
})
|
|
)
|
|
|
|
expect(details).toEqual([
|
|
{ name: 'serverType', value: 'SASJS' },
|
|
{ name: 'adminGroup', value: 'SASAdministrators' },
|
|
{ name: 'hotLicenceKey', value: 'non-commercial-and-evaluation' }
|
|
])
|
|
})
|
|
|
|
it('flags attributes that carry no value', () => {
|
|
expect(getSasjsTagDetails(tagWith({ runAsTask: '' }))).toEqual([
|
|
{ name: 'runAsTask', value: '(empty)' }
|
|
])
|
|
})
|
|
})
|