diff --git a/test/src/components/badge/indicator_test.dart b/test/src/components/badge/indicator_test.dart index a52a34d7..cf732149 100644 --- a/test/src/components/badge/indicator_test.dart +++ b/test/src/components/badge/indicator_test.dart @@ -1,16 +1,16 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'badge'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('badge')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); testWidgets('Default constructor initializes with correct parameters', (WidgetTester tester) async { await tester.pumpWidget(const TestApp(home: ZetaIndicator())); @@ -28,7 +28,7 @@ void main() { await expectLater( find.byType(ZetaIndicator), - matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_default.png')), + matchesGoldenFile(goldenFile.getFileUri('indicator_default')), ); }); @@ -73,7 +73,7 @@ void main() { await expectLater( find.byType(ZetaIndicator), - matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_icon_default.png')), + matchesGoldenFile(goldenFile.getFileUri('indicator_icon_default')), ); }); testWidgets('Icon constructor with values', (WidgetTester tester) async { @@ -101,7 +101,7 @@ void main() { await expectLater( find.byType(ZetaIndicator), - matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_icon_values.png')), + matchesGoldenFile(goldenFile.getFileUri('indicator_icon_values')), ); }); testWidgets('Notification constructor initializes with correct parameters', (WidgetTester tester) async { @@ -120,7 +120,7 @@ void main() { await expectLater( find.byType(ZetaIndicator), - matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_notification_default.png')), + matchesGoldenFile(goldenFile.getFileUri('indicator_notification_default')), ); }); testWidgets('Notification constructor with values', (WidgetTester tester) async { @@ -149,7 +149,7 @@ void main() { await expectLater( find.byType(ZetaIndicator), - matchesGoldenFile(join(getCurrentPath('badge'), 'indicator_notification_values.png')), + matchesGoldenFile(goldenFile.getFileUri('indicator_notification_values')), ); }); testWidgets('debugFillProperties works correctly', (WidgetTester tester) async { diff --git a/test/src/components/badge/label_test.dart b/test/src/components/badge/label_test.dart index f7f777fe..d5bfb5d2 100644 --- a/test/src/components/badge/label_test.dart +++ b/test/src/components/badge/label_test.dart @@ -1,16 +1,16 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'badge'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('badge')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); testWidgets('Initializes with correct parameters', (WidgetTester tester) async { await tester.pumpWidget(const TestApp(home: ZetaLabel(label: 'Test Label'))); @@ -22,7 +22,7 @@ void main() { expect(label.label, 'Test Label'); expect(label.status, ZetaWidgetStatus.info); - await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_default.png'))); + await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_default'))); }); testWidgets('Positive status', (WidgetTester tester) async { @@ -33,7 +33,7 @@ void main() { expect(label.status, ZetaWidgetStatus.positive); - await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_positive.png'))); + await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_positive'))); }); testWidgets('Warning status', (WidgetTester tester) async { @@ -44,7 +44,7 @@ void main() { expect(label.status, ZetaWidgetStatus.warning); - await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_warning.png'))); + await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_warning'))); }); testWidgets('Negative status', (WidgetTester tester) async { await tester.pumpWidget(const TestApp(home: ZetaLabel(label: 'Test Label', status: ZetaWidgetStatus.negative))); @@ -54,7 +54,7 @@ void main() { expect(label.status, ZetaWidgetStatus.negative); - await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_negative.png'))); + await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_negative'))); }); testWidgets('Neutral status', (WidgetTester tester) async { await tester.pumpWidget(const TestApp(home: ZetaLabel(label: 'Test Label', status: ZetaWidgetStatus.neutral))); @@ -64,7 +64,7 @@ void main() { expect(label.status, ZetaWidgetStatus.neutral); - await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_neutral.png'))); + await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_neutral'))); }); testWidgets('Dark mode', (WidgetTester tester) async { @@ -80,7 +80,7 @@ void main() { expect(label.status, ZetaWidgetStatus.info); - await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_dark.png'))); + await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_dark'))); }); testWidgets('Sharp', (WidgetTester tester) async { @@ -93,7 +93,7 @@ void main() { expect(label.rounded, false); - await expectLater(find.byType(ZetaLabel), matchesGoldenFile(join(getCurrentPath('badge'), 'label_sharp.png'))); + await expectLater(find.byType(ZetaLabel), matchesGoldenFile(goldenFile.getFileUri('label_sharp'))); }); testWidgets('debugFillProperties works correctly', (WidgetTester tester) async { diff --git a/test/src/components/badge/priority_pill_test.dart b/test/src/components/badge/priority_pill_test.dart index 28c53e1b..8724eba2 100644 --- a/test/src/components/badge/priority_pill_test.dart +++ b/test/src/components/badge/priority_pill_test.dart @@ -1,8 +1,6 @@ // ignore_for_file: avoid_dynamic_calls - import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -10,9 +8,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'badge'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('badge')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); testWidgets('Initializes with correct label and index', (WidgetTester tester) async { await tester.pumpWidget( @@ -36,7 +35,7 @@ void main() { await expectLater( find.byType(ZetaPriorityPill), - matchesGoldenFile(join(getCurrentPath('badge'), 'priority_pill_default.png')), + matchesGoldenFile(goldenFile.getFileUri('priority_pill_default')), ); }); testWidgets('High priority pill', (WidgetTester tester) async { @@ -64,7 +63,7 @@ void main() { await expectLater( find.byType(ZetaPriorityPill), - matchesGoldenFile(join(getCurrentPath('badge'), 'priority_pill_high.png')), + matchesGoldenFile(goldenFile.getFileUri('priority_pill_high')), ); }); testWidgets('Medium priority pill', (WidgetTester tester) async { @@ -84,7 +83,7 @@ void main() { await expectLater( find.byType(ZetaPriorityPill), - matchesGoldenFile(join(getCurrentPath('badge'), 'priority_pill_medium.png')), + matchesGoldenFile(goldenFile.getFileUri('priority_pill_medium')), ); }); testWidgets('Low priority pill', (WidgetTester tester) async { @@ -106,7 +105,7 @@ void main() { await expectLater( find.byType(ZetaPriorityPill), - matchesGoldenFile(join(getCurrentPath('badge'), 'priority_pill_low.png')), + matchesGoldenFile(goldenFile.getFileUri('priority_pill_low')), ); }); testWidgets('debugFillProperties works correctly', (WidgetTester tester) async { diff --git a/test/src/components/badge/status_label_test.dart b/test/src/components/badge/status_label_test.dart index 27c9d278..201a8ebc 100644 --- a/test/src/components/badge/status_label_test.dart +++ b/test/src/components/badge/status_label_test.dart @@ -1,7 +1,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -9,9 +8,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'badge'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('badge')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaStatusLabel Tests', () { testWidgets('Initializes with correct properties', (WidgetTester tester) async { @@ -24,7 +24,7 @@ void main() { await expectLater( find.byType(ZetaStatusLabel), - matchesGoldenFile(join(getCurrentPath('badge'), 'status_label_default.png')), + matchesGoldenFile(goldenFile.getFileUri('status_label_default')), ); }); }); @@ -43,7 +43,7 @@ void main() { await expectLater( find.byType(ZetaStatusLabel), - matchesGoldenFile(join(getCurrentPath('badge'), 'status_label_custom.png')), + matchesGoldenFile(goldenFile.getFileUri('status_label_custom')), ); }); testWidgets('debugFillProperties works correctly', (WidgetTester tester) async { diff --git a/test/src/components/badge/tag_test.dart b/test/src/components/badge/tag_test.dart index 6f6f4fcf..3dd84531 100644 --- a/test/src/components/badge/tag_test.dart +++ b/test/src/components/badge/tag_test.dart @@ -1,6 +1,5 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -8,9 +7,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'badge'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('badge')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaTag', () { testWidgets('Initializes right with correct parameters', (WidgetTester tester) async { @@ -24,7 +24,7 @@ void main() { await expectLater( find.byType(ZetaTag), - matchesGoldenFile(join(getCurrentPath('badge'), 'tag_right.png')), + matchesGoldenFile(goldenFile.getFileUri('tag_right')), ); }); @@ -38,7 +38,7 @@ void main() { await expectLater( find.byType(ZetaTag), - matchesGoldenFile(join(getCurrentPath('badge'), 'tag_left.png')), + matchesGoldenFile(goldenFile.getFileUri('tag_left')), ); }); }); diff --git a/test/src/components/button/button_test.dart b/test/src/components/button/button_test.dart index fed28ad8..c14a9271 100644 --- a/test/src/components/button/button_test.dart +++ b/test/src/components/button/button_test.dart @@ -3,7 +3,6 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -11,9 +10,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'button'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('button')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaButton Tests', () { @@ -55,7 +55,7 @@ void main() { expect(button.size, ZetaWidgetSize.medium); expect(button.type, ZetaButtonType.primary); - await expectLater(find.byType(ZetaButton), matchesGoldenFile(join(getCurrentPath('button'), 'button_primary.png'))); + await expectLater(find.byType(ZetaButton), matchesGoldenFile(goldenFile.getFileUri('button_primary'))); }); testWidgets('Initializes secondary with correct Label', (WidgetTester tester) async { await tester.pumpWidget( @@ -80,7 +80,7 @@ void main() { await expectLater( find.byType(ZetaButton), - matchesGoldenFile(join(getCurrentPath('button'), 'button_secondary.png')), + matchesGoldenFile(goldenFile.getFileUri('button_secondary')), ); }); testWidgets('Initializes positive with correct Label', (WidgetTester tester) async { @@ -101,7 +101,7 @@ void main() { await expectLater( find.byType(ZetaButton), - matchesGoldenFile(join(getCurrentPath('button'), 'button_positive.png')), + matchesGoldenFile(goldenFile.getFileUri('button_positive')), ); }); testWidgets('Initializes negative with correct Label', (WidgetTester tester) async { @@ -122,7 +122,7 @@ void main() { await expectLater( find.byType(ZetaButton), - matchesGoldenFile(join(getCurrentPath('button'), 'button_negative.png')), + matchesGoldenFile(goldenFile.getFileUri('button_negative')), ); }); testWidgets('Initializes outline with correct Label', (WidgetTester tester) async { @@ -141,7 +141,7 @@ void main() { expect(button.size, ZetaWidgetSize.large); expect(button.type, ZetaButtonType.outline); - await expectLater(find.byType(ZetaButton), matchesGoldenFile(join(getCurrentPath('button'), 'button_outline.png'))); + await expectLater(find.byType(ZetaButton), matchesGoldenFile(goldenFile.getFileUri('button_outline'))); }); testWidgets('Initializes outlineSubtle with correct Label', (WidgetTester tester) async { await tester.pumpWidget( @@ -161,7 +161,7 @@ void main() { await expectLater( find.byType(ZetaButton), - matchesGoldenFile(join(getCurrentPath('button'), 'button_outline_subtle.png')), + matchesGoldenFile(goldenFile.getFileUri('button_outline_subtle')), ); }); testWidgets('Initializes text with correct Label', (WidgetTester tester) async { @@ -182,7 +182,7 @@ void main() { await expectLater( find.byType(ZetaButton), - matchesGoldenFile(join(getCurrentPath('button'), 'button_text.png')), + matchesGoldenFile(goldenFile.getFileUri('button_text')), ); }); @@ -205,7 +205,7 @@ void main() { await expectLater( find.byType(ZetaButton), - matchesGoldenFile(join(getCurrentPath('button'), 'button_disabled.png')), + matchesGoldenFile(goldenFile.getFileUri('button_disabled')), ); }); testWidgets('Interaction with button', (WidgetTester tester) async { diff --git a/test/src/components/chat_item/chat_item_test.dart b/test/src/components/chat_item/chat_item_test.dart index 7e3456f7..8bafbc00 100644 --- a/test/src/components/chat_item/chat_item_test.dart +++ b/test/src/components/chat_item/chat_item_test.dart @@ -2,7 +2,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:intl/intl.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -10,9 +9,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'chat_item'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('chat_item')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaChatItem Tests', () { @@ -67,7 +67,7 @@ void main() { await expectLater( chatItemFinder, - matchesGoldenFile(join(getCurrentPath('chat_item'), 'chat_item_default.png')), + matchesGoldenFile(goldenFile.getFileUri('chat_item_default')), ); }); @@ -122,7 +122,7 @@ void main() { await expectLater( chatItemFinder, - matchesGoldenFile(join(getCurrentPath('chat_item'), 'chat_item_highlighted.png')), + matchesGoldenFile(goldenFile.getFileUri('chat_item_highlighted')), ); }); @@ -184,7 +184,7 @@ void main() { await expectLater( chatItemFinder, - matchesGoldenFile(join(getCurrentPath('chat_item'), 'chat_item_slidable_actions.png')), + matchesGoldenFile(goldenFile.getFileUri('chat_item_slidable_actions')), ); }); @@ -238,7 +238,7 @@ void main() { await expectLater( chatItemFinder, - matchesGoldenFile(join(getCurrentPath('chat_item'), 'chat_item_pale_slidable_buttons.png')), + matchesGoldenFile(goldenFile.getFileUri('chat_item_pale_slidable_buttons')), ); }); @@ -326,7 +326,7 @@ void main() { await expectLater( chatItemFinder, - matchesGoldenFile(join(getCurrentPath('chat_item'), 'chat_item_pale_and_regular_buttons.png')), + matchesGoldenFile(goldenFile.getFileUri('chat_item_pale_and_regular_buttons')), ); }); @@ -370,7 +370,7 @@ void main() { await expectLater( chatItemFinder, - matchesGoldenFile(join(getCurrentPath('chat_item'), 'chat_item_custom_leading.png')), + matchesGoldenFile(goldenFile.getFileUri('chat_item_custom_leading')), ); }); @@ -428,7 +428,7 @@ void main() { await expectLater( chatItemFinder, - matchesGoldenFile(join(getCurrentPath('chat_item'), 'chat_item_custom_slidable_buttons.png')), + matchesGoldenFile(goldenFile.getFileUri('chat_item_custom_slidable_buttons')), ); }); @@ -544,7 +544,7 @@ void main() { await expectLater( chatItemFinder, - matchesGoldenFile(join(getCurrentPath('chat_item'), 'chat_item_small_screen_slidable_button.png')), + matchesGoldenFile(goldenFile.getFileUri('chat_item_small_screen_slidable_button')), ); }); }); diff --git a/test/src/components/checkbox/checkbox_test.dart b/test/src/components/checkbox/checkbox_test.dart index f7c85810..c2c00c56 100644 --- a/test/src/components/checkbox/checkbox_test.dart +++ b/test/src/components/checkbox/checkbox_test.dart @@ -3,7 +3,6 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/src/components/checkbox/checkbox.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; @@ -12,9 +11,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'checkbox'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('checkbox')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaCheckbox Tests', () { @@ -54,7 +54,7 @@ void main() { final checkboxFinder = find.byType(ZetaCheckbox); await expectLater( checkboxFinder, - matchesGoldenFile(join(getCurrentPath('checkbox'), 'checkbox_enabled.png')), + matchesGoldenFile(goldenFile.getFileUri('checkbox_enabled')), ); await tester.tap(find.byType(ZetaCheckbox)); await tester.pump(); @@ -73,7 +73,7 @@ void main() { final checkboxFinder = find.byType(ZetaCheckbox); await expectLater( checkboxFinder, - matchesGoldenFile(join(getCurrentPath('checkbox'), 'checkbox_disabled.png')), + matchesGoldenFile(goldenFile.getFileUri('checkbox_disabled')), ); await tester.tap(find.byType(ZetaCheckbox)); await tester.pump(); @@ -136,7 +136,7 @@ void main() { await tester.pumpAndSettle(); await expectLater( checkboxFinder, - matchesGoldenFile(join(getCurrentPath('checkbox'), 'checkbox_hover.png')), + matchesGoldenFile(goldenFile.getFileUri('checkbox_hover')), ); }); diff --git a/test/src/components/dialpad/dialpad_test.dart b/test/src/components/dialpad/dialpad_test.dart index 1b19da10..f85a2d54 100644 --- a/test/src/components/dialpad/dialpad_test.dart +++ b/test/src/components/dialpad/dialpad_test.dart @@ -3,7 +3,6 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -11,9 +10,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'dialpad'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('dialpad')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaDialPad Tests', () { @@ -126,7 +126,7 @@ void main() { await expectLater( dialPadFinder, - matchesGoldenFile(join(getCurrentPath('dialpad'), 'dialpad_enabled.png')), + matchesGoldenFile(goldenFile.getFileUri('dialpad_enabled')), ); }); }); @@ -235,7 +235,7 @@ void main() { await expectLater( dialPadFinder, - matchesGoldenFile(join(getCurrentPath('dialpad'), 'dialpad_disabled.png')), + matchesGoldenFile(goldenFile.getFileUri('dialpad_disabled')), ); }); testWidgets('ZetaDialPadButton interaction', (WidgetTester tester) async { @@ -259,7 +259,7 @@ void main() { await expectLater( buttonFinder, - matchesGoldenFile(join(getCurrentPath('dialpad'), 'dialpadbutton.png')), + matchesGoldenFile(goldenFile.getFileUri('dialpadbutton')), ); }); diff --git a/test/src/components/fab/golden/FAB_default.png b/test/src/components/fab/golden/FAB_default.png new file mode 100644 index 00000000..70d8d11e Binary files /dev/null and b/test/src/components/fab/golden/FAB_default.png differ diff --git a/test/src/components/fab/golden/FAB_disabled.png b/test/src/components/fab/golden/FAB_disabled.png new file mode 100644 index 00000000..8a0e4a44 Binary files /dev/null and b/test/src/components/fab/golden/FAB_disabled.png differ diff --git a/test/src/components/fab/golden/FAB_inverse.png b/test/src/components/fab/golden/FAB_inverse.png new file mode 100644 index 00000000..1f994e94 Binary files /dev/null and b/test/src/components/fab/golden/FAB_inverse.png differ diff --git a/test/src/components/fab/golden/FAB_pressed.png b/test/src/components/fab/golden/FAB_pressed.png new file mode 100644 index 00000000..e0b19382 Binary files /dev/null and b/test/src/components/fab/golden/FAB_pressed.png differ diff --git a/test/src/components/fab/golden/FAB_secondary.png b/test/src/components/fab/golden/FAB_secondary.png new file mode 100644 index 00000000..ae97e30a Binary files /dev/null and b/test/src/components/fab/golden/FAB_secondary.png differ diff --git a/test/src/components/fabs/fab_test.dart b/test/src/components/fabs/fab_test.dart index e9e79000..cb90a4b3 100644 --- a/test/src/components/fabs/fab_test.dart +++ b/test/src/components/fabs/fab_test.dart @@ -3,16 +3,16 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'fab'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('fabs')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaFAB Tests', () { @@ -28,7 +28,7 @@ void main() { await expectLater( find.byType(ZetaFAB), - matchesGoldenFile(join(getCurrentPath('fabs'), 'FAB_default.png')), + matchesGoldenFile(goldenFile.getFileUri('FAB_default')), ); }); @@ -47,7 +47,7 @@ void main() { await expectLater( find.byType(ZetaFAB), - matchesGoldenFile(join(getCurrentPath('fabs'), 'FAB_pressed.png')), + matchesGoldenFile(goldenFile.getFileUri('FAB_pressed')), ); await e.up(); @@ -78,7 +78,7 @@ void main() { await expectLater( find.byType(ZetaFAB), - matchesGoldenFile(join(getCurrentPath('fabs'), 'FAB_inverse.png')), + matchesGoldenFile(goldenFile.getFileUri('FAB_inverse')), ); }); @@ -104,7 +104,7 @@ void main() { await expectLater( find.byType(ZetaFAB), - matchesGoldenFile(join(getCurrentPath('fabs'), 'FAB_secondary.png')), + matchesGoldenFile(goldenFile.getFileUri('FAB_secondary')), ); }); testWidgets('ZetaFAB interactive', (WidgetTester tester) async { @@ -168,7 +168,7 @@ void main() { await expectLater( find.byType(ZetaFAB), - matchesGoldenFile(join(getCurrentPath('fabs'), 'FAB_disabled.png')), + matchesGoldenFile(goldenFile.getFileUri('FAB_disabled')), ); }); diff --git a/test/src/components/in_page_banner/in_page_banner_test.dart b/test/src/components/in_page_banner/in_page_banner_test.dart index a15b4205..4c825515 100644 --- a/test/src/components/in_page_banner/in_page_banner_test.dart +++ b/test/src/components/in_page_banner/in_page_banner_test.dart @@ -1,16 +1,17 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; + import '../../../test_utils/test_app.dart'; import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'in_page_banner'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('in_page_banner')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaInPageBanner Tests', () { @@ -32,7 +33,7 @@ void main() { await expectLater( find.byType(ZetaInPageBanner), - matchesGoldenFile(join(getCurrentPath('in_page_banner'), 'in_page_banner_default.png')), + matchesGoldenFile(goldenFile.getFileUri('in_page_banner_default')), ); }); }); @@ -50,7 +51,7 @@ void main() { expect(decoration.color, ZetaColorBase.red.shade10); await expectLater( find.byType(ZetaInPageBanner), - matchesGoldenFile(join(getCurrentPath('in_page_banner'), 'in_page_banner_negative.png')), + matchesGoldenFile(goldenFile.getFileUri('in_page_banner_negative')), ); }); @@ -66,7 +67,7 @@ void main() { expect(decoration.color, ZetaColorBase.green.shade10); await expectLater( find.byType(ZetaInPageBanner), - matchesGoldenFile(join(getCurrentPath('in_page_banner'), 'in_page_banner_positive.png')), + matchesGoldenFile(goldenFile.getFileUri('in_page_banner_positive')), ); }); @@ -101,7 +102,7 @@ void main() { await expectLater( find.byType(ZetaInPageBanner), - matchesGoldenFile(join(getCurrentPath('in_page_banner'), 'in_page_banner_buttons.png')), + matchesGoldenFile(goldenFile.getFileUri('in_page_banner_buttons')), ); }); testWidgets("ZetaInPageBanner 'close' icon tap test", (WidgetTester tester) async { diff --git a/test/src/components/password/password_input_test.dart b/test/src/components/password/password_input_test.dart index 2a6af86a..57dbbd28 100644 --- a/test/src/components/password/password_input_test.dart +++ b/test/src/components/password/password_input_test.dart @@ -1,7 +1,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -9,9 +8,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'password'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('password')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); testWidgets('ZetaPasswordInput initializes correctly', (WidgetTester tester) async { @@ -24,7 +24,7 @@ void main() { await expectLater( find.byType(ZetaPasswordInput), - matchesGoldenFile(join(getCurrentPath('password'), 'password_default.png')), + matchesGoldenFile(goldenFile.getFileUri('password_default')), ); }); @@ -75,7 +75,7 @@ void main() { await expectLater( find.byType(ZetaPasswordInput), - matchesGoldenFile(join(getCurrentPath('password'), 'password_error.png')), + matchesGoldenFile(goldenFile.getFileUri('password_error')), ); }); testWidgets('Test debugFillProperties', (WidgetTester tester) async { diff --git a/test/src/components/search_bar/search_bar_test.dart b/test/src/components/search_bar/search_bar_test.dart index 8c28fbe4..9cfaef8b 100644 --- a/test/src/components/search_bar/search_bar_test.dart +++ b/test/src/components/search_bar/search_bar_test.dart @@ -3,7 +3,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -27,10 +26,10 @@ abstract class ISearchBarEvents { ]) void main() { late MockISearchBarEvents callbacks; + const goldenFile = GoldenFiles(component: 'search_bar'); setUpAll(() { - final testUri = Uri.parse(getCurrentPath('search_bar')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); setUp(() { @@ -61,7 +60,7 @@ void main() { await expectLater( find.byType(ZetaSearchBar), - matchesGoldenFile(join(getCurrentPath('search_bar'), 'search_bar_default.png')), + matchesGoldenFile(goldenFile.getFileUri('search_bar_default')), ); }); @@ -75,7 +74,7 @@ void main() { await expectLater( find.byType(ZetaSearchBar), - matchesGoldenFile(join(getCurrentPath('search_bar'), 'search_bar_medium.png')), + matchesGoldenFile(goldenFile.getFileUri('search_bar_medium')), ); }); @@ -91,7 +90,7 @@ void main() { await expectLater( find.byType(ZetaSearchBar), - matchesGoldenFile(join(getCurrentPath('search_bar'), 'search_bar_small.png')), + matchesGoldenFile(goldenFile.getFileUri('search_bar_small')), ); }); @@ -107,7 +106,7 @@ void main() { await expectLater( find.byType(ZetaSearchBar), - matchesGoldenFile(join(getCurrentPath('search_bar'), 'search_bar_full.png')), + matchesGoldenFile(goldenFile.getFileUri('search_bar_full')), ); }); @@ -123,7 +122,7 @@ void main() { await expectLater( find.byType(ZetaSearchBar), - matchesGoldenFile(join(getCurrentPath('search_bar'), 'search_bar_sharp.png')), + matchesGoldenFile(goldenFile.getFileUri('search_bar_sharp')), ); }); diff --git a/test/src/components/tooltip/tooltip_test.dart b/test/src/components/tooltip/tooltip_test.dart index 71961158..b1c5284f 100644 --- a/test/src/components/tooltip/tooltip_test.dart +++ b/test/src/components/tooltip/tooltip_test.dart @@ -1,11 +1,9 @@ // ignore_for_file: avoid_dynamic_calls - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -19,10 +17,10 @@ import 'tooltip_test.mocks.dart'; void main() { final mockZeta = MockZeta(); when(mockZeta.radius).thenReturn(const ZetaRadiiAA(primitives: ZetaPrimitivesLight())); - setUpAll(() { - final testUri = Uri.parse(getCurrentPath('tooltip')); + const goldenFile = GoldenFiles(component: 'tooltip'); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + setUpAll(() { + goldenFileComparator = TolerantComparator(goldenFile.uri); }); group('ZetaTooltip Widget Tests', () { @@ -118,7 +116,7 @@ void main() { // Verifying the CustomPaint with different arrow directions. await expectLater( find.byType(ZetaTooltip), - matchesGoldenFile(join(getCurrentPath('tooltip'), 'arrow_up.png')), + matchesGoldenFile(goldenFile.getFileUri('arrow_up')), ); }); @@ -138,7 +136,7 @@ void main() { // Verifying the CustomPaint with different arrow directions. await expectLater( find.byType(ZetaTooltip), - matchesGoldenFile(join(getCurrentPath('tooltip'), 'arrow_down.png')), + matchesGoldenFile(goldenFile.getFileUri('arrow_down')), ); }); @@ -159,7 +157,7 @@ void main() { // Verifying the CustomPaint with different arrow directions. await expectLater( find.byType(ZetaTooltip), - matchesGoldenFile(join(getCurrentPath('tooltip'), 'arrow_left.png')), + matchesGoldenFile(goldenFile.getFileUri('arrow_left')), ); }); @@ -180,7 +178,7 @@ void main() { // Verifying the CustomPaint with different arrow directions. await expectLater( find.byType(ZetaTooltip), - matchesGoldenFile(join(getCurrentPath('tooltip'), 'arrow_right.png')), + matchesGoldenFile(goldenFile.getFileUri('arrow_right')), ); }); diff --git a/test/src/components/top_app_bar/extended_top_app_bar_test.dart b/test/src/components/top_app_bar/extended_top_app_bar_test.dart index 379b2a14..ecc49885 100644 --- a/test/src/components/top_app_bar/extended_top_app_bar_test.dart +++ b/test/src/components/top_app_bar/extended_top_app_bar_test.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:path/path.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; import '../../../test_utils/test_app.dart'; @@ -8,9 +7,10 @@ import '../../../test_utils/tolerant_comparator.dart'; import '../../../test_utils/utils.dart'; void main() { + const goldenFile = GoldenFiles(component: 'top_app_bar'); + setUpAll(() { - final testUri = Uri.parse(getCurrentPath('top_app_bar')); - goldenFileComparator = TolerantComparator(testUri, tolerance: 0.01); + goldenFileComparator = TolerantComparator(goldenFile.uri); }); testWidgets('ZetaExtendedAppBarDelegate builds correctly', (WidgetTester tester) async { @@ -65,7 +65,7 @@ void main() { await expectLater( appBarFinder, - matchesGoldenFile(join(getCurrentPath('top_app_bar'), 'extended_app_bar_shrinks.png')), + matchesGoldenFile(goldenFile.getFileUri('extended_app_bar_shrinks')), ); }); @@ -163,7 +163,7 @@ void main() { await expectLater( appBarFinder, - matchesGoldenFile(join(getCurrentPath('top_app_bar'), 'extended_app_bar_shrinks_with_no_leading.png')), + matchesGoldenFile(goldenFile.getFileUri('extended_app_bar_shrinks_with_no_leading')), ); }); } diff --git a/test/test_utils/tolerant_comparator.dart b/test/test_utils/tolerant_comparator.dart index 7e5bdda4..fdfeed03 100644 --- a/test/test_utils/tolerant_comparator.dart +++ b/test/test_utils/tolerant_comparator.dart @@ -5,13 +5,13 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:image/image.dart' as img; class TolerantComparator extends LocalFileComparator { - TolerantComparator(super.testFile, {this.tolerance = 0.0}); + TolerantComparator(Uri testFile, {this.tolerance = 0.01}) : super(testFile.replace(scheme: 'file')); final double tolerance; @override Future compare(Uint8List imageBytes, Uri golden) async { - final goldenFile = File.fromUri(golden); + final goldenFile = File.fromUri(golden.replace(scheme: 'file')); if (!goldenFile.existsSync()) { goldenFile ..createSync(recursive: true) diff --git a/test/test_utils/utils.dart b/test/test_utils/utils.dart index 1afb1742..e8e7acc2 100644 --- a/test/test_utils/utils.dart +++ b/test/test_utils/utils.dart @@ -4,10 +4,6 @@ import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; import 'package:path/path.dart'; -String getCurrentPath(String component, {String type = 'components'}) { - return join(Directory.current.path, 'test', 'src', type, component, 'golden'); -} - extension Util on DiagnosticPropertiesBuilder { dynamic finder(String finder) { return properties.where((p) => p.name == finder).map((p) => p.toDescription()).firstOrNull; @@ -17,3 +13,17 @@ extension Util on DiagnosticPropertiesBuilder { return properties.firstWhereOrNull((p) => p.name == propertyName)?.value; } } + +class GoldenFiles { + const GoldenFiles({required this.component, this.type = 'components'}); + + final String component; + final String type; + + Uri get uri => getFileUri(''); + + Uri getFileUri(String fileName) { + return Uri.parse(join(Directory.current.path, 'test', 'src', type, component, 'golden', '$fileName.png')) + .replace(scheme: 'file'); + } +}