Sboonny
February 21, 2023, 10:17am
1
in this PR feat(client): change setting alert messages to more descriptive messages by Sboonny · Pull Request #49396 · freeCodeCamp/freeCodeCamp (github.com) , I tried to change the alert message into something more descriptive.
The issue is that changing the alert message broke the save API for validation, as shown in the gif below.
the validation show that UserName
isn’t avaliable which isn’t true.
But my code hasn’t interacted with createUpdateMyUsername
. I have been looking at it for days, and I don’t know how I broke it.
The code that I changed, that can affect it, is this:
const createStandardHandler = (req, res, next, alertMessage) => err => {
if (err) {
res.status(500).json(standardErrorMessage);
return next(err);
}
return res.status(200).json({ type: 'success', message: alertMessage });
};
const createUpdateUserProperties = (buildUpdate, validate, successMessage) => {
return (req, res, next) => {
const { user, body } = req;
const update = buildUpdate(body);
if (validate(update)) {
user.updateAttributes(
update,
createStandardHandler(req, res, next, successMessage)
);
} else {
handleInvalidUpdate(res);
}
};
};
Here is the file for username, which has the validation in it.
freeCodeCamp/username.tsx at 168d403e417d05ec070c238c739ae63b5b824b0b · freeCodeCamp/freeCodeCamp (github.com)
How do I revert to the original behaviour, which displayed the alert correctly
Sky020
February 21, 2023, 11:33am
2
Hey @Sboonny ,
I am unable to reproduce what you show in the gif. Have you fixed this?
Also, certifieduser
is the username we use for the certified user:
const ObjectId = require('mongodb').ObjectID;
const defaultUserImage = require('../../../config/misc').defaultUserImage;
module.exports = {
_id: ObjectId('5fa2db00a25c1c1fa49ce067'),
email: 'foo@bar.com',
emailVerified: true,
progressTimestamps: [],
isBanned: false,
isCheater: false,
username: 'certifieduser',
about: '',
name: 'Full Stack User',
location: '',
picture: defaultUserImage,
acceptedPrivacyTerms: true,
sendQuincyEmail: false,
currentChallengeId: '',
isHonest: true,
isFrontEndCert: true,
isDataVisCert: true,
Are you sure you do not have that user in the database? If you do, then it would not be available.
P.S. Remember, usernames are case-insensitive
Sboonny
February 21, 2023, 11:49am
3
Unfortunately, it is affected the tests feat(client): change setting alert messages to more descriptive messages · freeCodeCamp/freeCodeCamp@168d403 (github.com)
I thought the same thing and the test is flaky, but I have run the test 3 times and with the same result.
Here are more info, I should have included.
I have used Chrome while testing.
Actually I don’t know how to reproduce it consistently, all I know that I need to run npm run seed:certified-user
, then copy and paste “CertifiedUser” (not type it).
running new Gitpod environment still create the same bug
Sky020
February 21, 2023, 3:45pm
4
I still cannot reproduce:
Sboonny
February 21, 2023, 4:49pm
5
I have open another gitpod environment with new database, and push a commit to the PR, hopefully the tests will be happy.
If the tests are happy, I will mess with the original environment seeing why this happened.
it was a typo in used string.