fix(setup): set dbtype value also for single-db

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2025-10-05 19:58:59 +02:00
parent 274cef169d
commit 646b2545d5
No known key found for this signature in database
GPG key ID: 4A81C29F63464E8F
2 changed files with 17 additions and 10 deletions

View file

@ -84,9 +84,13 @@ describe('Default setup page', () => {
cy.mockInitialState('core', 'config', config)
cy.mount(SetupView)
// No DB radio selectors if only sqlite
cy.get('[data-cy-setup-form-field^="dbtype"]')
.should('not.exist')
.should('exist')
.should('not.be.visible')
.find('input')
.should('be.checked')
cy.get('[data-cy-setup-form-field="dbtype-sqlite"]').should('exist')
// Two warnings: sqlite and single db support
cy.get('[data-cy-setup-form-db-note="sqlite"]')
@ -94,10 +98,10 @@ describe('Default setup page', () => {
cy.get('[data-cy-setup-form-db-note="single-db"]')
.should('be.visible')
// Admin login, password and data directory
// Admin login, password, data directory and db type
cy.get('[data-cy-setup-form-field]')
.should('be.visible')
.should('have.length', 3)
.should('have.length', 4)
})
it('Renders single DB mysql', () => {
@ -110,9 +114,11 @@ describe('Default setup page', () => {
cy.mockInitialState('core', 'config', config)
cy.mount(SetupView)
// No DB radio selectors if only mysql
cy.get('[data-cy-setup-form-field^="dbtype"]')
.should('not.exist')
.should('exist')
.should('not.be.visible')
.find('input')
.should('be.checked')
// Single db support warning
cy.get('[data-cy-setup-form-db-note="single-db"]')
@ -124,11 +130,11 @@ describe('Default setup page', () => {
cy.get('[data-cy-setup-form-db-note="sqlite"]')
.should('not.exist')
// Admin login, password, data directory, db user,
// Admin login, password, data directory, db type, db user,
// db password, db name and db host
cy.get('[data-cy-setup-form-field]')
.should('be.visible')
.should('have.length', 7)
.should('have.length', 8)
})
it('Changes fields from sqlite to mysql then oci', () => {

View file

@ -82,7 +82,8 @@
<!-- Database type select -->
<fieldset class="setup-form__database-type">
<p v-if="!firstAndOnlyDatabase" :class="`setup-form__database-type-select--${DBTypeGroupDirection}`" class="setup-form__database-type-select">
<!-- Using v-show instead of v-if ensures that the input dbtype remains set even when only one database engine is available -->
<p v-show="!firstAndOnlyDatabase" :class="`setup-form__database-type-select--${DBTypeGroupDirection}`" class="setup-form__database-type-select">
<NcCheckboxRadioSwitch v-for="(name, db) in config.databases"
:key="db"
v-model="config.dbtype"
@ -96,7 +97,7 @@
</NcCheckboxRadioSwitch>
</p>
<NcNoteCard v-else data-cy-setup-form-db-note="single-db" type="warning">
<NcNoteCard v-if="firstAndOnlyDatabase" data-cy-setup-form-db-note="single-db" type="warning">
{{ t('core', 'Only {firstAndOnlyDatabase} is available.', { firstAndOnlyDatabase }) }}<br>
{{ t('core', 'Install and activate additional PHP modules to choose other database types.') }}<br>
<a :href="links.adminSourceInstall" target="_blank" rel="noreferrer noopener">