fix(admin): add favicon and page-aware titles
This commit is contained in:
42
admin/tests/app/pageTitle.test.ts
Normal file
42
admin/tests/app/pageTitle.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { documentTitleForRoute } from '../../src/app/pageTitle'
|
||||
import { setRecordCrumb } from '../../src/state/useBreadcrumbs'
|
||||
import { setNavigation } from '../../src/state/useNavigation'
|
||||
import { setSettings } from '../../src/state/useSettings'
|
||||
import { navigationFixture, settingsFixture } from '../fixtures/typed'
|
||||
import { resetState, routerAt, signIn } from '../helpers'
|
||||
|
||||
beforeEach(resetState)
|
||||
|
||||
describe('documentTitleForRoute', () => {
|
||||
it('uses the active controller label on list pages', async () => {
|
||||
await signIn()
|
||||
setNavigation(navigationFixture.data)
|
||||
const router = await routerAt('/acme/demo/widgets')
|
||||
expect(documentTitleForRoute(router.currentRoute.value)).toBe('Widgets | SummerCMS')
|
||||
})
|
||||
|
||||
it('uses the loaded record name on create, update and preview pages', async () => {
|
||||
await signIn()
|
||||
setNavigation(navigationFixture.data)
|
||||
setRecordCrumb('Blue widget')
|
||||
for (const path of ['/acme/demo/widgets/create', '/acme/demo/widgets/12', '/acme/demo/widgets/12/preview']) {
|
||||
const router = await routerAt(path)
|
||||
expect(documentTitleForRoute(router.currentRoute.value), path).toBe('Blue widget | SummerCMS')
|
||||
}
|
||||
})
|
||||
|
||||
it('uses the settings page label', async () => {
|
||||
await signIn()
|
||||
setSettings(settingsFixture.list.data)
|
||||
expect(documentTitleForRoute((await routerAt('/settings')).currentRoute.value)).toBe('Ustawienia | SummerCMS')
|
||||
expect(documentTitleForRoute((await routerAt('/settings/mail')).currentRoute.value)).toBe('Mail | SummerCMS')
|
||||
})
|
||||
|
||||
it('uses translated indicators for login, the empty home and not found', async () => {
|
||||
expect(documentTitleForRoute((await routerAt('/login')).currentRoute.value)).toBe('Witaj ponownie | SummerCMS')
|
||||
await signIn()
|
||||
expect(documentTitleForRoute((await routerAt('/')).currentRoute.value)).toBe('Brak dostępnych sekcji. | SummerCMS')
|
||||
expect(documentTitleForRoute((await routerAt('/nowhere')).currentRoute.value)).toBe('Nie znaleziono strony. | SummerCMS')
|
||||
})
|
||||
})
|
||||
@@ -19,6 +19,7 @@ beforeEach(() => {
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = ''
|
||||
document.title = ''
|
||||
})
|
||||
|
||||
enableAutoUnmount(afterEach)
|
||||
@@ -28,6 +29,7 @@ describe('app root', () => {
|
||||
const { wrapper } = await mountAt('/login')
|
||||
expect(wrapper.find('nav[aria-label="Wtyczki"]').exists()).toBe(false)
|
||||
expect(wrapper.find('form').exists()).toBe(true)
|
||||
expect(document.title).toBe('Witaj ponownie | SummerCMS')
|
||||
})
|
||||
|
||||
it('renders shell routes inside the shell and an unknown path as not found', async () => {
|
||||
@@ -37,6 +39,7 @@ describe('app root', () => {
|
||||
expect(wrapper.find('nav[aria-label="Wtyczki"]').exists()).toBe(true)
|
||||
expect(wrapper.findComponent(NotFoundView).exists()).toBe(true)
|
||||
expect(wrapper.find('main h1').text()).toBe('Nie znaleziono strony.')
|
||||
expect(document.title).toBe('Nie znaleziono strony. | SummerCMS')
|
||||
})
|
||||
|
||||
it('says so when the admin may open no plugin', async () => {
|
||||
|
||||
Reference in New Issue
Block a user