Skip to content

Commit

Permalink
tests: organised chat item, checkbox, chip, dialpad, fab, icon, in pa…
Browse files Browse the repository at this point in the history
…ge banner, password, search bar, slider, stepper input, and, tooltip
  • Loading branch information
DE7924 committed Oct 15, 2024
1 parent a575ada commit 889164b
Show file tree
Hide file tree
Showing 27 changed files with 1,143 additions and 919 deletions.
30 changes: 20 additions & 10 deletions test/TESTING_README.mdx → test/TESTING_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,34 @@ As you are writing tests think about helper function you could write and add the

### Groups

- Accessibility Tests
- **Accessibility Tests**
Semantic labels, touch areas, contrast ratios, etc.
- Content Tests
Finds the widget, parameter statuses, etc.
- Dimensions Tests
Size, padding, margin, alignment, etc.
- Styling Tests

- **Content Tests**
Finds the widget, parameter statuses, etc.
Checking for the value of props and attributes of the widget. Checking for the presence of widgets.

- **Dimensions Tests**
Size, padding, margin, alignment, etc.
getSize().

- **Styling Tests**
Rendered colors, fonts, borders, radii etc.
- Interaction Tests
Checking the style of widgets and child widgets.

- **Interaction Tests**
Gesture recognizers, taps, drags, etc.
- Golden Tests
For example, using a boolean to check if the widgets interaction function runs.

- **Golden Tests**
Compares the rendered widget with the golden file. Use the `goldenTest()` function from test_utils/utils.dart.
- Performance Tests

- **Performance Tests**
Animation performance, rendering performance, data manupulation performance, etc.

### Testing File Template

```
```dart
import 'dart:ui';
import 'package:flutter/foundation.dart';
Expand Down
2 changes: 1 addition & 1 deletion test/src/components/badge/label_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
ZetaLabel,
'label_neutral',
);
goldenTest(goldenFile, const ZetaLabel(label: 'Test Label'), ZetaLabel, 'label_dark', darkMode: true);
goldenTest(goldenFile, const ZetaLabel(label: 'Test Label'), ZetaLabel, 'label_dark', themeMode: ThemeMode.dark);
goldenTest(goldenFile, const ZetaLabel(label: 'Test Label', rounded: false), ZetaLabel, 'label_sharp');
});
group('$componentName Performance Tests', () {});
Expand Down
15 changes: 0 additions & 15 deletions test/src/components/badge/priority_pill_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ void main() {
expect(zetaPriorityPill.size, ZetaPriorityPillSize.small);

expect(find.text('test label'), findsOneWidget);

await expectLater(
find.byType(ZetaPriorityPill),
matchesGoldenFile(goldenFile.getFileUri('priority_pill_high')),
);
});
testWidgets('Medium priority pill', (WidgetTester tester) async {
await tester.pumpWidget(
Expand All @@ -104,11 +99,6 @@ void main() {
final ZetaPriorityPill zetaPriorityPill = tester.firstWidget(zetaPriorityPillFinder);
expect(zetaPriorityPill.type, ZetaPriorityPillType.medium);
expect(zetaPriorityPill.isBadge, true);

await expectLater(
find.byType(ZetaPriorityPill),
matchesGoldenFile(goldenFile.getFileUri('priority_pill_medium')),
);
});
testWidgets('Low priority pill', (WidgetTester tester) async {
await tester.pumpWidget(
Expand All @@ -126,11 +116,6 @@ void main() {
expect(zetaPriorityPill.type, ZetaPriorityPillType.low);
expect(zetaPriorityPill.isBadge, true);
expect(zetaPriorityPill.size, ZetaPriorityPillSize.small);

await expectLater(
find.byType(ZetaPriorityPill),
matchesGoldenFile(goldenFile.getFileUri('priority_pill_low')),
);
});
});
group('$componentName Dimensions Tests', () {});
Expand Down
8 changes: 6 additions & 2 deletions test/src/components/button/button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,12 @@ void main() {
ZetaButton,
'button_outline',
);
goldenTest(goldenFile, const ZetaButton.outlineSubtle(label: 'Test Button', borderType: ZetaWidgetBorder.sharp),
ZetaButton, 'button_outline_subtle');
goldenTest(
goldenFile,
const ZetaButton.outlineSubtle(label: 'Test Button', borderType: ZetaWidgetBorder.sharp),
ZetaButton,
'button_outline_subtle',
);
goldenTest(
goldenFile,
ZetaButton.text(onPressed: () {}, label: 'Test Button', borderType: ZetaWidgetBorder.full),
Expand Down
17 changes: 8 additions & 9 deletions test/src/components/chat_item/chat_item_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:intl/intl.dart';
Expand Down Expand Up @@ -520,7 +519,7 @@ void main() {
const subtitle = Text('Hello, how are you?');
final time = DateTime.now();

goldenTest(
goldenTestWithCallbacks(
goldenFile,
Scaffold(
body: Column(
Expand Down Expand Up @@ -554,7 +553,7 @@ void main() {
},
);

goldenTest(
goldenTestWithCallbacks(
goldenFile,
Column(
children: [
Expand Down Expand Up @@ -588,7 +587,7 @@ void main() {
},
);

goldenTest(
goldenTestWithCallbacks(
goldenFile,
Column(
children: [
Expand Down Expand Up @@ -619,7 +618,7 @@ void main() {
},
);

goldenTest(
goldenTestWithCallbacks(
goldenFile,
Column(
children: [
Expand Down Expand Up @@ -659,7 +658,7 @@ void main() {
},
);

goldenTest(
goldenTestWithCallbacks(
goldenFile,
Column(
children: [
Expand Down Expand Up @@ -704,7 +703,7 @@ void main() {
},
);

goldenTest(
goldenTestWithCallbacks(
goldenFile,
Column(
children: [
Expand Down Expand Up @@ -734,7 +733,7 @@ void main() {
},
);

goldenTest(
goldenTestWithCallbacks(
goldenFile,
Column(
children: [
Expand Down Expand Up @@ -771,7 +770,7 @@ void main() {
},
);

goldenTest(
goldenTestWithCallbacks(
goldenFile,
Column(
children: [
Expand Down
2 changes: 1 addition & 1 deletion test/src/components/checkbox/checkbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void main() {
});
});
group('$componentName Golden Tests', () {
goldenTest(
goldenTestWithCallbacks(
goldenFile,
ZetaCheckbox(
onChanged: (value) {},
Expand Down
3 changes: 0 additions & 3 deletions test/src/components/chips/chip_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:zeta_flutter/zeta_flutter.dart';
Expand Down
Loading

0 comments on commit 889164b

Please sign in to comment.