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

[fix] Date selection value is off #12

Open
wants to merge 6 commits into
base: fix_windows_integration_test
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/flutter_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ jobs:
fail_ci_if_error: true
verbose: true
os: ${{ matrix.os }}
attempt_limit: 5
attempt_limit: 20
attempt_delay: 10000

4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
if: github.event.pull_request.draft != true
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-2019]

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -135,5 +135,5 @@ jobs:
fail_ci_if_error: true
verbose: true
os: ${{ matrix.os }}
attempt_limit: 5
attempt_limit: 20
attempt_delay: 10000
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void main() {

// Make sure that the event is edited
tester.assertNumberOfEventsInCalendar(1, title: 'hello world');
tester.assertNumberofEventsOnSpecificDay(2, DateTime.now());
tester.assertNumberOfEventsOnSpecificDay(2, DateTime.now());

// Click on the event
await tester.openCalendarEvent(index: 1);
Expand All @@ -119,15 +119,15 @@ void main() {

// Check that there are 2 events
tester.assertNumberOfEventsInCalendar(2, title: 'hello world');
tester.assertNumberofEventsOnSpecificDay(3, DateTime.now());
tester.assertNumberOfEventsOnSpecificDay(3, DateTime.now());

// Delete an event
await tester.openCalendarEvent(index: 1);
await tester.tapRowDetailPageDeleteRowButton();

// Check that there is 1 event
tester.assertNumberOfEventsInCalendar(1, title: 'hello world');
tester.assertNumberofEventsOnSpecificDay(2, DateTime.now());
tester.assertNumberOfEventsOnSpecificDay(2, DateTime.now());
});

testWidgets('rescheduling events', (tester) async {
Expand All @@ -150,7 +150,7 @@ void main() {
// Make sure that the event has been rescheduled to the new date
final sameDayNextWeek = firstOfThisMonth.add(const Duration(days: 7));
tester.assertNumberOfEventsInCalendar(1);
tester.assertNumberofEventsOnSpecificDay(1, sameDayNextWeek);
tester.assertNumberOfEventsOnSpecificDay(1, sameDayNextWeek);

// Delete the event
await tester.openCalendarEvent(index: 0, date: sameDayNextWeek);
Expand All @@ -162,7 +162,7 @@ void main() {
await tester.dismissRowDetailPage();

// Make sure that the event is today
tester.assertNumberofEventsOnSpecificDay(1, today);
tester.assertNumberOfEventsOnSpecificDay(1, today);

// Click on the event
await tester.openCalendarEvent(index: 0);
Expand All @@ -183,7 +183,7 @@ void main() {

// Make sure that the event is edited
tester.assertNumberOfEventsInCalendar(1);
tester.assertNumberofEventsOnSpecificDay(1, newDate);
tester.assertNumberOfEventsOnSpecificDay(1, newDate);
});
});
}
95 changes: 95 additions & 0 deletions frontend/appflowy_flutter/integration_test/hotkeys_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'dart:io';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/workspace/application/settings/prelude.dart';
import 'package:appflowy/workspace/presentation/home/menu/menu.dart';
import 'package:appflowy/workspace/presentation/settings/settings_dialog.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'util/keyboard.dart';
import 'util/util.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('hotkeys test', () {
testWidgets('toggle theme mode', (tester) async {
await tester.initializeAppFlowy();

await tester.tapGoButton();
tester.expectToSeeHomePage();

await tester.openSettings();
await tester.openSettingsPage(SettingsPage.appearance);
await tester.pumpAndSettle();

tester.expectToSeeText(
LocaleKeys.settings_appearance_themeMode_system.tr(),
);

await tester.tapButton(
find.bySemanticsLabel(
LocaleKeys.settings_appearance_themeMode_system.tr(),
),
);

await tester.pumpAndSettle();

await tester.tapButton(
find.bySemanticsLabel(
LocaleKeys.settings_appearance_themeMode_dark.tr(),
),
);

await tester.pumpAndSettle(const Duration(seconds: 1));

await tester.tap(find.byType(SettingsDialog));

await tester.pumpAndSettle();

await FlowyTestKeyboard.simulateKeyDownEvent(
[
Platform.isMacOS
? LogicalKeyboardKey.meta
: LogicalKeyboardKey.control,
LogicalKeyboardKey.shift,
LogicalKeyboardKey.keyL,
],
tester: tester,
);

await tester.pumpAndSettle();

tester.expectToSeeText(
LocaleKeys.settings_appearance_themeMode_light.tr(),
);
});

testWidgets('show or hide home menu', (tester) async {
await tester.initializeAppFlowy();

await tester.tapGoButton();
tester.expectToSeeHomePage();

await tester.pumpAndSettle();

expect(find.byType(HomeMenu), findsOneWidget);

await FlowyTestKeyboard.simulateKeyDownEvent(
[
Platform.isMacOS
? LogicalKeyboardKey.meta
: LogicalKeyboardKey.control,
LogicalKeyboardKey.backslash,
],
tester: tester,
);

await tester.pumpAndSettle();

expect(find.byType(HomeMenu), findsNothing);
});
});
}
5 changes: 3 additions & 2 deletions frontend/appflowy_flutter/integration_test/util/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;

class FlowyTestContext {
FlowyTestContext({
Expand Down Expand Up @@ -60,7 +61,7 @@ extension AppFlowyTestBase on WidgetTester {
final dir = await getTemporaryDirectory();

// Use a random uuid to avoid conflict.
String path = '${dir.path}/appflowy_integration_test/${uuid()}';
String path = p.join(dir.path, 'appflowy_integration_test', uuid());
if (pathExtension != null && pathExtension.isNotEmpty) {
path = '$path/$pathExtension';
}
Expand All @@ -78,7 +79,7 @@ extension AppFlowyTestBase on WidgetTester {
Finder finder, {
int? pointer,
int buttons = kPrimaryButton,
bool warnIfMissed = true,
bool warnIfMissed = false,
int milliseconds = 500,
}) async {
await tap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ extension AppFlowyDatabaseTest on WidgetTester {
expect(findEvents, findsNWidgets(number));
}

void assertNumberofEventsOnSpecificDay(
void assertNumberOfEventsOnSpecificDay(
int number,
DateTime date, {
String? title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class _CellCalendarWidgetState extends State<_CellCalendarWidget> {
selectedDayPredicate: (day) => isSameDay(state.dateTime, day),
onDaySelected: (selectedDay, focusedDay) {
context.read<DateCellCalendarBloc>().add(
DateCellCalendarEvent.selectDay(selectedDay.toLocal().date),
DateCellCalendarEvent.selectDay(selectedDay.date),
);
},
onFormatChanged: (format) {
Expand Down
5 changes: 3 additions & 2 deletions frontend/appflowy_flutter/lib/startup/startup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ class FlowyRunner {
final launcher = getIt<AppLauncher>();
launcher.addTasks(
[
// handle platform errors.
const PlatformErrorCatcherTask(),
// this task should be first task, for handling platform errors.
// don't catch errors in test mode
if (!mode.isUnitTest) const PlatformErrorCatcherTask(),
// localization
const InitLocalizationTask(),
// init the app window
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ class AppearanceSettingsCubit extends Cubit<AppearanceSettingsState> {
emit(state.copyWith(themeMode: themeMode));
}

/// Toggle the theme mode
void toggleThemeMode() {
final currentThemeMode = state.themeMode;
setThemeMode(
currentThemeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light,
);
}

/// Update selected font in the user's settings and emit an updated state
/// with the font name.
void setFontFamily(String fontFamilyName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class MockApplicationDataStorage extends ApplicationDataStorage {
final path = initialPath;
if (path != null) {
initialPath = null;
await super.setPath(path);
return Future.value(path);
}
return super.getPath();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:appflowy/workspace/application/appearance.dart';
import 'package:appflowy/workspace/application/home/home_setting_bloc.dart';
import 'package:flutter/material.dart';
import 'package:hotkey_manager/hotkey_manager.dart';
Expand All @@ -25,6 +26,21 @@ class HomeHotKeys extends StatelessWidget {
.add(const HomeSettingEvent.collapseMenu());
},
);

final HotKey hotKeyForToggleThemeMode = HotKey(
KeyCode.keyL,
modifiers: [
Platform.isMacOS ? KeyModifier.meta : KeyModifier.control,
KeyModifier.shift,
],
scope: HotKeyScope.inapp,
);
hotKeyManager.register(
hotKeyForToggleThemeMode,
keyDownHandler: (_) {
context.read<AppearanceSettingsCubit>().toggleThemeMode();
},
);
return child;
}
}
Loading