|
| 1 | +import fs from 'node:fs'; |
| 2 | +import path from 'node:path'; |
| 3 | +import { describe, expect, it } from 'vitest'; |
| 4 | + |
| 5 | +const repoRoot = path.resolve(import.meta.dirname, '../..'); |
| 6 | + |
| 7 | +describe('loading startup shell', () => { |
| 8 | + it('starts behind the loading gate instead of preselecting a visual layout', () => { |
| 9 | + const html = fs.readFileSync(path.join(repoRoot, 'framework/index.html'), 'utf8'); |
| 10 | + |
| 11 | + expect(html).toContain('<html lang="en" data-course-loading="true">'); |
| 12 | + expect(html).not.toContain('data-layout="article"'); |
| 13 | + expect(html).not.toContain('data-sidebar-enabled="false"'); |
| 14 | + }); |
| 15 | + |
| 16 | + it('hides shell chrome and makes loading cover the full shell during startup', () => { |
| 17 | + const css = fs.readFileSync(path.join(repoRoot, 'framework/css/components/loading.css'), 'utf8'); |
| 18 | + |
| 19 | + expect(css).toContain('html[data-course-loading="true"] .course-header'); |
| 20 | + expect(css).toContain('html[data-course-loading="true"] .app-footer'); |
| 21 | + expect(css).toContain('position: fixed;'); |
| 22 | + expect(css).toContain('z-index: var(--z-overlay);'); |
| 23 | + }); |
| 24 | + |
| 25 | + it('removes the loading gate on every terminal startup path', () => { |
| 26 | + const appUi = fs.readFileSync(path.join(repoRoot, 'framework/js/app/AppUI.js'), 'utf8'); |
| 27 | + const mainJs = fs.readFileSync(path.join(repoRoot, 'framework/js/main.js'), 'utf8'); |
| 28 | + const removalCount = (mainJs.match(/removeAttribute\('data-course-loading'\)/g) || []).length; |
| 29 | + |
| 30 | + expect(appUi).toContain("document.documentElement.removeAttribute('data-course-loading');"); |
| 31 | + expect(removalCount).toBeGreaterThanOrEqual(2); |
| 32 | + }); |
| 33 | + |
| 34 | + it('still applies the course-config layout at runtime', () => { |
| 35 | + const mainJs = fs.readFileSync(path.join(repoRoot, 'framework/js/main.js'), 'utf8'); |
| 36 | + |
| 37 | + expect(mainJs).toContain("const layout = courseConfig.layout || 'article';"); |
| 38 | + expect(mainJs).toContain("html.setAttribute('data-layout', layout);"); |
| 39 | + }); |
| 40 | +}); |
0 commit comments