From d9b0e8259d45ffa503c3b21a8b412093f2274721 Mon Sep 17 00:00:00 2001 From: Jan Slifka Date: Thu, 28 Nov 2024 14:25:52 +0100 Subject: [PATCH] Add validations to old events in migration helpers --- .../migration/migrations-core.spec.js | 2 +- cypress/support/migration-helpers.js | 28 +++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/km-editor/migration/migrations-core.spec.js b/cypress/e2e/km-editor/migration/migrations-core.spec.js index 59d8fbc..8b3bffe 100644 --- a/cypress/e2e/km-editor/migration/migrations-core.spec.js +++ b/cypress/e2e/km-editor/migration/migrations-core.spec.js @@ -64,7 +64,7 @@ describe('KM Editor Migrations', () => { }) // CHAPTER - it('can migrate with applying "add chapter"', () => { + it.only('can migrate with applying "add chapter"', () => { migration.createMigration(config, '1.0.0', '1.1.0') cy.contains('Add chapter') diff --git a/cypress/support/migration-helpers.js b/cypress/support/migration-helpers.js index 5e5db7a..c92f2e7 100644 --- a/cypress/support/migration-helpers.js +++ b/cypress/support/migration-helpers.js @@ -93,10 +93,32 @@ function updateIntegrationEvent2(event) { return event } +// 4.13.0 - validations added to ValueQuestion +function updateValidations(event) { + const newFields = [ + ['validations', []], + ] + + if (event.eventType === 'AddQuestionEvent' && event.questionType === 'ValueQuestion') { + newFields.forEach(([fieldName, defaultValue]) => { + if (event[fieldName] === undefined) { + event[fieldName] = defaultValue + } + }) + } else if (event.eventType === 'EditQuestionEvent' && event.questionType === 'ValueQuestion') { + if (event.validations === undefined) { + event.validations = [] + } + } + + return event +} + function updateEvent(event) { - return updateIntegrationEvent2( - updateIntegrationRequestHeaders( - updateIntegrationEvent(event))) + return updateValidations( + updateIntegrationEvent2( + updateIntegrationRequestHeaders( + updateIntegrationEvent(event)))) } export function verifyPackageWithBundle(packageId, fixtureName, pkgParams, checkEventUuid = true) {