Skip to content

Commit e913ca6

Browse files
committed
Add KM editor warnings and item select question
1 parent 49751bd commit e913ca6

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

cypress/e2e/km-editor/editor/add.spec.js

+38
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,44 @@ describe('KM Editor Add Entity', () => {
611611
})
612612
})
613613

614+
describe('Item Select Question', () => {
615+
it('add Item Select Question', () => {
616+
const chapter = { title: 'My Chapter' }
617+
const listQuestion = {
618+
s_type: 'List',
619+
title: 'List all project colors'
620+
}
621+
622+
const itemSelectQuestion = {
623+
s_type: 'ItemSelect',
624+
title: 'What is your favorite color?',
625+
s_listQuestionUuid: listQuestion.title
626+
}
627+
628+
// Add item select question and its parents
629+
editor.open(kmId)
630+
editor.createChildren([['chapter', chapter], ['question', listQuestion]])
631+
632+
// Get uuid of created list question
633+
cy.url().then((url) => {
634+
const listQuestionUuid = url.split('/').pop()
635+
636+
// Create the item select question
637+
cy.getCy('breadcrumb-item').contains(chapter.title).click()
638+
editor.createChildren([['question', itemSelectQuestion]])
639+
640+
// Reopen editor again and check that the item select question is there
641+
cy.visitApp('/km-editor')
642+
editor.open(kmId)
643+
editor.traverseChildren([chapter.title, itemSelectQuestion.title])
644+
645+
// We need to use uuid for the check
646+
itemSelectQuestion.s_listQuestionUuid = listQuestionUuid
647+
cy.checkFields(itemSelectQuestion)
648+
})
649+
})
650+
})
651+
614652
// Resource Collections ------------------------------------------------------------------------------
615653

616654
describe('Resource Collection', () => {

cypress/e2e/km-editor/editor/warnings.spec.js

+63-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,26 @@ describe('KM Editor Warnings', () => {
8585
cy.checkFields(question)
8686
})
8787

88+
it('Question Item Select', () => {
89+
const chapter = {
90+
title: 'Chapter 1',
91+
text: 'This chapter text'
92+
}
93+
const question = {
94+
s_type: 'ItemSelect',
95+
title: 'Question 1',
96+
text: 'This question text'
97+
}
98+
editor.createChildren([['chapter', chapter], ['question', question]])
99+
100+
cy.visitApp('/km-editor')
101+
editor.open(kmId)
102+
editor.expectWarningsCount(1)
103+
editor.openWarnings()
104+
cy.contains('No list question selected for item select question').click()
105+
cy.checkFields(question)
106+
})
107+
88108
it('Question Choices', () => {
89109
const chapter = {
90110
title: 'Chapter 1',
@@ -353,4 +373,46 @@ describe('KM Editor Warnings', () => {
353373
cy.checkFields(integration)
354374
})
355375
})
356-
})
376+
377+
it('Resource Collection', () => {
378+
editor.createChildren([
379+
['resource-collection', {}]
380+
])
381+
382+
const warnings = [
383+
'Empty title for resource collection'
384+
]
385+
386+
warnings.forEach(warning => {
387+
cy.visitApp('/km-editor')
388+
editor.open(kmId)
389+
editor.expectWarningsCount(warnings.length)
390+
editor.openWarnings()
391+
cy.contains(warning).click()
392+
})
393+
})
394+
395+
it('Resource Page', () => {
396+
const resourceCollection = {
397+
title: 'Resource Collection'
398+
}
399+
400+
editor.createChildren([
401+
['resource-collection', resourceCollection],
402+
['resource-page', {}]
403+
])
404+
405+
const warnings = [
406+
'Empty title for resource page',
407+
'Empty content for resource page',
408+
]
409+
410+
warnings.forEach(warning => {
411+
cy.visitApp('/km-editor')
412+
editor.open(kmId)
413+
editor.expectWarningsCount(warnings.length)
414+
editor.openWarnings()
415+
cy.contains(warning).click()
416+
})
417+
})
418+
})

0 commit comments

Comments
 (0)