Skip to content

ci: update tests for arrayContainsAny & isNotEqualTo which now result in a "failed-precondition" exception. #12529

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

Merged
merged 5 commits into from
Mar 25, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ void runSecondDatabaseTests() {
});
});
/**
* get
*/
* get
*/
group('Query.get()', () {
testWidgets('returns a [QuerySnapshot]', (_) async {
CollectionReference<Map<String, dynamic>> collection =
Expand Down Expand Up @@ -194,8 +194,8 @@ void runSecondDatabaseTests() {
});

/**
* snapshots
*/
* snapshots
*/
group('Query.snapshots()', () {
testWidgets('returns a [Stream]', (_) async {
CollectionReference<Map<String, dynamic>> collection =
Expand Down Expand Up @@ -340,8 +340,8 @@ void runSecondDatabaseTests() {
});

/**
* End At
*/
* End At
*/

group('Query.endAt{Document}()', () {
testWidgets('ends at string field paths', (_) async {
Expand Down Expand Up @@ -506,8 +506,8 @@ void runSecondDatabaseTests() {
});

/**
* Start At
*/
* Start At
*/

group('Query.startAt{Document}()', () {
testWidgets('starts at string field paths', (_) async {
Expand Down Expand Up @@ -671,8 +671,8 @@ void runSecondDatabaseTests() {
});

/**
* End Before
*/
* End Before
*/

group('Query.endBefore{Document}()', () {
testWidgets('ends before string field paths', (_) async {
Expand Down Expand Up @@ -837,8 +837,8 @@ void runSecondDatabaseTests() {
});

/**
* Start after
*/
* Start after
*/
group('Query.startAfter{Document}()', () {
testWidgets('starts after string field paths', (_) async {
CollectionReference<Map<String, dynamic>> collection =
Expand Down Expand Up @@ -968,8 +968,8 @@ void runSecondDatabaseTests() {
});

/**
* Start & End
*/
* Start & End
*/

group('Query.startAt/endAt', () {
testWidgets('starts at & ends at a document', (_) async {
Expand Down Expand Up @@ -1084,8 +1084,8 @@ void runSecondDatabaseTests() {
});

/**
* Limit
*/
* Limit
*/

group('Query.limit{toLast}()', () {
testWidgets('limits documents', (_) async {
Expand Down Expand Up @@ -1152,8 +1152,8 @@ void runSecondDatabaseTests() {
});

/**
* Order
*/
* Order
*/
group('Query.orderBy()', () {
testWidgets('allows ordering by documentId', (_) async {
CollectionReference<Map<String, dynamic>> collection =
Expand Down Expand Up @@ -1236,8 +1236,8 @@ void runSecondDatabaseTests() {
});

/**
* Where filters
*/
* Where filters
*/

group('Query.where()', () {
testWidgets(
Expand Down Expand Up @@ -1820,15 +1820,82 @@ void runSecondDatabaseTests() {
Filter('totalDomesticRevenue', isEqualTo: 60000000),
Filter('totalWorldwideRevenue', isEqualTo: 200000000),
Filter('estimatedProfit', isEqualTo: 140000000),
// Fails because this is not allowed when arrayContainsAny is included in the Query
// Inequality causes "failed-precondition" exception and asks user to create an index
Filter('mainCharacter', isNotEqualTo: 'MainCharacter2'),
),
)
.orderBy('rating', descending: true)
.get(),
throwsA(
isA<FirebaseException>()
.having((e) => e.code, 'code', 'invalid-argument'),
.having((e) => e.code, 'code', 'failed-precondition')
.having(
(e) => e.message,
'message',
contains(
'The query contains range and inequality filters on multiple fields',
),
),
),
);
},
);

testWidgets(
'Exception thrown when combining `arrayContainsAny` & `isNotEqualTo` in multiple conjunctive queries',
(_) async {
CollectionReference<Map<String, dynamic>> collection =
await initializeTest('multiple-conjunctive-queries');

await expectLater(
collection
.where(
Filter.and(
Filter('rating1', isEqualTo: 3.8),
Filter('year1', isEqualTo: 1970),
Filter('runtime1', isEqualTo: 90),
Filter('director1', isEqualTo: 'Director2'),
Filter('producer1', isEqualTo: 'Producer2'),
Filter('budget1', isEqualTo: 20000000),
Filter('boxOffice1', isEqualTo: 50000000),
Filter('actor1', isEqualTo: 'Actor2'),
Filter('language1', isEqualTo: 'English'),
Filter('award1', isEqualTo: 'Award2'),
Filter('genre1', arrayContainsAny: ['sci-fi']),
Filter('country1', isEqualTo: 'USA'),
Filter('released1', isEqualTo: true),
Filter('screenplay1', isEqualTo: 'Screenplay2'),
Filter('cinematography1', isEqualTo: 'Cinematography2'),
Filter('music1', isEqualTo: 'Music2'),
Filter('rating2', isEqualTo: 4.2),
Filter('year2', isEqualTo: 1982),
Filter('runtime2', isEqualTo: 60),
Filter('director2', isEqualTo: 'Director3'),
Filter('producer2', isEqualTo: 'Producer3'),
Filter('budget2', isEqualTo: 30000000),
Filter('boxOffice2', isEqualTo: 60000000),
Filter('actor2', isEqualTo: 'Actor3'),
Filter('language2', isEqualTo: 'Korean'),
Filter('award2', isEqualTo: 'Award3'),
Filter('genre2', isEqualTo: ['sci-fi', 'action']),
Filter('country2', isEqualTo: 'South Korea'),
Filter('released2', isEqualTo: false),
// Inequality causes "failed-precondition" exception and asks user to create an index
Filter('screenplay2', isNotEqualTo: 'blah'),
),
)
.orderBy('rating1', descending: true)
.get(),
throwsA(
isA<FirebaseException>()
.having((e) => e.code, 'code', 'failed-precondition')
.having(
(e) => e.message,
'message',
contains(
'The query contains range and inequality filters on multiple fields',
),
),
),
);
},
Expand Down
Loading