Skip to content

Commit bcb3fc8

Browse files
authored
chore: use old landing SB order (#1633)
* Revert "chore: update learn_landing.dart to use v2 data (#1542)" This reverts commit 2f273ce. * chore: use old landing SB order * fix: learn landing integration test
1 parent 1b63968 commit bcb3fc8

3 files changed

Lines changed: 51 additions & 38 deletions

File tree

mobile-app/integration_test/learn/learn_landing.dart

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,27 @@ void main() {
2020
await tester.pumpAndSettle();
2121
await binding.takeScreenshot('learn/learn-landing');
2222

23-
String baseUrlV2 = LearnService.baseUrlV2;
24-
final Response res = await dio.get('$baseUrlV2/available-superblocks.json');
25-
Map<String, dynamic> superBlockStages = res.data['superblocks'];
23+
String baseUrl = LearnService.baseUrl;
24+
final Response res = await dio.get('$baseUrl/available-superblocks.json');
25+
List superBlocks = res.data['superblocks'];
2626
int publicSuperBlocks = 0;
27-
int totalSuperBlocks = 0;
28-
29-
// Iterate through each stage and count the superblocks
30-
superBlockStages.forEach((stage, superBlocksList) {
31-
for (final superBlock in superBlocksList) {
32-
totalSuperBlocks++;
33-
if (superBlock['public']) {
34-
publicSuperBlocks++;
35-
}
36-
}
37-
});
3827

39-
print('Total SuperBlocks: $totalSuperBlocks');
40-
print('Total Public SuperBlocks: $publicSuperBlocks');
28+
for (int i = 0; i < superBlocks.length; i++) {
29+
if (superBlocks[i]['public']) {
30+
publicSuperBlocks++;
31+
}
32+
}
4133
await tester.pumpAndSettle();
4234

4335
// Check if all superblocks are displayed
4436
final superBlockButtons = find.byType(SuperBlockButton);
4537
final publicSuperBlockButtons = find.byWidgetPredicate(
4638
(widget) => widget is SuperBlockButton && widget.button.public == true,
4739
);
48-
expect(superBlockButtons, findsNWidgets(totalSuperBlocks));
40+
expect(
41+
superBlockButtons,
42+
findsNWidgets(superBlocks.length - 1), // Exclude 'full-stack' superblock
43+
);
4944
expect(publicSuperBlockButtons, findsNWidgets(publicSuperBlocks));
5045

5146
// Check for login button

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class LearnService {
2323

2424
final Dio _dio = DioService.dio;
2525

26+
// TODO: change this to v2 and remove baseUrlV2 once the migration is complete
27+
static final baseUrl = '${AuthenticationService.baseURL}/curriculum-data/v1';
2628
static final baseUrlV2 =
2729
'${AuthenticationService.baseURL}/curriculum-data/v2';
2830

mobile-app/lib/ui/views/learn/landing/landing_viewmodel.dart

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class LearnLandingViewModel extends BaseViewModel {
7474
lastVisitedChallenge[0],
7575
);
7676

77-
String baseUrl = LearnService.baseUrlV2;
77+
String baseUrl = LearnService.baseUrl;
7878

7979
final Response res =
8080
await _dio.get('$baseUrl/${lastVisitedChallenge[1]}.json');
@@ -158,37 +158,53 @@ class LearnLandingViewModel extends BaseViewModel {
158158
}
159159

160160
Future<List<Widget>> requestSuperBlocks() async {
161-
String baseUrl = LearnService.baseUrlV2;
161+
String baseUrl = LearnService.baseUrl;
162162

163163
final Response res = await _dio.get('$baseUrl/available-superblocks.json');
164164

165165
List<Widget> layout = [];
166166
if (res.statusCode == 200) {
167-
Map<String, dynamic> superBlockStages = res.data['superblocks'];
168-
169167
await dotenv.load(fileName: '.env');
170168

171169
bool showAllSB =
172170
dotenv.get('SHOWALLSB', fallback: 'false').toLowerCase() == 'true';
173171

174-
for (var superBlockStage in superBlockStages.keys) {
175-
layout.add(Padding(
176-
padding: const EdgeInsets.all(8.0),
177-
child: handleStageTitle(superBlockStage),
178-
));
179-
180-
for (var superBlock in superBlockStages[superBlockStage]) {
181-
layout.add(
182-
SuperBlockButton(
183-
button: SuperBlockButtonData(
184-
path: superBlock['dashedName'],
185-
name: superBlock['title'],
186-
public: !showAllSB ? superBlock['public'] : true,
187-
),
188-
model: this,
189-
),
190-
);
172+
// Map<String, dynamic> superBlockStages = res.data['superblocks'];
173+
// for (var superBlockStage in superBlockStages.keys) {
174+
// layout.add(Padding(
175+
// padding: const EdgeInsets.all(8.0),
176+
// child: handleStageTitle(superBlockStage),
177+
// ));
178+
179+
// for (var superBlock in superBlockStages[superBlockStage]) {
180+
// layout.add(
181+
// SuperBlockButton(
182+
// button: SuperBlockButtonData(
183+
// path: superBlock['dashedName'],
184+
// name: superBlock['title'],
185+
// public: !showAllSB ? superBlock['public'] : true,
186+
// ),
187+
// model: this,
188+
// ),
189+
// );
190+
// }
191+
// }
192+
193+
List superBlocks = res.data['superblocks'];
194+
for (int i = 0; i < superBlocks.length; i++) {
195+
if (superBlocks[i]['dashedName'].toString().contains('full-stack')) {
196+
continue;
191197
}
198+
layout.add(
199+
SuperBlockButton(
200+
button: SuperBlockButtonData(
201+
path: superBlocks[i]['dashedName'],
202+
name: superBlocks[i]['title'],
203+
public: !showAllSB ? superBlocks[i]['public'] : true,
204+
),
205+
model: this,
206+
),
207+
);
192208
}
193209

194210
return layout;

0 commit comments

Comments
 (0)