Open LuckyKoni opened 6 months ago
Hi @LuckyKoni - Thank you for submitting the issue. Given the nature of the issue and its association with the involved data, it appears to be more project-specific, which may require additional time for thorough investigation on our end. To expedite the resolution process, I recommend creating a sample function with mock data (utilizing app state to store the data) to replicate the issue. Share the details with us. it will greatly help us in swiftly investigating and resolving the issue.
Thanks @hariprasadms I have just created a minimal project to demo my problem. The Bug Report Code: IT4slsmAsI1Nobhe+KryKPl7/SE4H202bY08scp/bxIgGIDzPOw+ZPWldhdoOemgTGxUI0SmmnsEw/DrjuPuUsI5OTmAbqZzws99FzrKIUC5QZOBDJC7OEFSGfhbJlDH1sKK2iNvLs1YLXdh7TuYeuetEzTAJLKzImdISq/LZO4=
Function code
import 'dart:convert';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:timeago/timeago.dart' as timeago;
import '/flutter_flow/lat_lng.dart';
import '/flutter_flow/place.dart';
import '/flutter_flow/uploaded_file.dart';
import '/flutter_flow/custom_functions.dart';
import '/backend/backend.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
String? getProductsTest(
List<ProductscopyRecord> products,
DateTime startDate,
DateTime endDate,
) {
/// MODIFY CODE ONLY BELOW THIS LINE
List<ProductscopyRecord> productsPost = products.where((product) {
return !product.isBooking;
}).toList();
List<ProductscopyRecord> queryBookingRecords = products.where((product) {
return product.isBooking &&
productsPost.map((p) => p.pid).contains(product.pid);
}).toList();
List<ProductscopyRecord> output = productsPost.where((p) {
bool hasBooking = queryBookingRecords.any((b) =>
startDate.isBefore(b.bookingEndDatetime!) &&
endDate.isAfter(b.bookingStartDatetime!));
return !hasBooking;
}).toList();
return output.length.toString();
/// MODIFY CODE ONLY ABOVE THIS LINE
}
Test function output: 0
Test function input data:
UI test output: 1 (Which is unexpected and inconsistent with function test)
The app state used:
Please let me know if you need more info.
And also here are the Document:
Hey @LuckyKoni - Thanks for the details. That is super helpful to investigate the issue. I just looked at test run and see I get result as '1'. Is that what you are expecting ?
@hariprasadms I just update my screenshots in my previous comments to make it more clear. So the expectation is to the UI shows "0" instead of 1.
To give you more context, the first record "isBooking" means there is a booking from 10 March 2024 to 12 March 2024. The second record is a listing record, listing the product from 1 March 2024 to 1 April 2024. The request period of the new booking in this example is from 8th March 2024 to 15 March 2024, which conflicts with the existing booking, thus the number of available product is expected to be 0. The Test function gives me the expected result 0, but the UI text using the function and app state gives me a 1.
Hi @LuckyKoni - Before delving into the intricacies of function code logic, I'd like to point out that during the function test run, the result displayed at my end is '1', which is consistent with what is shown on the UI. In light of this, it seems that the issue may be related to your logic implementation rather than a flaw in the function test run feature itself. Would you like to taking another thorough look at the logic behind function implementation?
To add more info, the result of function run and UI is consistent across real devices and debug run mode. Have a look at the logic please.
Hi @hariprasadms, the function test result is "0" please see my screenshot. Can you please share your screenshot and the data used for UI and Function testing. I don't believe there is anything wrong with the code logic - if it is wrong, i should get the same wrong result on UI and function test.
Hey @LuckyKoni - Thanks for the details. That is super helpful to investigate the issue. I just looked at test run and see I get result as '1'. Is that what you are expecting ?
![]()
Hi @hariprasadms In your test, can you please change the start date to 3/8/2024 instead of the current time, end date to 3/15/2024 instead of the current time. Then apply 3/8/2024 and 3/15/2024 as the start date and end date in App state for UI testing. This is when I got inconsistent result.
Hi @hariprasadms, did you manage to reproduce the issue?
Hi @LuckyKoni - Sorry for the delayed response. Are you still experiencing the issue, or have there been any changes with the latest FlutterFlow updates?
Hi @hariprasadms. I just test again and the issue persists. Please help.
I'm looking at it now. Have you made any changed to function recently?
@hariprasadms No recent change on this function. The project has the minimum setup with the collection, function, UI and app state to reproduce the issue.
With the above dates you mentioned, the function returns '0'. Is that correct as per latest date in the list ?
When I login to app I get below error. Is this affecting the function result ? or should I look into test app you setup earlier? the code below.
IT4slsmAsI1Nobhe+KryKPl7/SE4H202bY08scp/bxIgGIDzPOw+ZPWldhdoOemgTGxUI0SmmnsEw/DrjuPuUsI5OTmAbqZzws99FzrKIUC5QZOBDJC7OEFSGfhbJlDH1sKK2iNvLs1YLXdh7TuYeuetEzTAJLKzImdISq/LZO4=
The expected return is 0. Test function return 0. The UI return 1.
Can you please use this project report code instead. As your previous requested, this project has the minimum setup. IT4slsmAsI1Nobhe+KryKPl7/SE4H202bY08scp/bxIgGIDzPOw+ZPWldhdoOemgTGxUI0SmmlIEpcmKid/1LcIDHE2aG5hFzZFUTw6WQnORQZOBDJC7OEFSGfhbJlDH1sKK2iNvLs1YLXdh7TuYeuetEzTAJLKzImdISq/LZO4=
I checked the downloaded code and went through how the code runs. I noticed that the downloaded code and the test run mode show the same result when it's '1'. However, there's a different result for the same code in the function test, the result is 0.
I guess it can be issue with date stored in the app state. Can I ask you to store the date in string formate and convert it before use. Try this please.
@hariprasadms @takashiff Thanks for confirming the bug. Can you please let me know the ETA of this bug fix?
Hi @agreaves can you please advise on the bug fix update?
Hi team @agreaves @hariprasadms @takashiff any update on fixing this bug?
Hi @LuckyKoni - Its with dev team now. It will be worked on based on current priority. We will update the status once it is ready. Thanks
Has your issue been reported?
Current Behavior
I created a custom function to check if the requested booking period is conflicting with any existing bookings of the product. Here is the code that is really doing the checking
I use the same input data for Function test, the function works as expected. The output length is 0, since the requested booking conflicts with an existing booking.
But output length is displaying as 1 during the UI testing.
Expected Behavior
I expect the result of Function testing and UI testing are the same. In this example, since there is a conflict, both should show 0
Steps to Reproduce
Reproducible from Blank
Bug Report Code (Required)
ITFXl8rqw5ZOm8RE1ZDIaflaqDwwGUALa+dI0tZ+TQ0jF5D4OooiYsjSRElvTcyzaH5mGFal8WodpfzOkvPfF/cVNkydRrV8zpFQVhPPbECueJTSDKuSZXYkI+dVGUDFyLbUkx1vAPhpcXg47Ga1fufJcz6Cf9qOYwx5e6fDbOY=
Context
I created a custom function to check if the requested booking period is conflicting with any existing bookings of the product.
Visual documentation
Additional Info
No response
Environment