Skip to content

Commit d41ee81

Browse files
authored
fix: odin project tests (#1287)
* 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
1 parent 219885a commit d41ee81

File tree

5 files changed

+35
-25
lines changed

5 files changed

+35
-25
lines changed

.github/workflows/mobile-curriculum-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Setup pnpm
3636
uses: pnpm/action-setup@v2
3737
with:
38-
version: 8
38+
version: 9
3939

4040
- name: Use Node.js ${{ matrix.node-version }}
4141
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4

mobile-app/lib/service/learn/learn_file_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class LearnFileService {
174174
}
175175

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

mobile-app/lib/service/learn/learn_service.dart

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,29 +133,27 @@ class LearnService {
133133
}
134134

135135
void passChallenge(
136-
Challenge? challenge,
136+
Challenge challenge,
137137
String? solutionLink,
138138
) async {
139139
SharedPreferences prefs = await SharedPreferences.getInstance();
140140

141-
if (challenge != null) {
142-
List challengeFiles = challenge.files.map((file) {
143-
return {
144-
'contents':
145-
prefs.getString('${challenge.id}.${file.name}') ?? file.contents,
146-
'ext': file.ext.name,
147-
'history': file.history,
148-
'key': file.fileKey,
149-
'name': file.name,
150-
};
151-
}).toList();
152-
153-
await postChallengeCompleted(
154-
challenge,
155-
challengeFiles: challengeFiles,
156-
solutionLink: solutionLink,
157-
);
158-
}
141+
List challengeFiles = challenge.files.map((file) {
142+
return {
143+
'contents':
144+
prefs.getString('${challenge.id}.${file.name}') ?? file.contents,
145+
'ext': file.ext.name,
146+
'history': file.history,
147+
'key': file.fileKey,
148+
'name': file.name,
149+
};
150+
}).toList();
151+
152+
await postChallengeCompleted(
153+
challenge,
154+
challengeFiles: challengeFiles,
155+
solutionLink: solutionLink,
156+
);
159157
}
160158

161159
void goToNextChallenge(

mobile-app/lib/ui/views/learn/test_runner.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ class TestRunner extends BaseViewModel {
131131
testing: testing,
132132
);
133133

134-
firstHTMlfile = fileService.changeActiveFileLinks(
135-
parsedWithStyleTags,
136-
);
134+
if (challenge.id != '646c48df8674cf2b91020ecc') {
135+
firstHTMlfile = fileService.changeActiveFileLinks(
136+
parsedWithStyleTags,
137+
);
138+
}
139+
137140
return firstHTMlfile;
138141
}
139142

@@ -210,7 +213,7 @@ class TestRunner extends BaseViewModel {
210213
case 'index':
211214
return `${(await fileService.getCurrentEditedFileFromCache(challenge, testing: testing)).replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('\$', r'\$')}`;
212215
case 'editableContents':
213-
return `${(await fileService.getCurrentEditedFileFromCache(challenge, testing: testing)).replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('\$', r'\$')}`;
216+
return `${(await fileService.getCurrentEditedFileFromCache(challenge, testing: testing)).replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('\$', r'\$')}`;
214217
default:
215218
return code;
216219
}

mobile-app/test/widget_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ void main() {
2222
'2022/responsive-web-design',
2323
'responsive-web-design',
2424
'javascript-algorithms-and-data-structures',
25+
'the-odin-project',
2526
];
2627

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

31+
var editorChallengeTypes = <int>{};
3032
for (var currSuperBlock in publicSBs) {
3133
print('\nSUPERBLOCK: $currSuperBlock');
3234
for (var currBlock in curriculumData[currSuperBlock]['blocks'].values) {
@@ -36,6 +38,12 @@ void main() {
3638
a['challengeOrder'].compareTo(b['challengeOrder']) as int);
3739
for (var i = 0; i < challenges.length; i++) {
3840
var currChallenge = challenges[i];
41+
editorChallengeTypes.add(currChallenge['challengeType']);
42+
43+
// Skip non-editor challenges
44+
if (![0, 1, 5, 6, 14].contains(currChallenge['challengeType'])) {
45+
continue;
46+
}
3947

4048
// "solutions" is present only for legacy certificates and last step for new cert challenges
4149
// New certificates checks against next challenge
@@ -76,6 +84,7 @@ void main() {
7684
}
7785
}
7886
}
87+
print('\nEditor challenge types: $editorChallengeTypes');
7988
print('Done');
8089
});
8190
}

0 commit comments

Comments
 (0)