qazaq-legacy-foundation-web/src/components/contact-form-fields.test.ts
Peppa 9f77ca06f5
All checks were successful
peppa/lint lint: success за 2с
peppa/typecheck typecheck: success за 3с
peppa/test test: success за 1с
peppa/build build: success за 43с
ci / checks (pull_request) Successful in 1m30s
deploy / deploy (pull_request) Successful in 20s
QLFW-61: скрыть ловушку и защитить почту от подмены
2026-11-17 22:24:40 +05:00

24 lines
1.2 KiB
TypeScript

import { createElement } from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it, vi } from 'vitest'
import { getDict, locales } from '@/i18n'
import { ContactForm } from './ContactForm'
vi.mock('@/app/actions/inquiry', () => ({ submitInquiry: vi.fn() }))
describe('Только нужные поля и читаемая почта', () => {
for (const locale of locales) {
it(`Стили недоступны: ловушка скрыта, почта читаема (${locale})`, () => {
const html = renderToStaticMarkup(createElement(ContactForm, { t: getDict(locale), locale, email: 'qazaqlegacy@gmail.com' }))
expect(html).not.toContain('Website')
const trap = html.match(/<div[^>]*hidden[^>]*>[\s\S]*?<\/div>/)?.[0] ?? ''
expect(trap).toContain('style="display:none"')
expect(trap).toContain('name="website"')
expect(trap.toLowerCase()).toContain('tabindex="-1"')
expect(html).toContain('<!--email_off--><a href="mailto:qazaqlegacy@gmail.com"')
expect(html).toContain('>qazaqlegacy@gmail.com</a><!--/email_off-->')
expect(html).not.toContain('[email protected]')
})
}
})