test(16.2-06): admin SPA coverage of plugin field types and View site
- fieldTypes: one load per script URL, failed and refused scripts reported, global styles enabled on every screen, empty list on failure - registry, formState, FormField and ListView: plugin renderers, locale maps, notices as literal text, unknown column types as text - AppShell: the View site link's href, target, rel and en/pl label
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils'
|
||||
import AppShell from '../../src/components/shell/AppShell.vue'
|
||||
@@ -5,7 +7,9 @@ import { setNavigation } from '../../src/state/useNavigation'
|
||||
import { NARROW_QUERY, setCollapsed } from '../../src/state/useSidebar'
|
||||
import { showToast } from '../../src/state/useToasts'
|
||||
import { navigationFixture } from '../fixtures/typed'
|
||||
import { setBundle } from '../../src/app/i18n'
|
||||
import { fakeMedia, resetState, routerAt, signIn } from '../helpers'
|
||||
import { langFixture } from '../fixtures/typed'
|
||||
|
||||
async function mountShell(path: string) {
|
||||
await signIn()
|
||||
@@ -77,3 +81,39 @@ describe('app shell', () => {
|
||||
expect(wrapper.find('[role="alert"]').text()).toContain('Broken')
|
||||
})
|
||||
})
|
||||
|
||||
describe('View site link (Phase 16.2 quick follow-up)', () => {
|
||||
it('opens the site root in a new tab without an opener or referrer', async () => {
|
||||
const wrapper = await mountShell('/acme/demo/widgets')
|
||||
const link = wrapper.find('header a[data-view-site]')
|
||||
expect(link.exists()).toBe(true)
|
||||
expect(link.attributes('href')).toBe(`${window.location.origin}/`)
|
||||
expect(link.attributes('target')).toBe('_blank')
|
||||
expect(link.attributes('rel')?.split(' ').sort()).toEqual(['noopener', 'noreferrer'])
|
||||
// It sits next to the user menu, inside the header.
|
||||
expect(link.element.nextElementSibling?.matches('[data-user-menu], :has([data-user-menu])')).toBe(true)
|
||||
expect(link.find('svg').attributes('aria-hidden')).toBe('true')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['pl', 'Zobacz stronę'],
|
||||
['en', 'View site'],
|
||||
])('labels the link from the phrasebook in %s', async (locale, label) => {
|
||||
setBundle({ ...langFixture.data, 'backend::lang.nav.view_site': { other: label } }, locale)
|
||||
const wrapper = await mountShell('/acme/demo/widgets')
|
||||
const link = wrapper.find('a[data-view-site]')
|
||||
expect(link.attributes('aria-label')).toBe(label)
|
||||
expect(link.attributes('title')).toBe(label)
|
||||
})
|
||||
|
||||
it('has the label key in the backend phrasebook for en and pl', () => {
|
||||
for (const [locale, label] of [
|
||||
['en', 'View site'],
|
||||
['pl', 'Zobacz stronę'],
|
||||
]) {
|
||||
// vitest runs from the admin directory.
|
||||
const yaml = readFileSync(resolve(process.cwd(), '../modules/phrasebook/backend/lang', locale!, 'lang.yaml'), 'utf8')
|
||||
expect(yaml).toMatch(new RegExp(`^nav:[\\s\\S]*?^ view_site: ${label}$`, 'm'))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user