mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 00:08:25 +00:00
* fix: render the onboarding page server-side without crashing Vuelidate registers rules declared through the Options API `validations()` option inside `onBeforeMount`, which server-side rendering never runs. `v$` was therefore empty while DatabaseStep's template rendered `v$.name.$error`, so a cold SSR of /onboarding returned a 500. SSO logins hit this on every new user: the provider redirects to /dashboard, which server-redirects to /onboarding before any client JS runs. Register the rules through the composition form instead, so they exist during SSR, and move the misplaced optional chain in the form mixin so `v$.values` being absent no longer throws. Closes #6043 * chore: address review feedback Reword the changelog entry in user-facing terms and drop the `$registry` override from the SSR test, which never reached the component because it resolves the registry through `useNuxtApp()`.
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import { createSSRApp } from 'vue'
|
|
import { renderToString } from '@vue/server-renderer'
|
|
import { createI18n } from 'vue-i18n'
|
|
import { flushPromises } from '@vue/test-utils'
|
|
|
|
import { TestApp } from '@baserow/test/helpers/testApp'
|
|
import DatabaseStep from '@baserow/modules/database/components/onboarding/DatabaseStep'
|
|
|
|
describe('DatabaseStep', () => {
|
|
let testApp = null
|
|
|
|
beforeEach(() => {
|
|
testApp = new TestApp()
|
|
})
|
|
|
|
afterEach(() => {
|
|
testApp.afterEach()
|
|
})
|
|
|
|
const renderOnServer = () => {
|
|
const app = createSSRApp(DatabaseStep, { data: {} })
|
|
app.use(createI18n({ legacy: false, locale: 'en', messages: { en: {} } }))
|
|
app.use(testApp.store)
|
|
// The step components are registered globally by Nuxt, not by this app.
|
|
app.config.warnHandler = () => {}
|
|
app.config.globalProperties.$t = (key) => key
|
|
return renderToString(app)
|
|
}
|
|
|
|
test('renders the database name input server-side', async () => {
|
|
const html = await renderOnServer()
|
|
|
|
expect(html).toContain('databaseStep.databaseNameLabel')
|
|
})
|
|
|
|
test('shows a required error when the database name is cleared', async () => {
|
|
const wrapper = await testApp.mount(DatabaseStep, {
|
|
propsData: { data: {} },
|
|
})
|
|
|
|
await wrapper.find('input').setValue('')
|
|
await flushPromises()
|
|
|
|
expect(wrapper.find('.control__messages--error').text()).toBe(
|
|
'error.requiredField'
|
|
)
|
|
})
|
|
})
|