mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +00:00
* fix: disallow dots in application builder subdomain names * fix: reject Unicode dot equivalents in application builder subdomain names
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
import { describe, test, expect } from 'vitest'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import SubDomainForm from '@baserow/modules/builder/components/domain/SubDomainForm'
|
|
|
|
describe('SubDomainForm', () => {
|
|
const mountForm = () =>
|
|
mountSuspended(SubDomainForm, { props: { domain: 'test.com' } })
|
|
|
|
test('accepts a single label and builds the full domain name', async () => {
|
|
const wrapper = await mountForm()
|
|
|
|
await wrapper.find('input').setValue('hello')
|
|
|
|
expect(wrapper.vm.values.domain_name).toBe('hello.test.com')
|
|
expect(wrapper.vm.v$.domainPrefix.$error).toBe(false)
|
|
expect(wrapper.vm.isFormValid()).toBe(true)
|
|
})
|
|
|
|
test('rejects a name that contains a dot', async () => {
|
|
const wrapper = await mountForm()
|
|
|
|
await wrapper.find('input').setValue('hello.world')
|
|
|
|
expect(wrapper.vm.v$.domainPrefix.$error).toBe(true)
|
|
expect(wrapper.vm.v$.domainPrefix.noDot.$invalid).toBe(true)
|
|
expect(wrapper.text()).toContain('subDomainForm.noDotError')
|
|
expect(wrapper.vm.isFormValid()).toBe(false)
|
|
})
|
|
|
|
test.each(['\u3002', '\uFF0E', '\uFF61'])(
|
|
'rejects a name that contains the dot equivalent %j',
|
|
async (separator) => {
|
|
const wrapper = await mountForm()
|
|
|
|
await wrapper.find('input').setValue(`hello${separator}world`)
|
|
|
|
expect(wrapper.vm.v$.domainPrefix.noDot.$invalid).toBe(true)
|
|
expect(wrapper.vm.isFormValid()).toBe(false)
|
|
}
|
|
)
|
|
})
|