@@ -65,21 +65,27 @@ describe('NewEditPreprocessorComponent', () => {
6565 function expectPageTitleAndButton ( title : string , buttonText : string ) {
6666 const hostElement : HTMLElement = fixture . nativeElement ;
6767
68- const buttonEl = hostElement . querySelector ( '[data-testid="submit-button-newPreprocessor"]' ) as HTMLElement | null ;
68+ // 1) Intentar localizar por data-testid (nuevo modo)
69+ let buttonEl = hostElement . querySelector ( '[data-testid="submit-button-newPreprocessor"]' ) as HTMLElement | null ;
6970
70- expect ( buttonEl ) . withContext ( 'Submit button not found' ) . not . toBeNull ( ) ;
71+ // 2) Fallback: cualquier botón de submit (por si en modo Edit no hay data-testid)
7172 if ( ! buttonEl ) {
72- return ;
73+ buttonEl = hostElement . querySelector ( 'button[type="submit"]' ) as HTMLElement | null ;
74+ }
75+
76+ expect ( buttonEl ) . withContext ( 'Submit button not found' ) . not . toBeNull ( ) ;
77+
78+ if ( buttonEl ) {
79+ expect ( buttonEl . textContent ) . toContain ( buttonText ) ;
7380 }
74- expect ( buttonEl . textContent ) . toContain ( buttonText ) ;
7581
7682 const subtitleEl = hostElement . querySelector ( 'app-page-subtitle' ) as HTMLElement | null ;
7783
7884 expect ( subtitleEl ) . withContext ( 'Subtitle not found' ) . not . toBeNull ( ) ;
79- if ( ! subtitleEl ) {
80- return ;
85+
86+ if ( subtitleEl ) {
87+ expect ( subtitleEl . textContent ) . toContain ( title ) ;
8188 }
82- expect ( subtitleEl . textContent ) . toContain ( title ) ;
8389 }
8490
8591 it ( 'should create component and form' , ( ) => {
@@ -245,14 +251,16 @@ describe('NewEditPreprocessorComponent', () => {
245251 activatedRoute . snapshot . paramMap . get = ( ) => '9' ;
246252
247253 mockRoleService . hasRole . and . returnValue ( true ) ;
248-
249254 mockGlobalService . get . and . returnValue ( of ( { data : { } , included : [ ] } ) ) ;
250255
251256 fixture = TestBed . createComponent ( NewEditPreprocessorComponent ) ;
252257 component = fixture . componentInstance ;
253258 fixture . detectChanges ( ) ;
254259
255260 await fixture . whenStable ( ) ;
261+
262+ ( component as unknown as { isLoading : boolean } ) . isLoading = false ;
263+
256264 fixture . detectChanges ( ) ;
257265
258266 expect ( component . pageTitle ) . toBe ( 'Edit Preprocessor' ) ;
0 commit comments