@@ -12,6 +12,7 @@ import { mockRoleBindingK8sResource } from '@odh-dashboard/internal/__mocks__/mo
1212import {
1313 DatabaseType ,
1414 FormFieldSelector ,
15+ MAX_MODEL_REGISTRY_NAME_LENGTH ,
1516 modelRegistrySettings ,
1617} from '../../../pages/modelRegistrySettings' ;
1718import { pageNotfound } from '../../../pages/pageNotFound' ;
@@ -336,51 +337,57 @@ describe('CreateModal', () => {
336337 modelRegistrySettings . shouldHaveAllErrors ( ) ;
337338 } ) ;
338339
339- it ( 'should enforce maxLength of 40 on the name input field' , ( ) => {
340+ it ( 'should enforce maxLength on the name input field' , ( ) => {
340341 modelRegistrySettings . visit ( true ) ;
341342 modelRegistrySettings . findCreateButton ( ) . click ( ) ;
342343 modelRegistrySettings
343344 . findFormField ( FormFieldSelector . NAME )
344- . should ( 'have.attr' , 'maxLength' , '40' ) ;
345+ . should ( 'have.attr' , 'maxLength' , String ( MAX_MODEL_REGISTRY_NAME_LENGTH ) ) ;
345346 } ) ;
346347
347- it ( 'should disable submit when resource name exceeds 40 characters ' , ( ) => {
348+ it ( 'should disable submit when resource name exceeds the character limit ' , ( ) => {
348349 modelRegistrySettings . visit ( true ) ;
349350 modelRegistrySettings . findCreateButton ( ) . click ( ) ;
350351 modelRegistrySettings . findDatabaseSourceDefaultRadio ( ) . should ( 'be.checked' ) ;
351352
352- modelRegistrySettings . findFormField ( FormFieldSelector . NAME ) . type ( 'a' . repeat ( 40 ) ) ;
353+ modelRegistrySettings
354+ . findFormField ( FormFieldSelector . NAME )
355+ . type ( 'a' . repeat ( MAX_MODEL_REGISTRY_NAME_LENGTH ) ) ;
353356 modelRegistrySettings . findSubmitButton ( ) . should ( 'be.enabled' ) ;
354357
355358 modelRegistrySettings . k8sNameDescription . findResourceEditLink ( ) . click ( ) ;
356- modelRegistrySettings . k8sNameDescription . findResourceNameInput ( ) . clear ( ) . type ( 'a' . repeat ( 41 ) ) ;
359+ modelRegistrySettings . k8sNameDescription
360+ . findResourceNameInput ( )
361+ . clear ( )
362+ . type ( 'a' . repeat ( MAX_MODEL_REGISTRY_NAME_LENGTH + 1 ) ) ;
357363 modelRegistrySettings . findSubmitButton ( ) . should ( 'be.disabled' ) ;
358364 } ) ;
359365
360- it ( 'should show character count warning when name approaches 40 limit' , ( ) => {
366+ it ( 'should show character count warning when name approaches the limit' , ( ) => {
361367 modelRegistrySettings . visit ( true ) ;
362368 modelRegistrySettings . findCreateButton ( ) . click ( ) ;
363369
364- const nearLimitName = 'a' . repeat ( 31 ) ;
370+ const nearLimitName = 'a' . repeat ( MAX_MODEL_REGISTRY_NAME_LENGTH - 9 ) ;
365371 modelRegistrySettings . findFormField ( FormFieldSelector . NAME ) . type ( nearLimitName ) ;
366- cy . contains ( ' Cannot exceed 40 characters' ) . should ( 'be.visible' ) ;
372+ cy . contains ( ` Cannot exceed ${ MAX_MODEL_REGISTRY_NAME_LENGTH } characters` ) . should ( 'be.visible' ) ;
367373 cy . contains ( 'remaining' ) . should ( 'be.visible' ) ;
368374 } ) ;
369375
370- it ( 'should allow creation with name at exactly 40 characters using default database' , ( ) => {
376+ it ( 'should allow creation with name at exactly the character limit using default database' , ( ) => {
371377 modelRegistrySettings . visit ( true ) ;
372378 modelRegistrySettings . findCreateButton ( ) . click ( ) ;
373379 modelRegistrySettings . findDatabaseSourceDefaultRadio ( ) . should ( 'be.checked' ) ;
374380
375- const exactName = 'a' . repeat ( 40 ) ;
381+ const exactName = 'a' . repeat ( MAX_MODEL_REGISTRY_NAME_LENGTH ) ;
376382 modelRegistrySettings . findFormField ( FormFieldSelector . NAME ) . type ( exactName ) ;
377383 modelRegistrySettings . findSubmitButton ( ) . should ( 'be.enabled' ) ;
378384 modelRegistrySettings . findSubmitButton ( ) . click ( ) ;
379385
380386 cy . wait ( '@createModelRegistry' ) . then ( ( interception ) => {
381- const expectedName = 'a' . repeat ( 40 ) ;
382- expect ( interception . request . body . modelRegistry . metadata . name ) . to . equal ( expectedName ) ;
383- expect ( interception . request . body . modelRegistry . metadata . name ) . to . have . length . at . most ( 40 ) ;
387+ expect ( interception . request . body . modelRegistry . metadata . name ) . to . equal ( exactName ) ;
388+ expect ( interception . request . body . modelRegistry . metadata . name ) . to . have . length . at . most (
389+ MAX_MODEL_REGISTRY_NAME_LENGTH ,
390+ ) ;
384391 } ) ;
385392 } ) ;
386393
0 commit comments