Skip to content
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
29 changes: 12 additions & 17 deletions mobile-app/integration_test/learn/learn_landing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,27 @@ void main() {
await tester.pumpAndSettle();
await binding.takeScreenshot('learn/learn-landing');

String baseUrlV2 = LearnService.baseUrlV2;
final Response res = await dio.get('$baseUrlV2/available-superblocks.json');
Map<String, dynamic> superBlockStages = res.data['superblocks'];
String baseUrl = LearnService.baseUrl;
final Response res = await dio.get('$baseUrl/available-superblocks.json');
List superBlocks = res.data['superblocks'];
int publicSuperBlocks = 0;
int totalSuperBlocks = 0;

// Iterate through each stage and count the superblocks
superBlockStages.forEach((stage, superBlocksList) {
for (final superBlock in superBlocksList) {
totalSuperBlocks++;
if (superBlock['public']) {
publicSuperBlocks++;
}
}
});

print('Total SuperBlocks: $totalSuperBlocks');
print('Total Public SuperBlocks: $publicSuperBlocks');
for (int i = 0; i < superBlocks.length; i++) {
if (superBlocks[i]['public']) {
publicSuperBlocks++;
}
}
await tester.pumpAndSettle();

// Check if all superblocks are displayed
final superBlockButtons = find.byType(SuperBlockButton);
final publicSuperBlockButtons = find.byWidgetPredicate(
(widget) => widget is SuperBlockButton && widget.button.public == true,
);
expect(superBlockButtons, findsNWidgets(totalSuperBlocks));
expect(
superBlockButtons,
findsNWidgets(superBlocks.length - 1), // Exclude 'full-stack' superblock
);
expect(publicSuperBlockButtons, findsNWidgets(publicSuperBlocks));

// Check for login button
Expand Down
2 changes: 2 additions & 0 deletions mobile-app/lib/service/learn/learn_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class LearnService {

final Dio _dio = DioService.dio;

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

Expand Down
58 changes: 37 additions & 21 deletions mobile-app/lib/ui/views/learn/landing/landing_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class LearnLandingViewModel extends BaseViewModel {
lastVisitedChallenge[0],
);

String baseUrl = LearnService.baseUrlV2;
String baseUrl = LearnService.baseUrl;

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

Future<List<Widget>> requestSuperBlocks() async {
String baseUrl = LearnService.baseUrlV2;
String baseUrl = LearnService.baseUrl;

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

List<Widget> layout = [];
if (res.statusCode == 200) {
Map<String, dynamic> superBlockStages = res.data['superblocks'];

await dotenv.load(fileName: '.env');

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

for (var superBlockStage in superBlockStages.keys) {
layout.add(Padding(
padding: const EdgeInsets.all(8.0),
child: handleStageTitle(superBlockStage),
));

for (var superBlock in superBlockStages[superBlockStage]) {
layout.add(
SuperBlockButton(
button: SuperBlockButtonData(
path: superBlock['dashedName'],
name: superBlock['title'],
public: !showAllSB ? superBlock['public'] : true,
),
model: this,
),
);
// Map<String, dynamic> superBlockStages = res.data['superblocks'];
// for (var superBlockStage in superBlockStages.keys) {
// layout.add(Padding(
// padding: const EdgeInsets.all(8.0),
// child: handleStageTitle(superBlockStage),
// ));

// for (var superBlock in superBlockStages[superBlockStage]) {
// layout.add(
// SuperBlockButton(
// button: SuperBlockButtonData(
// path: superBlock['dashedName'],
// name: superBlock['title'],
// public: !showAllSB ? superBlock['public'] : true,
// ),
// model: this,
// ),
// );
// }
// }

List superBlocks = res.data['superblocks'];
for (int i = 0; i < superBlocks.length; i++) {
if (superBlocks[i]['dashedName'].toString().contains('full-stack')) {
continue;
}
layout.add(
SuperBlockButton(
button: SuperBlockButtonData(
path: superBlocks[i]['dashedName'],
name: superBlocks[i]['title'],
public: !showAllSB ? superBlocks[i]['public'] : true,
),
model: this,
),
);
}

return layout;
Expand Down
Loading