Skip to content

Commit

Permalink
fix: odin project tests (#1287)
Browse files Browse the repository at this point in the history
* feat: add class to external file css

* fix: temp workaround for challenge 3 of intermediate css in new RWD

* chore: update mobile curriculum e2e tests to check TOP SB

* chore: remove unnecessary null check

* chore: update pnpm to v9 in actions
  • Loading branch information
Nirajn2311 authored Jun 17, 2024
1 parent 219885a commit d41ee81
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
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');
});
}

0 comments on commit d41ee81

Please sign in to comment.