You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to create a fake group to have some data to test the app, and found some buggy behaviour with default rules.
ScreenRecording_12-31-2024.10-20-56_1.MP4
(I didn't commit this because I didn't know where to place it.. I ran it as a test file, but if committed it would run for all tests... and I couldn't make it work as a standalone Dart file, I believe because it imports some Flutter stuff somewhere...)
import'dart:math';
import'package:faker/faker.dart';
import'package:parousia/models/models.dart';
import'package:parousia/repositories/repositories.dart';
import'package:parousia/util/util.dart';
import'package:rrule/rrule.dart';
import'package:supabase/supabase.dart';
finalSupabaseConfig config =SupabaseConfig.fromPath('supabase/config/localhost.json');
const authOptions =AuthClientOptions(authFlowType:AuthFlowType.implicit);
SupabaseClientsupabaseAnonClient() =>SupabaseClient(config.apiUrl, config.anonKey, authOptions: authOptions);
voidmain() async {
final supabase =supabaseAnonClient();
await supabase.auth
.signUp(password:'password', email: faker.internet.email());
final groupsRepository =GroupsRepository(supabase: supabase);
final group =await groupsRepository.createGroup(
Fake.group(),
);
final schedulesRepository =SchedulesRepository(supabase: supabase);
final schedules =awaitFuture.wait([
for (var i =0; i <5; i++)
schedulesRepository.createSchedule(Fake.schedule(groupId: group.id))
]);
final membersRepository =MembersRepository(supabase: supabase);
final members =awaitFuture.wait([
for (var i =0; i <15; i++)
membersRepository.addMemberToGroup(group.id,
displayName: faker.person.name())
]);
final defaultRulesRepository =DefaultRulesRepository(supabase: supabase);
ReplyOptions?randomReply() {
if (Random().nextBool()) returnnull;
final replies =ReplyOptions.values;
return replies[Random().nextInt(replies.length)];
}
RecurrenceRulerandomRecurrenceRule() {
final n =Random().nextInt(5);
switch (n) {
case0:returnCommonRecurrenceRules.daily;
case1:returnCommonRecurrenceRules.weekly;
case2:returnCommonRecurrenceRules.monthly;
case3:returnCommonRecurrenceRules.weekends;
case4:returnCommonRecurrenceRules.weekdays;
default:returnCommonRecurrenceRules.daily;
}
}
Future<DefaultRule?> createOptionalRandomDefaultRule(
Schedule schedule, Member member) {
final reply =randomReply();
if (reply ==null) returnFuture.value(null);
final rule =randomRecurrenceRule();
return defaultRulesRepository.createDefaultRule(DefaultRule(
memberId: member.id,
scheduleId: schedule.id,
selectedOption: reply,
recurrenceRule: rule));
}
final defaultRules =awaitFuture.wait([
for (final schedule in schedules)
for (final member in members)
createOptionalRandomDefaultRule(schedule, member)
]);
final invitesRepository =InvitesRepository(supabase: supabase);
final invites =awaitFuture.wait([
for (final member in members)
invitesRepository.inviteWithGeneratedCode(member.id)
]);
print('Use invite code ${invites.first.value} to join the group');
}
The text was updated successfully, but these errors were encountered:
I tried to create a fake group to have some data to test the app, and found some buggy behaviour with default rules.
ScreenRecording_12-31-2024.10-20-56_1.MP4
(I didn't commit this because I didn't know where to place it.. I ran it as a test file, but if committed it would run for all tests... and I couldn't make it work as a standalone Dart file, I believe because it imports some Flutter stuff somewhere...)
The text was updated successfully, but these errors were encountered: