Skip to content

Commit 3d7ce8c

Browse files
author
github-actions
committed
test: Fix bug in golden tests that meant they failed on windows
test: Add new GlodenFinder class to simplify generating golden file Uris
1 parent 3ac64a7 commit 3d7ce8c

File tree

18 files changed

+136
-136
lines changed

18 files changed

+136
-136
lines changed

lib/src/components/list_item/notification_list_item.dart

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ZetaNotificationListItem extends ZetaStatelessWidget {
7777
final extend = actionWith / maxScreenWidth;
7878
if (extend.clamp(0, maxButtonWidth).toDouble() > 1) {
7979
return 1;
80-
}
80+
}
8181
return extend.clamp(0, maxButtonWidth).toDouble();
8282
}
8383

@@ -148,8 +148,7 @@ class ZetaNotificationListItem extends ZetaStatelessWidget {
148148
crossAxisAlignment: CrossAxisAlignment.start,
149149
children: [
150150
Row(
151-
mainAxisAlignment:
152-
MainAxisAlignment.spaceBetween,
151+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
153152
children: [
154153
MergeSemantics(
155154
child: Row(
@@ -160,9 +159,7 @@ class ZetaNotificationListItem extends ZetaStatelessWidget {
160159
size: ZetaWidgetSize.small,
161160
),
162161
SizedBox(
163-
width: Zeta.of(context)
164-
.spacing
165-
.minimum,
162+
width: Zeta.of(context).spacing.minimum,
166163
),
167164
Text(
168165
title,
@@ -176,8 +173,7 @@ class ZetaNotificationListItem extends ZetaStatelessWidget {
176173
if (notificationTime != null)
177174
Text(
178175
notificationTime!,
179-
style:
180-
ZetaTextStyles.bodySmall.apply(
176+
style: ZetaTextStyles.bodySmall.apply(
181177
color: colors.textDisabled,
182178
),
183179
),
@@ -186,15 +182,12 @@ class ZetaNotificationListItem extends ZetaStatelessWidget {
186182
padding: const EdgeInsets.all(2),
187183
decoration: BoxDecoration(
188184
color: colors.surfaceNegative,
189-
borderRadius:
190-
Zeta.of(context).radius.full,
185+
borderRadius: Zeta.of(context).radius.full,
191186
),
192187
child: ZetaIcon(
193188
ZetaIcons.important_notification,
194189
color: colors.white,
195-
size: Zeta.of(context)
196-
.spacing
197-
.large,
190+
size: Zeta.of(context).spacing.large,
198191
),
199192
),
200193
].gap(Zeta.of(context).spacing.minimum),
@@ -205,8 +198,7 @@ class ZetaNotificationListItem extends ZetaStatelessWidget {
205198
if (attachment != null)
206199
Container(
207200
padding: EdgeInsets.symmetric(
208-
vertical:
209-
Zeta.of(context).spacing.minimum,
201+
vertical: Zeta.of(context).spacing.minimum,
210202
),
211203
child: Row(
212204
children: [
@@ -216,8 +208,7 @@ class ZetaNotificationListItem extends ZetaStatelessWidget {
216208
color: colors.primary,
217209
),
218210
DefaultTextStyle(
219-
style: ZetaTextStyles.bodyXSmall
220-
.apply(color: colors.primary),
211+
style: ZetaTextStyles.bodyXSmall.apply(color: colors.primary),
221212
child: attachment!,
222213
),
223214
],
@@ -230,7 +221,9 @@ class ZetaNotificationListItem extends ZetaStatelessWidget {
230221
),
231222
if (action != null)
232223
Container(
233-
alignment: Alignment.bottomRight, child: action),
224+
alignment: Alignment.bottomRight,
225+
child: action,
226+
),
234227
],
235228
).paddingAll(Zeta.of(context).spacing.small),
236229
),

test/src/components/badge/indicator_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import 'package:flutter/foundation.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_test/flutter_test.dart';
4-
import 'package:path/path.dart';
54
import 'package:zeta_flutter/zeta_flutter.dart';
65
import '../../../test_utils/test_app.dart';
76
import '../../../test_utils/tolerant_comparator.dart';
87
import '../../../test_utils/utils.dart';
98

109
void main() {
10+
const goldenFile = GoldenFinder(component: 'badge');
11+
1112
setUpAll(() {
12-
final testUri = Uri.parse(getCurrentPath('badge'));
13-
goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01);
13+
goldenFileComparator = TolerantComparator(goldenFile.uri);
1414
});
1515
testWidgets('Default constructor initializes with correct parameters', (WidgetTester tester) async {
1616
await tester.pumpWidget(const TestApp(home: ZetaIndicator()));
@@ -28,7 +28,7 @@ void main() {
2828

2929
await expectLater(
3030
find.byType(ZetaIndicator),
31-
matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_default.png')),
31+
matchesGoldenFile(goldenFile.getFileUri('indicator_default.png')),
3232
);
3333
});
3434

@@ -73,7 +73,7 @@ void main() {
7373

7474
await expectLater(
7575
find.byType(ZetaIndicator),
76-
matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_icon_default.png')),
76+
matchesGoldenFile(goldenFile.getFileUri('indicator_icon_default')),
7777
);
7878
});
7979
testWidgets('Icon constructor with values', (WidgetTester tester) async {
@@ -101,7 +101,7 @@ void main() {
101101

102102
await expectLater(
103103
find.byType(ZetaIndicator),
104-
matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_icon_values.png')),
104+
matchesGoldenFile(goldenFile.getFileUri('indicator_icon_values.png')),
105105
);
106106
});
107107
testWidgets('Notification constructor initializes with correct parameters', (WidgetTester tester) async {
@@ -120,7 +120,7 @@ void main() {
120120

121121
await expectLater(
122122
find.byType(ZetaIndicator),
123-
matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_notification_default.png')),
123+
matchesGoldenFile(goldenFile.getFileUri('indicator_notification_default.png')),
124124
);
125125
});
126126
testWidgets('Notification constructor with values', (WidgetTester tester) async {
@@ -149,7 +149,7 @@ void main() {
149149

150150
await expectLater(
151151
find.byType(ZetaIndicator),
152-
matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_notification_values.png')),
152+
matchesGoldenFile(goldenFile.getFileUri('indicator_notification_values.png')),
153153
);
154154
});
155155
testWidgets('debugFillProperties works correctly', (WidgetTester tester) async {

test/src/components/badge/label_test.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import 'package:flutter/foundation.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_test/flutter_test.dart';
4-
import 'package:path/path.dart';
54
import 'package:zeta_flutter/zeta_flutter.dart';
65
import '../../../test_utils/test_app.dart';
76
import '../../../test_utils/tolerant_comparator.dart';
87
import '../../../test_utils/utils.dart';
98

109
void main() {
10+
const goldenFile = GoldenFinder(component: 'badge');
11+
1112
setUpAll(() {
12-
final testUri = Uri.parse(getCurrentPath('badge'));
13-
goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01);
13+
goldenFileComparator = TolerantComparator(goldenFile.uri);
1414
});
1515
testWidgets('Initializes with correct parameters', (WidgetTester tester) async {
1616
await tester.pumpWidget(const TestApp(home: ZetaLabel(label: 'Test Label')));
@@ -22,7 +22,7 @@ void main() {
2222
expect(label.label, 'Test Label');
2323
expect(label.status, ZetaWidgetStatus.info);
2424

25-
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_default.png')));
25+
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_default.png')));
2626
});
2727

2828
testWidgets('Positive status', (WidgetTester tester) async {
@@ -33,7 +33,7 @@ void main() {
3333

3434
expect(label.status, ZetaWidgetStatus.positive);
3535

36-
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_positive.png')));
36+
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_positive.png')));
3737
});
3838

3939
testWidgets('Warning status', (WidgetTester tester) async {
@@ -44,7 +44,7 @@ void main() {
4444

4545
expect(label.status, ZetaWidgetStatus.warning);
4646

47-
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_warning.png')));
47+
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_warning.png')));
4848
});
4949
testWidgets('Negative status', (WidgetTester tester) async {
5050
await tester.pumpWidget(const TestApp(home: ZetaLabel(label: 'Test Label', status: ZetaWidgetStatus.negative)));
@@ -54,7 +54,7 @@ void main() {
5454

5555
expect(label.status, ZetaWidgetStatus.negative);
5656

57-
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_negative.png')));
57+
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_negative.png')));
5858
});
5959
testWidgets('Neutral status', (WidgetTester tester) async {
6060
await tester.pumpWidget(const TestApp(home: ZetaLabel(label: 'Test Label', status: ZetaWidgetStatus.neutral)));
@@ -64,7 +64,7 @@ void main() {
6464

6565
expect(label.status, ZetaWidgetStatus.neutral);
6666

67-
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_neutral.png')));
67+
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_neutral.png')));
6868
});
6969

7070
testWidgets('Dark mode', (WidgetTester tester) async {
@@ -80,7 +80,7 @@ void main() {
8080

8181
expect(label.status, ZetaWidgetStatus.info);
8282

83-
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_dark.png')));
83+
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_dark.png')));
8484
});
8585

8686
testWidgets('Sharp', (WidgetTester tester) async {
@@ -93,7 +93,7 @@ void main() {
9393

9494
expect(label.rounded, false);
9595

96-
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_sharp.png')));
96+
await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_sharp.png')));
9797
});
9898

9999
testWidgets('debugFillProperties works correctly', (WidgetTester tester) async {

test/src/components/badge/priority_pill_test.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
// ignore_for_file: avoid_dynamic_calls
2-
32
import 'package:flutter/foundation.dart';
43
import 'package:flutter_test/flutter_test.dart';
5-
import 'package:path/path.dart';
64
import 'package:zeta_flutter/zeta_flutter.dart';
75

86
import '../../../test_utils/test_app.dart';
97
import '../../../test_utils/tolerant_comparator.dart';
108
import '../../../test_utils/utils.dart';
119

1210
void main() {
11+
const goldenFile = GoldenFinder(component: 'badge');
12+
1313
setUpAll(() {
14-
final testUri = Uri.parse(getCurrentPath('badge'));
15-
goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01);
14+
goldenFileComparator = TolerantComparator(goldenFile.uri);
1615
});
1716
testWidgets('Initializes with correct label and index', (WidgetTester tester) async {
1817
await tester.pumpWidget(
@@ -36,7 +35,7 @@ void main() {
3635

3736
await expectLater(
3837
find.byType(ZetaPriorityPill),
39-
matchesGoldenFile(join(getCurrentPath('badge'), 'priority_pill_default.png')),
38+
matchesGoldenFile(goldenFile.getFileUri('priority_pill_default.png')),
4039
);
4140
});
4241
testWidgets('High priority pill', (WidgetTester tester) async {
@@ -64,7 +63,7 @@ void main() {
6463

6564
await expectLater(
6665
find.byType(ZetaPriorityPill),
67-
matchesGoldenFile(join(getCurrentPath('badge'), 'priority_pill_high.png')),
66+
matchesGoldenFile(goldenFile.getFileUri('priority_pill_high.png')),
6867
);
6968
});
7069
testWidgets('Medium priority pill', (WidgetTester tester) async {
@@ -84,7 +83,7 @@ void main() {
8483

8584
await expectLater(
8685
find.byType(ZetaPriorityPill),
87-
matchesGoldenFile(join(getCurrentPath('badge'), 'priority_pill_medium.png')),
86+
matchesGoldenFile(goldenFile.getFileUri('priority_pill_medium.png')),
8887
);
8988
});
9089
testWidgets('Low priority pill', (WidgetTester tester) async {
@@ -106,7 +105,7 @@ void main() {
106105

107106
await expectLater(
108107
find.byType(ZetaPriorityPill),
109-
matchesGoldenFile(join(getCurrentPath('badge'), 'priority_pill_low.png')),
108+
matchesGoldenFile(goldenFile.getFileUri('priority_pill_low.png')),
110109
);
111110
});
112111
testWidgets('debugFillProperties works correctly', (WidgetTester tester) async {

test/src/components/badge/status_label_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import 'package:flutter/foundation.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_test/flutter_test.dart';
4-
import 'package:path/path.dart';
54
import 'package:zeta_flutter/zeta_flutter.dart';
65

76
import '../../../test_utils/test_app.dart';
87
import '../../../test_utils/tolerant_comparator.dart';
98
import '../../../test_utils/utils.dart';
109

1110
void main() {
11+
const goldenFile = GoldenFinder(component: 'badge');
12+
1213
setUpAll(() {
13-
final testUri = Uri.parse(getCurrentPath('badge'));
14-
goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01);
14+
goldenFileComparator = TolerantComparator(goldenFile.uri);
1515
});
1616
group('ZetaStatusLabel Tests', () {
1717
testWidgets('Initializes with correct properties', (WidgetTester tester) async {
@@ -24,7 +24,7 @@ void main() {
2424

2525
await expectLater(
2626
find.byType(ZetaStatusLabel),
27-
matchesGoldenFile(join(getCurrentPath('badge'), 'status_label_default.png')),
27+
matchesGoldenFile(goldenFile.getFileUri('status_label_default.png')),
2828
);
2929
});
3030
});
@@ -43,7 +43,7 @@ void main() {
4343

4444
await expectLater(
4545
find.byType(ZetaStatusLabel),
46-
matchesGoldenFile(join(getCurrentPath('badge'), 'status_label_custom.png')),
46+
matchesGoldenFile(goldenFile.getFileUri('status_label_custom.png')),
4747
);
4848
});
4949
testWidgets('debugFillProperties works correctly', (WidgetTester tester) async {

test/src/components/badge/tag_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import 'package:flutter/foundation.dart';
22
import 'package:flutter_test/flutter_test.dart';
3-
import 'package:path/path.dart';
43
import 'package:zeta_flutter/zeta_flutter.dart';
54

65
import '../../../test_utils/test_app.dart';
76
import '../../../test_utils/tolerant_comparator.dart';
87
import '../../../test_utils/utils.dart';
98

109
void main() {
10+
const goldenFile = GoldenFinder(component: 'badge');
11+
1112
setUpAll(() {
12-
final testUri = Uri.parse(getCurrentPath('badge'));
13-
goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01);
13+
goldenFileComparator = TolerantComparator(goldenFile.uri);
1414
});
1515
group('ZetaTag', () {
1616
testWidgets('Initializes right with correct parameters', (WidgetTester tester) async {
@@ -24,7 +24,7 @@ void main() {
2424

2525
await expectLater(
2626
find.byType(ZetaTag),
27-
matchesGoldenFile(join(getCurrentPath('badge'), 'tag_right.png')),
27+
matchesGoldenFile(goldenFile.getFileUri('tag_right.png')),
2828
);
2929
});
3030

@@ -38,7 +38,7 @@ void main() {
3838

3939
await expectLater(
4040
find.byType(ZetaTag),
41-
matchesGoldenFile(join(getCurrentPath('badge'), 'tag_left.png')),
41+
matchesGoldenFile(goldenFile.getFileUri('tag_left.png')),
4242
);
4343
});
4444
});

0 commit comments

Comments
 (0)