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

fix: Dialog and dropdowns are no longer visible on the golden files #79

Closed
1 task done
soeren-schmaljohann-2denker opened this issue Sep 15, 2022 · 1 comment · Fixed by #91
Closed
1 task done
Labels
bug Something isn't working

Comments

@soeren-schmaljohann-2denker

Is there an existing issue for this?

  • I have searched the existing issues.

Version

0.5.0

Description

After upgrading from version 0.3.3 to 0.5.0 the golden test stopped showing dialogs and opened dropdown menus. I have changed nothing with the pre test pumps, but still

Steps to reproduce

This is a test I wrote, trying to reproduce it:

import 'package:alchemist/alchemist.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  goldenTest(
    'drop down',
    fileName: 'dropdown',
    constraints: const BoxConstraints(
      maxWidth: 500,
      maxHeight: 500,
    ),
    pumpBeforeTest: (tester) async {
      await tester.pumpAndSettle();
      await tester.tap(find.byType(DropdownButton<String>));
      await tester.pumpAndSettle();
    },
    builder: () {
      return const TestApp();
    },
  );

  goldenTest(
    'dialog',
    fileName: 'dialog',
    constraints: const BoxConstraints(
      maxWidth: 500,
      maxHeight: 500,
    ),
    pumpBeforeTest: (tester) async {
      await tester.pumpAndSettle();
      await tester.tap(find.byType(TextButton));
      await tester.pumpAndSettle();
    },
    builder: () {
      return const TestApp();
    },
  );
}

class TestApp extends StatelessWidget {
  const TestApp({super.key});

  @override
  Widget build(BuildContext context) => Material(
        child: Center(
          child: Column(
            children: [
              DropdownButton<String>(
                value: '0',
                items: const [
                  DropdownMenuItem<String>(
                    value: '0',
                    child: Text('0'),
                  ),
                  DropdownMenuItem<String>(
                    value: '1',
                    child: Text('1'),
                  ),
                  DropdownMenuItem<String>(
                    value: '2',
                    child: Text('2'),
                  ),
                ],
                onChanged: null,
              ),
              TextButton(
                onPressed: () {
                  showDialog(
                    context: context,
                    builder: (context) => const AlertDialog(
                      content: Text('popup'),
                    ),
                  );
                },
                child: const Text('button'),
              )
            ],
          ),
        ),
      );
}

This is the config setup:

// flutter_test_config.dart

import 'dart:async';
import 'dart:io';

import 'package:alchemist/alchemist.dart';
import 'package:flutter/material.dart';

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
  // This is used to detect if it is running in a github actions workflow
  // For other CI Systems this might look different
  final isRunningInCi = Platform.environment['CI'] == 'true';

  return AlchemistConfig.runWithConfig(
    config: AlchemistConfig(
      theme: baseTheme.copyWith(textTheme: strippedTextTheme),
      platformGoldensConfig: PlatformGoldensConfig(
        enabled: !isRunningInCi,
      ),
    ),
    run: testMain,
  );
}

final baseTheme = ThemeData.light();
final baseTextTheme = baseTheme.textTheme;

final strippedTextTheme = baseTextTheme.copyWith(
  displayLarge: baseTextTheme.displayLarge?.forGoldens,
  displayMedium: baseTextTheme.displayMedium?.forGoldens,
  displaySmall: baseTextTheme.displaySmall?.forGoldens,
  headlineLarge: baseTextTheme.headlineLarge?.forGoldens,
  headlineMedium: baseTextTheme.headlineMedium?.forGoldens,
  headlineSmall: baseTextTheme.headlineSmall?.forGoldens,
  bodyLarge: baseTextTheme.bodyLarge?.forGoldens,
  bodyMedium: baseTextTheme.bodyMedium?.forGoldens,
  bodySmall: baseTextTheme.bodySmall?.forGoldens,
  titleLarge: baseTextTheme.titleLarge?.forGoldens,
  titleMedium: baseTextTheme.titleMedium?.forGoldens,
  titleSmall: baseTextTheme.titleSmall?.forGoldens,
  labelLarge: baseTextTheme.labelLarge?.forGoldens,
  labelMedium: baseTextTheme.labelMedium?.forGoldens,
  labelSmall: baseTextTheme.labelSmall?.forGoldens,
);

extension _GoldenTextStyle on TextStyle {
  TextStyle get forGoldens {
    final familySplit = fontFamily?.split('/');
    final rawFamily = familySplit?.last;

    return TextStyle(
      inherit: inherit,
      color: color,
      backgroundColor: backgroundColor,
      fontSize: fontSize,
      fontWeight: fontWeight,
      fontStyle: fontStyle,
      letterSpacing: letterSpacing,
      wordSpacing: wordSpacing,
      textBaseline: textBaseline,
      height: height,
      locale: locale,
      foreground: foreground,
      background: background,
      shadows: shadows,
      fontFeatures: fontFeatures,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      decorationThickness: decorationThickness,
      debugLabel: debugLabel,
      package: null,
      fontFamily: rawFamily,
      fontFamilyFallback: const ['Roboto'],
    );
  }
}

And these are the resulting images (for the ci):

dialog
dropdown

Expected behavior

The dropdown menu and dialog should be visable like in these screenshots generated with the 0.3.3 version (sadly due to the The non-abstract class 'BlockedTextCanvasAdapter' is missing implementations for these members error I can't produce these with the provided code, so I took the screenshot from our app):

app-project-dialog
projects-dropdown

Screenshots

No response

Additional context and comments

No response

@soeren-schmaljohann-2denker soeren-schmaljohann-2denker added the bug Something isn't working label Sep 15, 2022
@fikretsengul
Copy link

I have the same issue.

ABausG pushed a commit to ABausG/alchemist that referenced this issue May 17, 2023
…no_longer_visible_on_the_golden_files_(Betterment#79)' into fixes
btrautmann pushed a commit that referenced this issue May 25, 2023
…) (#91)

Co-authored-by: Christoph Schacht <christoph.schacht@lyth.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants