diff --git a/test/adminUx.test.ts b/test/adminUx.test.ts index ff14994..b306e3f 100644 --- a/test/adminUx.test.ts +++ b/test/adminUx.test.ts @@ -92,12 +92,12 @@ function checkText(where: string, kind: 'description' | 'label' | 'option', valu function walk(fields: Field[], path: string, problems: Problem[]) { for (const field of fields) { const f = field as { admin?: Record } & Field & Record - const where = `${path}.${'name' in f && f.name ? String(f.name) : f.type}` + const where = `${path}.${'name' in f && typeof f.name === 'string' && f.name ? f.name : f.type}` if (f.hidden || f.admin?.hidden || f.admin?.disabled) {continue} if (f.type === 'tabs') { for (const tab of (f as unknown as { tabs: ({ fields: Field[] } & Record)[] }).tabs) { - const tabWhere = `${path}.tab(${String(tab.name ?? JSON.stringify(tab.label))})` + const tabWhere = `${path}.tab(${typeof tab.name === 'string' ? tab.name : JSON.stringify(tab.label)})` checkText(tabWhere, 'label', tab.label, problems) if (tab.description) {checkText(tabWhere, 'description', tab.description, problems)} walk(tab.fields, tabWhere, problems) @@ -226,7 +226,7 @@ describe('admin languages', () => { const key = Object.keys(adminTexts.en)[0] const config = applyAdminI18n({ i18n: { supportedLanguages: { de } as never, translations: { de: { ipal: { [key]: 'Eigener Text' } } } as never }, - } as Config) + } as unknown as Config) expect(Object.keys(config.i18n!.supportedLanguages!)).toEqual(['de']) const translations = config.i18n!.translations as Record }> expect(translations.de.ipal[key]).toBe('Eigener Text') diff --git a/test/seoSearch.test.ts b/test/seoSearch.test.ts index b4ae10f..a1ac4ad 100644 --- a/test/seoSearch.test.ts +++ b/test/seoSearch.test.ts @@ -293,7 +293,7 @@ describe('plugin: Search engines tab', () => { const base = (): Config => ({ collections: [{ slug: 'users', auth: true, fields: [] }], secret: 'test' }) as unknown as Config const tabs = (c: Config) => { const settings = c.globals?.find((g) => g.slug === 'site-settings') - const field = settings?.fields[0] as { tabs: { label: { en: string } }[] } + const field = settings?.fields[0] as unknown as { tabs: { label: { en: string } }[] } return field.tabs.map((t) => t.label.en) } @@ -314,7 +314,7 @@ describe('plugin: Search engines tab', () => { twoFactor: false, })(base()) const settings = custom.globals?.find((g) => g.slug === 'site-settings') - const tab = (settings?.fields[0] as { tabs: { fields: { name?: string }[]; label: { en: string } }[] }).tabs.find((t) => t.label.en === 'Search engines') + const tab = (settings?.fields[0] as unknown as { tabs: { fields: { name?: string }[]; label: { en: string } }[] }).tabs.find((t) => t.label.en === 'Search engines') expect(tab?.fields.map((f) => f.name)).toEqual(['searchVerification', 'aiCrawlers']) }) }) diff --git a/test/submitForm.test.ts b/test/submitForm.test.ts index 65882e3..d8e0c1f 100644 --- a/test/submitForm.test.ts +++ b/test/submitForm.test.ts @@ -184,13 +184,13 @@ describe('submitForm — other gates', () => { }) test('validator messages: full sentences, Polish via localizedRules, own message wins', () => { - expect(required()('')).toBe('Fill in this field.') - expect(minLength(10)('abc')).toBe('Enter at least 10 characters.') + expect(required()('', {})).toBe('Fill in this field.') + expect(minLength(10)('abc', {})).toBe('Enter at least 10 characters.') const pl = localizedRules('pl-PL') - expect(pl.required()('')).toBe('Uzupełnij to pole.') - expect(pl.minLength(2)('a')).toBe('Wpisz co najmniej 2 znaki.') - expect(pl.minLength(5)('a')).toBe('Wpisz co najmniej 5 znaków.') - expect(pl.email('Mój tekst')('x')).toBe('Mój tekst') + expect(pl.required()('', {})).toBe('Uzupełnij to pole.') + expect(pl.minLength(2)('a', {})).toBe('Wpisz co najmniej 2 znaki.') + expect(pl.minLength(5)('a', {})).toBe('Wpisz co najmniej 5 znaków.') + expect(pl.email('Mój tekst')('x', {})).toBe('Mój tekst') }) test('the captcha field injected by the widget is not an unknown key', async () => {