Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add golden_toolkit to sharezone_widgets #900

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/sharezone_widgets/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2022 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

tags:
# The tag "golden" is used by the "golden_toolkit" package.
#
# This will indicate that goldens are an expected test tag. All tests that use
# testGoldens() will automatically be given this tag. This allows you to
# easily target golden tests from the command line.
golden:
8 changes: 8 additions & 0 deletions lib/sharezone_widgets/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
golden_toolkit:
dependency: "direct dev"
description:
name: golden_toolkit
sha256: "8f74adab33154fe7b731395782797021f97d2edc52f7bfb85ff4f1b5c4a215f0"
url: "https://pub.dev"
source: hosted
version: "0.15.0"
http_parser:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions lib/sharezone_widgets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
golden_toolkit: ^0.15.0
sharezone_lints:
path: ../sharezone_lints
46 changes: 46 additions & 0 deletions lib/sharezone_widgets/test_goldens/flutter_test_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2022 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 'dart:async';
import 'dart:io';
import 'dart:ui';

import 'package:golden_toolkit/golden_toolkit.dart';

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
const Device phoneLandscape = Device(
name: 'phone_landscape',
size: Size(667, 375),
);

return GoldenToolkit.runWithConfiguration(
() async {
await loadAppFonts();
await testMain();
},
config: GoldenToolkitConfiguration(
// Due to slight differences in rendering across platforms, mostly around
// text, the tests will only be run on a macOS machine on Github Actions.
// This means that if you update the tests on a Linux or Windows machine
// the golden tests will not pass on Github Actions. Instead you are
// recommended to download the goldens directly from the failed Github
// Actions job, and use those inside of your branch.
//
// See
// https://github.com/flutter/flutter/issues/36667#issuecomment-521335243.
skipGoldenAssertion: () => !Platform.isMacOS,
defaultDevices: const [
Device.phone,
phoneLandscape,
Device.tabletLandscape,
Device.tabletPortrait,
Device.iphone11,
],
),
);
}