Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: odin project tests #1287

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mobile-curriculum-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/lib/service/learn/learn_file_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class LearnFileService {
}

for (String contents in cssFilesWithCache) {
String tag = '<style> $contents </style>';
String tag = '<style class="fcc-injected-styles"> $contents </style>';
tags.add(tag);
}

Expand Down
36 changes: 17 additions & 19 deletions mobile-app/lib/service/learn/learn_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,27 @@ class LearnService {
}

void passChallenge(
Challenge? challenge,
Challenge challenge,
String? solutionLink,
) async {
SharedPreferences prefs = await SharedPreferences.getInstance();

if (challenge != null) {
List challengeFiles = challenge.files.map((file) {
return {
'contents':
prefs.getString('${challenge.id}.${file.name}') ?? file.contents,
'ext': file.ext.name,
'history': file.history,
'key': file.fileKey,
'name': file.name,
};
}).toList();

await postChallengeCompleted(
challenge,
challengeFiles: challengeFiles,
solutionLink: solutionLink,
);
}
List challengeFiles = challenge.files.map((file) {
return {
'contents':
prefs.getString('${challenge.id}.${file.name}') ?? file.contents,
'ext': file.ext.name,
'history': file.history,
'key': file.fileKey,
'name': file.name,
};
}).toList();

await postChallengeCompleted(
challenge,
challengeFiles: challengeFiles,
solutionLink: solutionLink,
);
}

void goToNextChallenge(
Expand Down
11 changes: 7 additions & 4 deletions mobile-app/lib/ui/views/learn/test_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ class TestRunner extends BaseViewModel {
testing: testing,
);

firstHTMlfile = fileService.changeActiveFileLinks(
parsedWithStyleTags,
);
if (challenge.id != '646c48df8674cf2b91020ecc') {
firstHTMlfile = fileService.changeActiveFileLinks(
parsedWithStyleTags,
);
}

return firstHTMlfile;
}

Expand Down Expand Up @@ -210,7 +213,7 @@ class TestRunner extends BaseViewModel {
case 'index':
return `${(await fileService.getCurrentEditedFileFromCache(challenge, testing: testing)).replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('\$', r'\$')}`;
case 'editableContents':
return `${(await fileService.getCurrentEditedFileFromCache(challenge, testing: testing)).replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('\$', r'\$')}`;
return `${(await fileService.getCurrentEditedFileFromCache(challenge, testing: testing)).replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('\$', r'\$')}`;
default:
return code;
}
Expand Down
9 changes: 9 additions & 0 deletions mobile-app/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ void main() {
'2022/responsive-web-design',
'responsive-web-design',
'javascript-algorithms-and-data-structures',
'the-odin-project',
];

var curriculumFile = File('../../shared/config/curriculum.json');
Map curriculumData = jsonDecode(curriculumFile.readAsStringSync());

var editorChallengeTypes = <int>{};
for (var currSuperBlock in publicSBs) {
print('\nSUPERBLOCK: $currSuperBlock');
for (var currBlock in curriculumData[currSuperBlock]['blocks'].values) {
Expand All @@ -36,6 +38,12 @@ void main() {
a['challengeOrder'].compareTo(b['challengeOrder']) as int);
for (var i = 0; i < challenges.length; i++) {
var currChallenge = challenges[i];
editorChallengeTypes.add(currChallenge['challengeType']);

// Skip non-editor challenges
if (![0, 1, 5, 6, 14].contains(currChallenge['challengeType'])) {
continue;
}

// "solutions" is present only for legacy certificates and last step for new cert challenges
// New certificates checks against next challenge
Expand Down Expand Up @@ -76,6 +84,7 @@ void main() {
}
}
}
print('\nEditor challenge types: $editorChallengeTypes');
print('Done');
});
}
Loading