@@ -465,6 +465,156 @@ describe('ApiConfiguration.vue', () => {
465465 } )
466466 } )
467467
468+ describe ( 'Comma-Separated Values' , ( ) => {
469+ describe ( 'Page Types' , ( ) => {
470+ it ( 'adds multiple page types when separated by commas' , async ( ) => {
471+ const wrapper = mount ( ApiConfiguration )
472+ getVm ( wrapper ) . store . pageTypes = [ ]
473+ getVm ( wrapper ) . pageTypeInput = 'landing_page,product_page,about_page'
474+ await wrapper . vm . $nextTick ( )
475+ const form = wrapper . findAll ( 'form' ) [ 0 ] !
476+ await form . trigger ( 'submit' )
477+ expect ( getVm ( wrapper ) . store . pageTypes ) . toContain ( 'landing_page' )
478+ expect ( getVm ( wrapper ) . store . pageTypes ) . toContain ( 'product_page' )
479+ expect ( getVm ( wrapper ) . store . pageTypes ) . toContain ( 'about_page' )
480+ expect ( getVm ( wrapper ) . store . pageTypes . length ) . toBe ( 3 )
481+ } )
482+
483+ it ( 'trims whitespace from each comma-separated page type' , async ( ) => {
484+ const wrapper = mount ( ApiConfiguration )
485+ getVm ( wrapper ) . store . pageTypes = [ ]
486+ getVm ( wrapper ) . pageTypeInput = ' landing_page , product_page , about_page '
487+ await wrapper . vm . $nextTick ( )
488+ const form = wrapper . findAll ( 'form' ) [ 0 ] !
489+ await form . trigger ( 'submit' )
490+ expect ( getVm ( wrapper ) . store . pageTypes ) . toEqual ( [
491+ 'landing_page' ,
492+ 'product_page' ,
493+ 'about_page' ,
494+ ] )
495+ } )
496+
497+ it ( 'filters out empty values in comma-separated page types' , async ( ) => {
498+ const wrapper = mount ( ApiConfiguration )
499+ getVm ( wrapper ) . store . pageTypes = [ ]
500+ getVm ( wrapper ) . pageTypeInput = 'landing_page,,product_page, ,about_page'
501+ await wrapper . vm . $nextTick ( )
502+ const form = wrapper . findAll ( 'form' ) [ 0 ] !
503+ await form . trigger ( 'submit' )
504+ expect ( getVm ( wrapper ) . store . pageTypes ) . toEqual ( [
505+ 'landing_page' ,
506+ 'product_page' ,
507+ 'about_page' ,
508+ ] )
509+ expect ( getVm ( wrapper ) . store . pageTypes . length ) . toBe ( 3 )
510+ } )
511+
512+ it ( 'does not add duplicate page types in comma-separated input' , async ( ) => {
513+ const wrapper = mount ( ApiConfiguration )
514+ getVm ( wrapper ) . store . pageTypes = [ 'landing_page' ]
515+ getVm ( wrapper ) . pageTypeInput = 'landing_page,product_page,landing_page'
516+ await wrapper . vm . $nextTick ( )
517+ const form = wrapper . findAll ( 'form' ) [ 0 ] !
518+ await form . trigger ( 'submit' )
519+ expect ( getVm ( wrapper ) . store . pageTypes ) . toEqual ( [ 'landing_page' , 'product_page' ] )
520+ expect ( getVm ( wrapper ) . store . pageTypes . length ) . toBe ( 2 )
521+ } )
522+
523+ it ( 'handles mixed duplicates and new values in comma-separated input' , async ( ) => {
524+ const wrapper = mount ( ApiConfiguration )
525+ getVm ( wrapper ) . store . pageTypes = [ 'landing_page' , 'contact_page' ]
526+ getVm ( wrapper ) . pageTypeInput = 'landing_page,product_page,about_page,contact_page'
527+ await wrapper . vm . $nextTick ( )
528+ const form = wrapper . findAll ( 'form' ) [ 0 ] !
529+ await form . trigger ( 'submit' )
530+ expect ( getVm ( wrapper ) . store . pageTypes ) . toContain ( 'landing_page' )
531+ expect ( getVm ( wrapper ) . store . pageTypes ) . toContain ( 'contact_page' )
532+ expect ( getVm ( wrapper ) . store . pageTypes ) . toContain ( 'product_page' )
533+ expect ( getVm ( wrapper ) . store . pageTypes ) . toContain ( 'about_page' )
534+ expect ( getVm ( wrapper ) . store . pageTypes . length ) . toBe ( 4 )
535+ } )
536+
537+ it ( 'clears input after adding comma-separated page types' , async ( ) => {
538+ const wrapper = mount ( ApiConfiguration )
539+ getVm ( wrapper ) . pageTypeInput = 'landing_page,product_page,about_page'
540+ await wrapper . vm . $nextTick ( )
541+ const form = wrapper . findAll ( 'form' ) [ 0 ] !
542+ await form . trigger ( 'submit' )
543+ expect ( getVm ( wrapper ) . pageTypeInput ) . toBe ( '' )
544+ } )
545+ } )
546+
547+ describe ( 'Collection Keys' , ( ) => {
548+ it ( 'adds multiple collection keys when separated by commas' , async ( ) => {
549+ const wrapper = mount ( ApiConfiguration )
550+ getVm ( wrapper ) . store . collectionKeys = [ ]
551+ getVm ( wrapper ) . collectionKeyInput = 'recipes,articles,products'
552+ await wrapper . vm . $nextTick ( )
553+ const forms = wrapper . findAll ( 'form' )
554+ await forms [ 1 ] ! . trigger ( 'submit' )
555+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toContain ( 'recipes' )
556+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toContain ( 'articles' )
557+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toContain ( 'products' )
558+ expect ( getVm ( wrapper ) . store . collectionKeys . length ) . toBe ( 3 )
559+ } )
560+
561+ it ( 'trims whitespace from each comma-separated collection key' , async ( ) => {
562+ const wrapper = mount ( ApiConfiguration )
563+ getVm ( wrapper ) . store . collectionKeys = [ ]
564+ getVm ( wrapper ) . collectionKeyInput = ' recipes , articles , products '
565+ await wrapper . vm . $nextTick ( )
566+ const forms = wrapper . findAll ( 'form' )
567+ await forms [ 1 ] ! . trigger ( 'submit' )
568+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toEqual ( [ 'recipes' , 'articles' , 'products' ] )
569+ } )
570+
571+ it ( 'filters out empty values in comma-separated collection keys' , async ( ) => {
572+ const wrapper = mount ( ApiConfiguration )
573+ getVm ( wrapper ) . store . collectionKeys = [ ]
574+ getVm ( wrapper ) . collectionKeyInput = 'recipes,,articles, ,products'
575+ await wrapper . vm . $nextTick ( )
576+ const forms = wrapper . findAll ( 'form' )
577+ await forms [ 1 ] ! . trigger ( 'submit' )
578+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toEqual ( [ 'recipes' , 'articles' , 'products' ] )
579+ expect ( getVm ( wrapper ) . store . collectionKeys . length ) . toBe ( 3 )
580+ } )
581+
582+ it ( 'does not add duplicate collection keys in comma-separated input' , async ( ) => {
583+ const wrapper = mount ( ApiConfiguration )
584+ getVm ( wrapper ) . store . collectionKeys = [ 'recipes' ]
585+ getVm ( wrapper ) . collectionKeyInput = 'recipes,articles,recipes'
586+ await wrapper . vm . $nextTick ( )
587+ const forms = wrapper . findAll ( 'form' )
588+ await forms [ 1 ] ! . trigger ( 'submit' )
589+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toEqual ( [ 'recipes' , 'articles' ] )
590+ expect ( getVm ( wrapper ) . store . collectionKeys . length ) . toBe ( 2 )
591+ } )
592+
593+ it ( 'handles mixed duplicates and new values in comma-separated input' , async ( ) => {
594+ const wrapper = mount ( ApiConfiguration )
595+ getVm ( wrapper ) . store . collectionKeys = [ 'recipes' , 'news' ]
596+ getVm ( wrapper ) . collectionKeyInput = 'recipes,articles,products,news'
597+ await wrapper . vm . $nextTick ( )
598+ const forms = wrapper . findAll ( 'form' )
599+ await forms [ 1 ] ! . trigger ( 'submit' )
600+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toContain ( 'recipes' )
601+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toContain ( 'news' )
602+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toContain ( 'articles' )
603+ expect ( getVm ( wrapper ) . store . collectionKeys ) . toContain ( 'products' )
604+ expect ( getVm ( wrapper ) . store . collectionKeys . length ) . toBe ( 4 )
605+ } )
606+
607+ it ( 'clears input after adding comma-separated collection keys' , async ( ) => {
608+ const wrapper = mount ( ApiConfiguration )
609+ getVm ( wrapper ) . collectionKeyInput = 'recipes,articles,products'
610+ await wrapper . vm . $nextTick ( )
611+ const forms = wrapper . findAll ( 'form' )
612+ await forms [ 1 ] ! . trigger ( 'submit' )
613+ expect ( getVm ( wrapper ) . collectionKeyInput ) . toBe ( '' )
614+ } )
615+ } )
616+ } )
617+
468618 describe ( 'Store Integration' , ( ) => {
469619 it ( 'reads token from store' , async ( ) => {
470620 const wrapper = mount ( ApiConfiguration )
0 commit comments