-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into new_docs_nextra
- Loading branch information
Showing
84 changed files
with
1,077 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+21.1 KB
...ges/subject_settings_page/goldens/subject_settings_page_error_dark.iphone11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20 KB
.../pages/subject_settings_page/goldens/subject_settings_page_error_dark.phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.8 KB
...ject_settings_page/goldens/subject_settings_page_error_dark.phone_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.5 KB
...ect_settings_page/goldens/subject_settings_page_error_dark.tablet_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27 KB
...ject_settings_page/goldens/subject_settings_page_error_dark.tablet_portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.9 KB
...es/subject_settings_page/goldens/subject_settings_page_error_light.iphone11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.6 KB
...pages/subject_settings_page/goldens/subject_settings_page_error_light.phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.3 KB
...ect_settings_page/goldens/subject_settings_page_error_light.phone_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.8 KB
...ct_settings_page/goldens/subject_settings_page_error_light.tablet_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.2 KB
...ect_settings_page/goldens/subject_settings_page_error_light.tablet_portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.1 KB
...s/subject_settings_page/goldens/subject_settings_page_loading_dark.iphone11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20 KB
...ages/subject_settings_page/goldens/subject_settings_page_loading_dark.phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.8 KB
...ct_settings_page/goldens/subject_settings_page_loading_dark.phone_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.5 KB
...t_settings_page/goldens/subject_settings_page_loading_dark.tablet_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27 KB
...ct_settings_page/goldens/subject_settings_page_loading_dark.tablet_portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.9 KB
.../subject_settings_page/goldens/subject_settings_page_loading_light.iphone11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.6 KB
...ges/subject_settings_page/goldens/subject_settings_page_loading_light.phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.3 KB
...t_settings_page/goldens/subject_settings_page_loading_light.phone_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.8 KB
..._settings_page/goldens/subject_settings_page_loading_light.tablet_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.2 KB
...t_settings_page/goldens/subject_settings_page_loading_light.tablet_portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.1 KB
...subject_settings_page/goldens/subject_settings_page_with_data_dark.iphone11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20 KB
...es/subject_settings_page/goldens/subject_settings_page_with_data_dark.phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.8 KB
..._settings_page/goldens/subject_settings_page_with_data_dark.phone_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.5 KB
...settings_page/goldens/subject_settings_page_with_data_dark.tablet_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27 KB
..._settings_page/goldens/subject_settings_page_with_data_dark.tablet_portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.9 KB
...ubject_settings_page/goldens/subject_settings_page_with_data_light.iphone11.png
Oops, something went wrong.
Binary file added
BIN
+18.6 KB
...s/subject_settings_page/goldens/subject_settings_page_with_data_light.phone.png
Oops, something went wrong.
Binary file added
BIN
+18.3 KB
...settings_page/goldens/subject_settings_page_with_data_light.phone_landscape.png
Oops, something went wrong.
Binary file added
BIN
+24.8 KB
...ettings_page/goldens/subject_settings_page_with_data_light.tablet_landscape.png
Oops, something went wrong.
Binary file added
BIN
+25.2 KB
...settings_page/goldens/subject_settings_page_with_data_light.tablet_portrait.png
Oops, something went wrong.
137 changes: 137 additions & 0 deletions
137
app/test_goldens/grades/pages/subject_settings_page/subject_settings_page_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// Copyright (c) 2024 Sharezone UG (haftungsbeschränkt) | ||
// Licensed under the EUPL-1.2-or-later. | ||
// | ||
// You may obtain a copy of the Licence at: | ||
// https://joinup.ec.europa.eu/software/page/eupl | ||
// | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
|
||
import 'package:fast_immutable_collections/fast_immutable_collections.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:golden_toolkit/golden_toolkit.dart'; | ||
import 'package:mockito/annotations.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:sharezone/grades/grades_service/grades_service.dart'; | ||
import 'package:sharezone/grades/pages/subject_settings_page/subject_settings_page.dart'; | ||
import 'package:sharezone/grades/pages/subject_settings_page/subject_settings_page_controller.dart'; | ||
import 'package:sharezone/grades/pages/subject_settings_page/subject_settings_page_view.dart'; | ||
import 'package:sharezone_widgets/sharezone_widgets.dart'; | ||
|
||
import 'subject_settings_page_test.mocks.dart'; | ||
|
||
@GenerateNiceMocks([ | ||
MockSpec<SubjectSettingsPageController>(), | ||
]) | ||
void main() { | ||
group(SubjectSettingsPage, () { | ||
const termId = TermId('term-1'); | ||
const subjectId = SubjectId('subject-1'); | ||
late MockSubjectSettingsPageController controller; | ||
|
||
setUp(() { | ||
controller = MockSubjectSettingsPageController(); | ||
}); | ||
|
||
void setState(SubjectSettingsState state) { | ||
// Mockito does not support mocking sealed classes yet, so we have to | ||
// provide a dummy implementation of the state. | ||
// | ||
// Ticket: https://github.com/dart-lang/mockito/issues/675 | ||
provideDummy<SubjectSettingsState>(state); | ||
when(controller.state).thenReturn(state); | ||
} | ||
|
||
void setLoaded() { | ||
setState(SubjectSettingsLoaded( | ||
SubjectSettingsPageView( | ||
subjectName: 'Mathe', | ||
finalGradeTypeDisplayName: 'Zeugnisnote', | ||
finalGradeTypeIcon: const Icon(Icons.edit_document), | ||
selectableGradingTypes: const IListConst([]), | ||
weights: IMapConst({ | ||
GradeType.oralParticipation.id: const Weight.factor(0.5), | ||
GradeType.writtenExam.id: const Weight.factor(1), | ||
}), | ||
), | ||
)); | ||
} | ||
|
||
void setError() { | ||
setState(const SubjectSettingsError('An error occurred.')); | ||
} | ||
|
||
void setLoading() { | ||
setState(const SubjectSettingsLoading()); | ||
} | ||
|
||
Future<void> pushSubjectSettingsPage( | ||
WidgetTester tester, ThemeData theme) async { | ||
await tester.pumpWidgetBuilder( | ||
MultiProvider( | ||
providers: [ | ||
Provider<GradesService>( | ||
create: (_) => GradesService(), | ||
), | ||
ChangeNotifierProvider<SubjectSettingsPageController>.value( | ||
value: controller, | ||
), | ||
], | ||
child: const SubjectSettingsPage( | ||
termId: termId, | ||
subjectId: subjectId, | ||
), | ||
), | ||
wrapper: materialAppWrapper(theme: theme), | ||
); | ||
} | ||
|
||
group('with data', () { | ||
testGoldens('renders as expected (light mode)', (tester) async { | ||
setLoaded(); | ||
await pushSubjectSettingsPage(tester, getLightTheme()); | ||
await multiScreenGolden( | ||
tester, 'subject_settings_page_with_data_light'); | ||
}); | ||
|
||
testGoldens('renders as expected (dark mode)', (tester) async { | ||
setLoaded(); | ||
await pushSubjectSettingsPage(tester, getDarkTheme()); | ||
await multiScreenGolden(tester, 'subject_settings_page_with_data_dark'); | ||
}); | ||
}); | ||
|
||
group('error', () { | ||
testGoldens('renders as expected (light mode)', (tester) async { | ||
setError(); | ||
await pushSubjectSettingsPage(tester, getLightTheme()); | ||
await multiScreenGolden(tester, 'subject_settings_page_error_light'); | ||
}); | ||
|
||
testGoldens('renders as expected (dark mode)', (tester) async { | ||
setError(); | ||
await pushSubjectSettingsPage(tester, getDarkTheme()); | ||
await multiScreenGolden(tester, 'subject_settings_page_error_dark'); | ||
}); | ||
}); | ||
|
||
group('loading', () { | ||
testGoldens('renders as expected (light mode)', (tester) async { | ||
setLoading(); | ||
await pushSubjectSettingsPage(tester, getLightTheme()); | ||
await multiScreenGolden(tester, 'subject_settings_page_loading_light', | ||
customPump: (tester) => | ||
tester.pump(const Duration(milliseconds: 100))); | ||
}); | ||
|
||
testGoldens('renders as expected (dark mode)', (tester) async { | ||
setLoading(); | ||
await pushSubjectSettingsPage(tester, getDarkTheme()); | ||
await multiScreenGolden(tester, 'subject_settings_page_loading_dark', | ||
customPump: (tester) => | ||
tester.pump(const Duration(milliseconds: 100))); | ||
}); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.