Repository: freeCodeCamp/freeCodeCamp
File: e2e/settings.spec.ts (TypeScript)

Code before:
        name: 'Delete my account'
      })
    ).toBeVisible();
  });

  test('Should allow empty string in any field in about settings', async ({
    page
  }) => {
    const saveButton = page.getByRole('button', {
      name: translations.settings.headings['personal-info']
    });

    const nameInput = page.getByLabel(translations.settings.labels.name, {
      exact: true
    });
    const locationInput = page.getByLabel(
      translations.settings.labels.location
    );
    const pictureInput = page.getByLabel(translations.settings.labels.picture);
    const aboutInput = page.getByLabel(translations.settings.labels.about);
    const updatedAlert = page.getByText(translations.flash['updated-about-me']);

    await nameInput.fill('Quincy Larson');
    await locationInput.fill('USA');
    await pictureInput.fill(
      'https://cdn.freecodecamp.org/platform/english/images/quincy-larson-signature.svg'
    );
    await aboutInput.fill('Teacher at freeCodeCamp');

    await expect(saveButton).not.toBeDisabled();
    await saveButton.click();
    await expect(updatedAlert).toBeVisible();
    // clear the alert to make sure it's gone before we save again.
    await updatedAlert.getByRole('button').click();

    await nameInput.fill('');
    await locationInput.fill('');
    await pictureInput.fill('');
    await aboutInput.fill('');

    await expect(saveButton).not.toBeDisabled();
    await saveButton.click();
    await expect(updatedAlert).toBeVisible();

    await page.reload();

    await expect(nameInput).toHaveValue('');
    await expect(locationInput).toHaveValue('');
    await expect(pictureInput).toHaveValue('');
    await expect(aboutInput).toHaveValue('');
  });

Review comment (bug):
Looking at the linked run, I'm now also a bit worried that about following situation:
- Test fails after saving the initially changed values.
- All retries will fail, because entering the same _initial_ values will not enable save button.

What do you think about dropping this line? Would it be very weird, to just click the save button at this point, without caring if it's enabled?

Edit: Well, of course I now realized that's not going to work with the further part of the test:
```js
    await expect(updatedAlert).toBeVisible();
    // clear the alert to make sure it's gone before we save again.
    await updatedAlert.getByRole('button').click();
```

Any other ideas?

Code after:

  test('Should allow empty string in any field in about settings', async ({
    page
  }) => {
    const saveButton = page.getByRole('button', {
      name: translations.settings.headings['personal-info']
    });

    const nameInput = page.getByLabel(translations.settings.labels.name, {
      exact: true
    });
    const locationInput = page.getByLabel(
      translations.settings.labels.location
    );
    const pictureInput = page.getByLabel(translations.settings.labels.picture);
    const aboutInput = page.getByLabel(translations.settings.labels.about);
    const updatedAlert = page.getByText(translations.flash['updated-about-me']);

    await nameInput.fill('Quincy Larson');
    await locationInput.fill('USA');
    await pictureInput.fill(
      'https://cdn.freecodecamp.org/platform/english/images/quincy-larson-signature.svg'
    );
    await aboutInput.fill('Teacher at freeCodeCamp');

    await expect(saveButton).not.toBeDisabled();
    await saveButton.click();
    await expect(updatedAlert).toBeVisible();
    // clear the alert to make sure it's gone before we save again.
    await updatedAlert.getByRole('button').click();

    await nameInput.fill('');
    await locationInput.fill('');
    await pictureInput.fill('');
    await aboutInput.fill('');

    await expect(saveButton).not.toBeDisabled();
    await saveButton.click();
    await expect(updatedAlert).toBeVisible();

    await page.reload();

    await expect(nameInput).toHaveValue('');
    await expect(locationInput).toHaveValue('');
    await expect(pictureInput).toHaveValue('');
    await expect(aboutInput).toHaveValue('');
  });
});