@@ -123,11 +123,10 @@ export const AssessmentTestsPanel = ({
123123 } ;
124124 } , [ activeTab , extractProfessionalAreaFromDiagnostic , formatInterestedRole ] ) ;
125125
126- const contextualProfessionalArea = testsContext ?. professionalArea ;
127-
128126 const buildFallbackTest = useCallback ( (
129127 type : 'TECHNICAL' | 'PSYCHOTECHNICAL' ,
130128 questions : AssessmentTestQuestion [ ] ,
129+ context ?: GenerateTestsForProfileDto ,
131130 ) : GeneratedTest => ( {
132131 id : `${ type . toLowerCase ( ) } -fallback-test` ,
133132 name :
@@ -136,18 +135,19 @@ export const AssessmentTestsPanel = ({
136135 : 'Prueba psicotecnica inicial' ,
137136 description :
138137 type === 'TECHNICAL'
139- ? contextualProfessionalArea
140- ? `Evaluacion tecnica generada para ${ contextualProfessionalArea } a partir de preguntas base del sistema.`
138+ ? context ?. professionalArea
139+ ? `Evaluacion tecnica generada para ${ context . professionalArea } a partir de preguntas base del sistema.`
141140 : 'Evaluacion tecnica general generada a partir de preguntas base del sistema.'
142141 : 'Evaluacion psicotecnica general generada a partir de preguntas base del sistema.' ,
143142 type,
144143 questionCount : questions . length ,
145144 estimatedDurationMin : Math . max ( 10 , Math . ceil ( questions . length * 1.5 ) ) ,
146145 questions,
147- } ) , [ contextualProfessionalArea ] ) ;
146+ } ) , [ ] ) ;
148147
149148 const withFallbackTests = useCallback ( async (
150149 tests : GeneratedTestsResponseDto ,
150+ context : GenerateTestsForProfileDto ,
151151 ) : Promise < GeneratedTestsResponseDto > => {
152152 const nextTests : GeneratedTestsResponseDto = {
153153 ...tests ,
@@ -156,17 +156,17 @@ export const AssessmentTestsPanel = ({
156156 } ;
157157
158158 if ( activeTab === 'Tecnica' && nextTests . technicalTests . length === 0 ) {
159- const technicalQuestions = await getTechnicalTestQuestionsForContext ( testsContext ?? undefined ) . catch ( ( ) => [ ] ) ;
159+ const technicalQuestions = await getTechnicalTestQuestionsForContext ( context ) . catch ( ( ) => [ ] ) ;
160160 if ( technicalQuestions . length > 0 ) {
161- nextTests . technicalTests = [ buildFallbackTest ( 'TECHNICAL' , technicalQuestions ) ] ;
161+ nextTests . technicalTests = [ buildFallbackTest ( 'TECHNICAL' , technicalQuestions , context ) ] ;
162162 }
163163 }
164164
165165 if ( activeTab === 'Psicotecnica' && nextTests . psychotechnicalTests . length === 0 ) {
166166 const psychotechnicalQuestions = await getPsychotechnicalTestQuestions ( ) . catch ( ( ) => [ ] ) ;
167167 if ( psychotechnicalQuestions . length > 0 ) {
168168 nextTests . psychotechnicalTests = [
169- buildFallbackTest ( 'PSYCHOTECHNICAL' , psychotechnicalQuestions ) ,
169+ buildFallbackTest ( 'PSYCHOTECHNICAL' , psychotechnicalQuestions , context ) ,
170170 ] ;
171171 }
172172 }
@@ -175,7 +175,7 @@ export const AssessmentTestsPanel = ({
175175 nextTests . technicalTests . length + nextTests . psychotechnicalTests . length ;
176176
177177 return nextTests ;
178- } , [ activeTab , buildFallbackTest , testsContext ] ) ;
178+ } , [ activeTab , buildFallbackTest ] ) ;
179179
180180 const getTestsForTab = ( testsResponse ?: GeneratedTestsResponseDto | null ) : GeneratedTest [ ] => {
181181 const source = testsResponse ?? generatedTests ;
@@ -191,7 +191,7 @@ export const AssessmentTestsPanel = ({
191191 const nextContext = await buildTestsContext ( ) ;
192192 setTestsContext ( nextContext ) ;
193193 const tests = await generateTestsForProfile ( nextContext ) ;
194- const normalizedTests = await withFallbackTests ( tests ) ;
194+ const normalizedTests = await withFallbackTests ( tests , nextContext ) ;
195195 setGeneratedTests ( normalizedTests ) ;
196196 return normalizedTests ;
197197 } catch ( error ) {
@@ -447,6 +447,7 @@ export const AssessmentTestsPanel = ({
447447 : 'Iniciar prueba psicotecnica' ;
448448 const generatedTechnicalSkillsCount = generatedTests ?. profile . technicalSkillsCount ?? 0 ;
449449 const generatedTotalTests = generatedTests ?. totalTests ?? 0 ;
450+ const contextualProfessionalArea = testsContext ?. professionalArea ;
450451 const contextualTechnicalSkills = testsContext ?. technicalSkills ?? [ ] ;
451452
452453 if ( tests . length === 0 ) {
0 commit comments