Skip to content

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

Merged
Lyokone merged 137 commits into
dataconnectfrom
tests/fdc
Sep 12, 2024
Merged

test(fdc): add e2e and unit tests to fdc#13224
Lyokone merged 137 commits into
dataconnectfrom
tests/fdc

Conversation

@Lyokone

@Lyokone Lyokone commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

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

@russellwheatley russellwheatley left a comment

Copy link
Copy Markdown
Member

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 👍

Comment thread .github/workflows/e2e_tests_fdc.yaml Outdated
- 'docs/**'
- 'website/**'
- '**/example/**'
- '**/flutterfire_ui/**'

Copy link
Copy Markdown
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/**'

Comment thread .github/workflows/e2e_tests_fdc.yaml
Comment thread .github/workflows/e2e_tests_fdc.yaml Outdated
path: |
~/.android/avd/*
~/.android/adb*
key: avd-ubuntu

Copy link
Copy Markdown
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 }}

Comment thread .github/workflows/e2e_tests_fdc.yaml Outdated
- uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92
name: Xcode Compile Cache
with:
key: ${{ runner.os }}-ios-fdc-v3

Copy link
Copy Markdown
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
Copy Markdown
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

@russellwheatley russellwheatley Sep 12, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
@Lyokone
Lyokone deleted the tests/fdc branch September 12, 2024 11:19
@firebase firebase locked and limited conversation to collaborators Oct 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants