diff --git a/apps/client/cypress/e2e/specs/admin/system-settings.e2e.ts b/apps/client/cypress/e2e/specs/admin/system-settings.e2e.ts index 56e0f86e2a..9cba028059 100644 --- a/apps/client/cypress/e2e/specs/admin/system-settings.e2e.ts +++ b/apps/client/cypress/e2e/specs/admin/system-settings.e2e.ts @@ -1,4 +1,4 @@ -import type { SystemSettings } from '@cpn-console/shared' +import { type SystemSettings, SystemSettingsSchema } from '@cpn-console/shared' import { getModel } from '../../support/func.js' describe('Administration system settings', () => { @@ -7,7 +7,7 @@ describe('Administration system settings', () => { beforeEach(() => { cy.intercept('GET', 'api/v1/system/settings?key=maintenance').as('listMaintenanceSetting') cy.intercept('GET', 'api/v1/system/settings').as('listSystemSettings') - cy.intercept('POST', 'api/v1/system/settings').as('upsertSystemSetting') + cy.intercept('POST', 'api/v1/system/settings').as('upsertSystemSettings') cy.kcLogin('tcolin') cy.visit('/admin/system-settings') @@ -29,12 +29,13 @@ describe('Administration system settings', () => { cy.getByDataTestid(`toggle-maintenance`) .find('input') .check({ force: true }) - cy.wait('@upsertSystemSetting').its('response').then(($response) => { + + cy.getByDataTestid('button-submit') + .click() + + cy.wait('@upsertSystemSettings').its('response').then(($response) => { expect($response?.statusCode).to.match(/^20\d$/) - expect(JSON.stringify($response?.body)).to.equal(JSON.stringify({ - key: 'maintenance', - value: 'on', - })) + expect(JSON.stringify($response?.body)).to.equal(JSON.stringify(SystemSettingsSchema.parse({}))) }) cy.visit('/projects') @@ -83,12 +84,13 @@ describe('Administration system settings', () => { cy.getByDataTestid(`toggle-maintenance`) .find('input') .uncheck({ force: true }) - cy.wait('@upsertSystemSetting').its('response').then(($response) => { + + cy.getByDataTestid('button-submit') + .click() + + cy.wait('@upsertSystemSettings').its('response').then(($response) => { expect($response?.statusCode).to.match(/^20\d$/) - expect(JSON.stringify($response?.body)).to.equal(JSON.stringify({ - key: 'maintenance', - value: 'off', - })) + expect(JSON.stringify($response?.body)).to.equal(JSON.stringify(SystemSettingsSchema.parse({}))) }) cy.visit('/projects') diff --git a/apps/client/src/App.vue b/apps/client/src/App.vue index 02fa047bc0..89c0929ce0 100644 --- a/apps/client/src/App.vue +++ b/apps/client/src/App.vue @@ -42,11 +42,10 @@ watch(label, (label: string) => { const systemSettings = ref() const serviceStore = useServiceStore() -onBeforeMount(() => { - serviceStore.startHealthPolling() - serviceStore.checkServicesHealth() - - systemStore.listSystemSettings() +onBeforeMount(async () => { + await serviceStore.startHealthPolling() + await serviceStore.checkServicesHealth() + await systemStore.listSystemSettings() systemSettings.value = systemStore.systemSettings }) @@ -54,7 +53,7 @@ onBeforeMount(() => {