Skip to content

Commit

Permalink
Add golden test: "renders filled create homework dialog as expected".
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas-Sander committed Oct 16, 2023
1 parent 6cbf3a2 commit 63b93ba
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/test/homework/homework_dialog_bloc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,17 @@ class FakeLocalFile extends LocalFile {
required this.mimeType,
});

factory FakeLocalFile.empty({String name = '', MimeType? mimeType}) {
return FakeLocalFile._(
file: null,
fileData: Uint8List(0),
sizeBytes: 0,
path: null,
mimeType: null,
fileName: name,
);
}

factory FakeLocalFile.fromData(
Uint8List data, String? path, String name, String? type) {
return FakeLocalFile._(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
// SPDX-License-Identifier: EUPL-1.2

import 'package:bloc_test/bloc_test.dart';
import 'package:common_domain_models/common_domain_models.dart';
import 'package:date/date.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:files_basics/files_models.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart' as bloc_lib;
import 'package:flutter_test/flutter_test.dart';
Expand All @@ -15,6 +20,8 @@ import 'package:sharezone/blocs/homework/homework_dialog_bloc.dart';
import 'package:sharezone/pages/homework/homework_dialog.dart';
import 'package:sharezone_widgets/sharezone_widgets.dart';

import '../../../test/homework/homework_dialog_bloc_test.dart';

// ignore_for_file: invalid_use_of_visible_for_testing_member

class MockHomeworkDialogBloc
Expand Down Expand Up @@ -77,6 +84,61 @@ void main() {
'homework_dialog_add_empty_dark',
);
});

testGoldens('renders filled create homework dialog as expected',
(tester) async {
final state = Ready(
title: 'S. 32 8a)',
course: CourseChosen(
courseId: CourseId('maths'),
courseName: 'Maths',
isChangeable: true,
),
dueDate: Date('2023-10-12'),
submissions: const SubmissionsDisabled(isChangeable: false),
description: 'Das ist eine Beschreibung',
attachments: IList([
FileView(
fileId: FileId('foo'),
fileName: 'foo.png',
format: FileFormat.image,
localFile: FakeLocalFile.empty(name: 'foo.png'),
),
FileView(
fileId: FileId('bar'),
fileName: 'bar.pdf',
format: FileFormat.pdf,
localFile: FakeLocalFile.empty(name: 'bar.pdf'),
),
]),
notifyCourseMembers: false,
isPrivate: (true, isChangeable: true),
hasModifiedData: true,
isEditing: false,
);

whenListen(
homeworkDialogBloc,
Stream.value(state),
initialState: state,
);

await pumpAndSettleHomeworkDialog(tester,
isEditing: false, theme: lightTheme);

await multiScreenGolden(
tester,
'homework_dialog_add_filled_1_light',
);

await pumpAndSettleHomeworkDialog(tester,
isEditing: false, theme: darkTheme);

await multiScreenGolden(
tester,
'homework_dialog_add_filled_1_dark',
);
});
});
}

Expand Down

0 comments on commit 63b93ba

Please sign in to comment.