Skip to content

fix(view, viewmodel, service): use full file name as file identifier#1590

Merged
Sembauke merged 3 commits into
freeCodeCamp:mainfrom
huyenltnguyen:fix/file-selection-dropdown
Jul 7, 2025
Merged

fix(view, viewmodel, service): use full file name as file identifier#1590
Sembauke merged 3 commits into
freeCodeCamp:mainfrom
huyenltnguyen:fix/file-selection-dropdown

Conversation

@huyenltnguyen
Copy link
Copy Markdown
Member

@huyenltnguyen huyenltnguyen commented Jul 3, 2025

Checklist:

This PR:

Testing

I've tested and verified the following cases:

  • React coding challenges are now accessible, file selection drowdown displays correctly

    Screenshot Screenshot 2025-07-03 at 17 38 34
  • Challenge reset is working as expected

  • The file content are saved and retrieved correctly as expected

  • Tests run on HTML, CSS, JS challenges correctly as expected

But...

The tests fail on React challenges. It seems the user's code isn't passed to the tests. The tests can't see the code change and just run against the seed code.

I'm not sure if this is related to the test runner integration or if I'm missing something obvious.

Feel free to push changes to the PR to speed things up.

@huyenltnguyen huyenltnguyen force-pushed the fix/file-selection-dropdown branch from 170abe1 to 7a37b52 Compare July 3, 2025 19:35
testing: testing,
);

if (!await cssFileIsLinked(content, '${file.name}.${file.ext.name}')) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file.ext is the Ext enum.

Changing this line to use getFullFileName would mean changing file.ext.name to file.ext.value. This isn't an issue as they return the same string.

enum Ext {
js('js'),
html('html'),
css('css'),
jsx('jsx'),
py('py');

Comment on lines +10 to +12
String getFullFileName(ChallengeFile file) {
return '${file.name}.${file.ext.value}';
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I defined this function 3 times, so I was tempted to make it a global util. But the function is too small that I don't know if it's really necessary, also I'm not sure where the util file should be if we were to create it.

@huyenltnguyen huyenltnguyen force-pushed the fix/file-selection-dropdown branch from 7a37b52 to fbcc8a0 Compare July 3, 2025 19:43
@huyenltnguyen huyenltnguyen marked this pull request as ready for review July 3, 2025 20:49
@huyenltnguyen huyenltnguyen requested a review from a team July 3, 2025 20:49
@huyenltnguyen huyenltnguyen added the status: waiting review Waiting for review label Jul 3, 2025
Comment on lines +574 to +575
await prefs.remove('${currChallenge.id}.${getFullFileName(file)}');
await prefs.remove('${currChallenge.id}${getFullFileName(file)}');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhhhh 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to ask about this.

I'm not sure if prefs.remove('${currChallenge.id}${file.name}'); is a mistake here or it's intended. I don't think I've seen prefs.set with this pattern.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that might be some kind of artifact. Not sure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check and remove it if there's no preference with that key

Comment thread mobile-app/lib/ui/views/learn/challenge/challenge_viewmodel.dart Outdated
@Sembauke Sembauke merged commit 35c171d into freeCodeCamp:main Jul 7, 2025
2 of 6 checks passed
@huyenltnguyen huyenltnguyen deleted the fix/file-selection-dropdown branch July 7, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting review Waiting for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error thrown when accessing React challenges

3 participants