one moar time - we can do it?
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 35m48s

This commit is contained in:
2025-12-17 12:03:02 -08:00
parent ed2eb1743e
commit 13bdf1b76e
4 changed files with 16 additions and 13 deletions

View File

@@ -279,7 +279,7 @@ describe('useAiAnalysis Hook', () => {
});
describe('generateImage', () => {
it.only('should not run if there are no DEEP_DIVE results', async () => {
it('should not run if there are no DEEP_DIVE results', async () => {
console.log('TEST: should not run generateImage if DEEP_DIVE results are missing');
const { result } = renderHook(() => useAiAnalysis(defaultParams), { wrapper });

View File

@@ -173,28 +173,25 @@ describe('ProfileManager Authenticated User Features', () => {
vi.mocked(mockedApiClient.getUserAddress).mockResolvedValue(
new Response(JSON.stringify(mockAddress), { status: 200 })
);
// Ensure profile update succeeds so we isolate the address update failure
vi.mocked(mockedApiClient.updateUserProfile).mockResolvedValueOnce(
new Response(JSON.stringify(authenticatedProfile), { status: 200 })
);
// Mock the failing promise for the address update.
vi.mocked(mockedApiClient.updateUserAddress).mockRejectedValueOnce(new Error('Address update failed'));
render(<ProfileManager {...authenticatedProps} />);
// Wait for initial data fetch (getUserAddress) to complete
await waitFor(() => expect(screen.getByLabelText(/city/i)).toHaveValue(mockAddress.city));
fireEvent.change(screen.getByLabelText(/city/i), { target: { value: 'NewCity' } });
const saveButton = screen.getByRole('button', { name: /save profile/i });
// --- FINAL DIAGNOSTIC LOGGING ---
console.log(`[TEST LOG] FINAL CHECK: Is save button disabled? -> ${saveButton.hasAttribute('disabled')}`);
// ---
console.log(`[TEST LOG] FINAL CHECK: Is saveButton disabled? -> ${saveButton.hasAttribute('disabled')}`);
console.log('[TEST LOG] About to wrap fireEvent.click in act()...');
console.log('[TEST LOG] About to wrap fireEvent.submit in act()...');
await act(async () => {
console.log('[TEST LOG] INSIDE act(): Clicking "Save Profile" button.');
fireEvent.click(saveButton);
console.log('[TEST LOG] INSIDE act(): Firing submit event on the form.');
fireEvent.submit(screen.getByRole('form', { name: /profile form/i }));
});
console.log('[TEST LOG] Exited act() block.');

View File

@@ -192,6 +192,10 @@ export const ProfileManager: React.FC<ProfileManagerProps> = ({ isOpen, onClose,
logger.debug('[handleProfileSave] Save process finished.');
};
// --- DEBUG LOGGING ---
// Log the loading states on every render to debug the submit button's disabled state.
logger.debug('[ComponentRender] Loading states:', { profileLoading, addressLoading });
const handleAddressChange = (field: keyof Address, value: string) => {
setAddress(prev => ({ ...prev, [field]: value }));
};
@@ -379,7 +383,7 @@ export const ProfileManager: React.FC<ProfileManagerProps> = ({ isOpen, onClose,
</div>
{activeTab === 'profile' && (
<form onSubmit={handleProfileSave} className="space-y-4">
<form aria-label="Profile Form" onSubmit={handleProfileSave} className="space-y-4">
<div>
<label htmlFor="fullName" className="block text-sm font-medium text-gray-700 dark:text-gray-300">Full Name</label>
<input id="fullName" type="text" value={fullName} onChange={e => setFullName(e.target.value)} className="mt-1 block w-full px-3 py-2 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm" />

View File

@@ -229,9 +229,11 @@ export class AIService {
// Find the start of the JSON, which can be inside a markdown block
const markdownMatch = responseText.match(/```(json)?\s*([\s\S]*?)\s*```/);
let jsonString = responseText;
if (markdownMatch && markdownMatch[2]) {
logger.debug('[_parseJsonFromAiResponse] Found JSON within markdown code block.');
jsonString = markdownMatch[2];
if (markdownMatch && markdownMatch[2] !== undefined) {
logger.debug({ rawCapture: markdownMatch[2] },'[_parseJsonFromAiResponse] Found JSON content within markdown code block.');
// Architectural Fix: Trim whitespace from the extracted content to make parsing more robust.
jsonString = markdownMatch[2].trim();
logger.debug({ trimmedJsonString: jsonString }, '[_parseJsonFromAiResponse] Trimmed extracted JSON string.');
}
// Find the first '{' or '[' and the last '}' or ']' to isolate the JSON object.