@@ -33,7 +33,8 @@ import {
33
33
ComponentCollection ,
34
34
QuestionBooleanModel ,
35
35
QuestionRadiogroupModel ,
36
- PageModel
36
+ PageModel ,
37
+ ActionContainer
37
38
} from "survey-core" ;
38
39
import {
39
40
EmptySurveyCreatorOptions ,
@@ -236,8 +237,10 @@ test("dropdown property editor, get choices on callback", () => {
236
237
Serializer . removeProperty ( "survey" , "region" ) ;
237
238
} ) ;
238
239
test ( "Serializer.addpropery, type: 'dropdown' cuts the text before dots, provided into choices. Bug#5787" , ( ) : any => {
239
- Serializer . addProperty ( "survey" , { name : "prop1:dropdown" , type : "dropdown" ,
240
- choices : [ "Gemini 1.5 Pro" , "Claude 3.5 Sonnet" ] } ) ;
240
+ Serializer . addProperty ( "survey" , {
241
+ name : "prop1:dropdown" , type : "dropdown" ,
242
+ choices : [ "Gemini 1.5 Pro" , "Claude 3.5 Sonnet" ]
243
+ } ) ;
241
244
const survey = new SurveyModel ( ) ;
242
245
const propertyGrid = new PropertyGridModelTester ( survey ) ;
243
246
const question = propertyGrid . survey . getQuestionByName ( "prop1" ) ;
@@ -3108,9 +3111,11 @@ test("Do not select page on adding new page in the property grid #5564", () => {
3108
3111
expect ( creator . survey . pages ) . toHaveLength ( 1 ) ;
3109
3112
creator . selectElement ( creator . survey ) ;
3110
3113
const pagesQuestion = < QuestionMatrixDynamicModel > creator . propertyGrid . getQuestionByName ( "pages" ) ;
3114
+ expect ( pagesQuestion . visibleRows ) . toHaveLength ( 1 ) ;
3111
3115
const actions = pagesQuestion . getTitleActions ( ) ;
3112
3116
actions [ actions . length - 1 ] . action ( ) ;
3113
3117
expect ( creator . survey . pages ) . toHaveLength ( 2 ) ;
3118
+ expect ( pagesQuestion . visibleRows ) . toHaveLength ( 2 ) ;
3114
3119
expect ( ( < any > creator . selectedElement ) . pages ) . toHaveLength ( 2 ) ;
3115
3120
} ) ;
3116
3121
test ( "Setup correct categories for dynamic properties in components" , ( ) => {
@@ -3321,6 +3326,31 @@ test("check pages editor respects onPageAdding", () => {
3321
3326
expect ( creator . survey . pages . length ) . toBe ( 1 ) ;
3322
3327
settings . defaultNewSurveyJSON = savedNewJSON ;
3323
3328
} ) ;
3329
+ test ( "Localication and survey.pages property, Bug#6687" , ( ) => {
3330
+ const deutschStrings : any = {
3331
+ ed : {
3332
+ newPageName : "Seite"
3333
+ }
3334
+ } ;
3335
+ editorLocalization . locales [ "de" ] = deutschStrings ;
3336
+ settings . defaultNewSurveyJSON = { } ;
3337
+ const creator = new CreatorTester ( undefined , undefined , false ) ;
3338
+ creator . locale = "de" ;
3339
+ const propertyGrid = new PropertyGridModelTester ( creator . survey ) ;
3340
+ const pagesQuestion = < QuestionMatrixDynamicModel > (
3341
+ propertyGrid . survey . getQuestionByName ( "pages" )
3342
+ ) ;
3343
+ const propertyEditor = new PropertyGridEditorMatrixPages ( ) ;
3344
+ const options = { titleActions : [ ] , question : pagesQuestion } ;
3345
+ propertyEditor . onGetQuestionTitleActions ( creator . survey , options , creator ) ;
3346
+ const addNewPageAction = options . titleActions [ 0 ] as IAction ;
3347
+
3348
+ expect ( creator . survey . pages . length ) . toBe ( 0 ) ;
3349
+ addNewPageAction . action ! ( ) ;
3350
+
3351
+ expect ( creator . survey . pages . length ) . toBe ( 1 ) ;
3352
+ expect ( creator . survey . pages [ 0 ] . name ) . toBe ( "Seite1" ) ;
3353
+ } ) ;
3324
3354
test ( "Set property name into correct category" , ( ) => {
3325
3355
Serializer . addProperty ( "question" , {
3326
3356
name : "validation" ,
@@ -3665,4 +3695,29 @@ test("Undo for deleting validator in multiple text item, Bug#6295", () => {
3665
3695
creator . undo ( ) ;
3666
3696
expect ( item1 . validators ) . toHaveLength ( 1 ) ;
3667
3697
expect ( matrix . visibleRows ) . toHaveLength ( 1 ) ;
3668
- } ) ;
3698
+ } ) ;
3699
+ test ( "Pages Collection Editor - The Trash Bin (Remove) button is unavailable when you use the Add Page button Bug#6645" , ( ) => {
3700
+ const creator = new CreatorTester ( undefined , undefined , false ) ;
3701
+ const propertyGrid = new PropertyGridModelTester ( creator . survey , creator ) ;
3702
+ const pagesQuestion = < QuestionMatrixDynamicModel > propertyGrid . survey . getQuestionByName ( "pages" ) ;
3703
+ const rowsCount = pagesQuestion . visibleRows . length ;
3704
+ const action = pagesQuestion . getTitleActions ( ) . filter ( action => action . id === "add-item" ) [ 0 ] ;
3705
+ expect ( action ) . toBeTruthy ( ) ;
3706
+ action . action ( ) ;
3707
+ action . action ( ) ;
3708
+ expect ( pagesQuestion . visibleRows ) . toHaveLength ( rowsCount + 2 ) ;
3709
+
3710
+ const rows = pagesQuestion . renderedTable . rows ;
3711
+ expect ( rows [ 0 ] . isErrorsRow ) . toBeFalsy ( ) ;
3712
+ expect ( rows [ 0 ] . hasEndActions ) . toBeTruthy ( ) ;
3713
+ let cell = rows [ 0 ] . cells [ rows [ 0 ] . cells . length - 1 ] ;
3714
+ expect ( cell . isActionsCell ) . toBeTruthy ( ) ;
3715
+ let container = < ActionContainer > cell . item . value ;
3716
+ expect ( container . getActionById ( "remove-row" ) ) . toBeTruthy ( ) ;
3717
+ expect ( rows [ 2 ] . isErrorsRow ) . toBeFalsy ( ) ;
3718
+ expect ( rows [ 2 ] . hasEndActions ) . toBeTruthy ( ) ;
3719
+ cell = rows [ 2 ] . cells [ rows [ 2 ] . cells . length - 1 ] ;
3720
+ expect ( cell . isActionsCell ) . toBeTruthy ( ) ;
3721
+ container = < ActionContainer > cell . item . value ;
3722
+ expect ( container . getActionById ( "remove-row" ) ) . toBeTruthy ( ) ;
3723
+ } ) ;
0 commit comments