Repository: freeCodeCamp/freeCodeCamp
File: api/src/routes/protected/settings.test.ts (TypeScript)

Code before:
          location: 'Some Location',
          picture: validPictureUrl
        });

        // Update only about, keeping same picture
        const updateResponse = await superPut('/update-my-about').send({
          about: 'New about text here',
          name: 'Test User',
          location: 'Some Location',
          picture: validPictureUrl
        });

        expect(updateResponse.statusCode).toEqual(200);
        expect(updateResponse.body).toEqual({
          message: 'flash.updated-about-me',
          type: 'success'
        });

        const user = await fastifyTestInstance?.prisma.user.findFirst({
          where: { email: 'foo@bar.com' }
        });

        expect(user?.about).toEqual('New about text here');
        expect(user?.picture).toEqual(validPictureUrl);
      });

      test('PUT still validates picture when it is actually changed', async () => {
        // Set initial valid picture
        const validPictureUrl = 'https://example.com/avatar.png';
        await superPut('/update-my-about').send({
          about: 'Initial',
          name: 'Test',
          location: 'Location',
          picture: validPictureUrl
        });

        // Try to change picture to invalid URL (no extension)
        const updateResponse = await superPut('/update-my-about').send({
          about: 'Initial',
          name: 'Test',
          location: 'Location',
          picture: 'https://example.com/new-avatar' // Changed but invalid
        });

        expect(updateResponse.statusCode).toEqual(400);
        expect(updateResponse.body).toEqual({
          message: 'flash.wrong-updating',
          type: 'danger'
        });

        // Verify picture wasn't updated

Review comment (suggestion):
```suggestion
```
These don't seem to cover anything that the first test doesn't.

Code after:

        expect(response.body).toEqual({
          message: 'buttons.accepted-honesty',
          type: 'success'
        });
        expect(response.statusCode).toEqual(200);
      });

      test('PUT returns 400 status code with invalid honesty', async () => {
        const response = await superPut('/update-my-honesty').send({
          isHonest: false
        });

        expect(response.body).toEqual(updateErrorResponse);
        expect(response.statusCode).toEqual(400);
      });
    });

    describe('/update-privacy-terms', () => {
      test('PUT returns 200 status code with "success" message', async () => {
        const response = await superPut('/update-privacy-terms').send({
          quincyEmails: true
        });

        expect(response.body).toEqual({
          message: 'flash.privacy-updated',
          type: 'success'
        });
        expect(response.statusCode).toEqual(200);
      });

      test('PUT returns 400 status code with non-boolean data', async () => {
        const response = await superPut('/update-privacy-terms').send({
          quincyEmails: '123'
        });

        expect(response.body).toEqual(updateErrorResponse);
        expect(response.statusCode).toEqual(400);
      });
    });

    describe('/update-my-portfolio', () => {
      test('PUT returns 200 status code with "success" message', async () => {
        const response = await superPut('/update-my-portfolio').send({
          portfolio: [{}]
        });

        expect(response.body).toEqual({
          message: 'flash.portfolio-item-updated',
          type: 'success'
        });