Skip to content

Commit

Permalink
Add validations to old events in migration helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Nov 28, 2024
1 parent b507076 commit d9b0e82
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/km-editor/migration/migrations-core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
28 changes: 25 additions & 3 deletions cypress/support/migration-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d9b0e82

Please sign in to comment.