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

test(fdc): add e2e and unit tests to fdc #13224

Merged
merged 137 commits into from
Sep 12, 2024
Merged

test(fdc): add e2e and unit tests to fdc #13224

merged 137 commits into from
Sep 12, 2024

Conversation

Lyokone
Copy link
Contributor

@Lyokone Lyokone commented Aug 27, 2024

Description

Replace this paragraph with a description of what this PR is doing. If you're modifying existing behavior, describe the existing behavior, how this PR is changing it, and what motivated the change.

Related Issues

#13063

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@Lyokone Lyokone changed the title test(fdc): add e2e tests to fdc test(fdc): add e2e and unit tests to fdc Sep 11, 2024
Copy link
Member

@russellwheatley russellwheatley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor feedback but it's looking good to me 👍

- 'docs/**'
- 'website/**'
- '**/example/**'
- '**/flutterfire_ui/**'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- '**/flutterfire_ui/**'

.github/workflows/e2e_tests_fdc.yaml Show resolved Hide resolved
path: |
~/.android/avd/*
~/.android/adb*
key: avd-ubuntu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key: avd-ubuntu
key: avd-${{ runner.os }}

- uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92
name: Xcode Compile Cache
with:
key: ${{ runner.os }}-ios-fdc-v3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key: ${{ runner.os }}-ios-fdc-v3
key: xcode-cache-${{ runner.os }}

Comment on lines 37 to 69
final listener = MoviesConnector.instance.listMovies
.ref()
.subscribe()
.listen((value) {
final movies = value.data.movies;

if (count == 0) {
expect(movies.length, 0,
reason: 'First emission should contain an empty list');
} else {
expect(movies.length, 1,
reason: 'Second emission should contain one movie');
expect(movies[0].title, 'The Matrix',
reason: 'The movie should be The Matrix');
hasBeenListened = true;
}
count++;
});

await Future.delayed(const Duration(seconds: 1));

await MoviesConnector.instance.createMovie
.ref(
genre: 'Action',
title: 'The Matrix',
releaseYear: 1999,
rating: 4.5,
)
.execute();

await MoviesConnector.instance.listMovies.ref().execute();

await Future.delayed(const Duration(seconds: 1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth using Completers for this type of test: https://github.com/firebase/flutterfire/blob/spm-core-2/tests/integration_test/firebase_storage/task_e2e.dart#L136-L163

It means you don't have to use Future.delayed which could be flakey

group(
'$FirebaseDataConnect.instance listen',
() {
// ignore: unused_local_variable
Copy link
Member

@russellwheatley russellwheatley Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is still needed if it is used?

group(
'$FirebaseDataConnect.instance query',
() {
// ignore: unused_local_variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
description: 'A new Flutter project.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: 'A new Flutter project.'
description: 'Firebase Data Connect example app'

late MockFirebaseAuth mockAuth;
late MockFirebaseAppCheck mockAppCheck;
late MockConnectorConfig mockConnectorConfig;
// ignore: unused_local_variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ignore: unused_local_variable

I guess this can also be removed

DeleteMovieMovieDelete.fromJson(Map<String, dynamic> json)
: id = json['id'] {}

// TODO(mtewani): Fix up to create a map on the fly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these todos relevant btw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These todos are generated when using the VSCode extension, so nothing we can directly do in this repository.

@Lyokone Lyokone merged commit fa12459 into dataconnect Sep 12, 2024
24 of 25 checks passed
@Lyokone Lyokone deleted the tests/fdc branch September 12, 2024 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants