Skip to content

Commit

Permalink
Merge pull request #2113 from nextcloud/feat/neon_framework/test-acce…
Browse files Browse the repository at this point in the history
…ssibility-guidelines
  • Loading branch information
provokateurin authored Jun 3, 2024
2 parents 7b99fb0 + de05c19 commit 45823d0
Show file tree
Hide file tree
Showing 50 changed files with 421 additions and 256 deletions.
3 changes: 2 additions & 1 deletion packages/neon/neon_dashboard/lib/l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
}
},
"locationSet": "Set location for weather",
"address": "Address"
"address": "Address",
"openWidget": "Open widget"
}
6 changes: 6 additions & 0 deletions packages/neon/neon_dashboard/lib/l10n/localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ abstract class DashboardLocalizations {
/// In en, this message translates to:
/// **'Address'**
String get address;

/// No description provided for @openWidget.
///
/// In en, this message translates to:
/// **'Open widget'**
String get openWidget;
}

class _DashboardLocalizationsDelegate extends LocalizationsDelegate<DashboardLocalizations> {
Expand Down
3 changes: 3 additions & 0 deletions packages/neon/neon_dashboard/lib/l10n/localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ class DashboardLocalizationsEn extends DashboardLocalizations {

@override
String get address => 'Address';

@override
String get openWidget => 'Open widget';
}
2 changes: 1 addition & 1 deletion packages/neon/neon_dashboard/lib/src/pages/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class DashboardMainPage extends StatelessWidget {
if (widget.buttons != null) {
for (final button in widget.buttons!) {
yield SizedBox(
height: 40,
height: 56,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: DashboardWidgetButton(
Expand Down
30 changes: 20 additions & 10 deletions packages/neon/neon_dashboard/lib/src/widgets/widget.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:neon_dashboard/l10n/localizations.dart';
import 'package:nextcloud/dashboard.dart' as dashboard;

/// Displays a single dashboard widget and its items.
Expand All @@ -19,17 +20,26 @@ class DashboardWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Card(
child: InkWell(
onTap: widget.widgetUrl != null && widget.widgetUrl!.isNotEmpty ? () => context.go(widget.widgetUrl!) : null,
borderRadius: const BorderRadius.all(Radius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
children: children,
),
),
Widget child = Padding(
padding: const EdgeInsets.all(8),
child: Column(
children: children,
),
);

if (widget.widgetUrl != null && widget.widgetUrl!.isNotEmpty) {
child = Tooltip(
message: DashboardLocalizations.of(context).openWidget,
child: InkWell(
onTap: () => context.go(widget.widgetUrl!),
borderRadius: const BorderRadius.all(Radius.circular(12)),
child: child,
),
);
}

return Card(
child: child,
);
}
}
Binary file modified packages/neon/neon_dashboard/test/goldens/widget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/neon/neon_dashboard/test/goldens/widget_not_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/neon/neon_dashboard/test/goldens/widget_with_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/neon/neon_dashboard/test/goldens/widget_without_items.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:neon_framework/testing.dart';

void main() {
testWidgets('Set weather location dialog', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
const TestApp(
localizationsDelegates: DashboardLocalizations.localizationsDelegates,
supportedLocales: DashboardLocalizations.supportedLocales,
Expand Down
38 changes: 19 additions & 19 deletions packages/neon/neon_dashboard/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main() {
testWidgets('Everything filled', (tester) async {
final router = MockGoRouter();

await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetItem(
Expand Down Expand Up @@ -99,7 +99,7 @@ void main() {
});

testWidgets('Not round', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetItem(
Expand All @@ -122,7 +122,7 @@ void main() {
});

testWidgets('Without link', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetItem(
Expand All @@ -143,7 +143,7 @@ void main() {
});

testWidgets('Without overlayIconUrl', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetItem(
Expand All @@ -157,7 +157,7 @@ void main() {
});

testWidgets('Without iconUrl', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetItem(
Expand All @@ -183,7 +183,7 @@ void main() {
testWidgets('Opens link', (tester) async {
final router = MockGoRouter();

await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetButton(
Expand All @@ -198,7 +198,7 @@ void main() {
});

testWidgets('New', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetButton(
Expand All @@ -214,7 +214,7 @@ void main() {
});

testWidgets('More', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetButton(
Expand All @@ -230,7 +230,7 @@ void main() {
});

testWidgets('Setup', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetButton(
Expand All @@ -246,7 +246,7 @@ void main() {
});

testWidgets('Invalid', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
DashboardWidgetButton(
Expand Down Expand Up @@ -299,7 +299,7 @@ void main() {
);

testWidgets('Everything filled', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand Down Expand Up @@ -345,7 +345,7 @@ void main() {

testWidgets('Without widgetUrl', (tester) async {
final widgetEmptyURL = widget.rebuild((b) => b.widgetUrl = '');
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand Down Expand Up @@ -373,7 +373,7 @@ void main() {

testWidgets('Not round', (tester) async {
final widgetNotRound = widget.rebuild((b) => b.itemIconsRound = false);
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand Down Expand Up @@ -402,7 +402,7 @@ void main() {
});

testWidgets('With halfEmptyContentMessage', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand All @@ -425,7 +425,7 @@ void main() {
});

testWidgets('With emptyContentMessage', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand All @@ -448,7 +448,7 @@ void main() {
});

testWidgets('With emptyContentMessage and halfEmptyContentMessage', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand Down Expand Up @@ -479,7 +479,7 @@ void main() {
});

testWidgets('Without items', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand All @@ -503,7 +503,7 @@ void main() {

testWidgets('Without buttons', (tester) async {
final widgetWithoutButtons = widget.rebuild((b) => b.buttons.clear());
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand All @@ -528,7 +528,7 @@ void main() {
final widgetWithMultipleButtons = widget.rebuild(
(b) => b.buttons.replace([button, button]),
);
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
wrapWidget(
accountsBloc,
Builder(
Expand Down
6 changes: 3 additions & 3 deletions packages/neon/neon_notifications/test/action_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {
when(() => action.label).thenReturn('label');
when(() => action.primary).thenReturn(true);

await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
TestApp(
child: NotificationsAction(
action: action,
Expand All @@ -27,7 +27,7 @@ void main() {
when(() => action.label).thenReturn('label');
when(() => action.primary).thenReturn(false);

await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
TestApp(
child: NotificationsAction(
action: action,
Expand All @@ -46,7 +46,7 @@ void main() {
when(() => action.primary).thenReturn(true);
when(() => action.link).thenReturn('/link');

await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
TestApp(
router: router,
child: NotificationsAction(
Expand Down
6 changes: 3 additions & 3 deletions packages/neon/neon_notifications/test/main_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void main() {
final controller = StreamController<Object>();
when(() => bloc.errors).thenAnswer((_) => controller.stream);

await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
TestApp(
localizationsDelegates: NotificationsLocalizations.localizationsDelegates,
supportedLocales: NotificationsLocalizations.supportedLocales,
Expand All @@ -69,7 +69,7 @@ void main() {
});

testWidgets('Without notifications', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
TestApp(
localizationsDelegates: NotificationsLocalizations.localizationsDelegates,
supportedLocales: NotificationsLocalizations.supportedLocales,
Expand Down Expand Up @@ -113,7 +113,7 @@ void main() {
),
);

await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
TestApp(
localizationsDelegates: NotificationsLocalizations.localizationsDelegates,
supportedLocales: NotificationsLocalizations.supportedLocales,
Expand Down
4 changes: 2 additions & 2 deletions packages/neon/neon_notifications/test/notification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void main() {
});

testWidgets('Without matching app', (tester) async {
await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
TestApp(
localizationsDelegates: NotificationsLocalizations.localizationsDelegates,
supportedLocales: NotificationsLocalizations.supportedLocales,
Expand Down Expand Up @@ -100,7 +100,7 @@ void main() {
when(() => app.id).thenReturn('app');
when(() => app.buildIcon(size: any(named: 'size'))).thenReturn(const SizedBox());

await tester.pumpWidget(
await tester.pumpWidgetWithAccessibility(
TestApp(
localizationsDelegates: NotificationsLocalizations.localizationsDelegates,
supportedLocales: NotificationsLocalizations.supportedLocales,
Expand Down
7 changes: 6 additions & 1 deletion packages/neon/neon_talk/lib/l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@
"type": {}
}
},
"roomSendMessage": "Send a message..."
"roomSendMessage": "Send a message...",
"roomMessageAddEmoji": "Add emoji to message",
"roomMessageSend": "Send message",
"reactionsAddNew": "Add a new reaction",
"reactionsLoading": "Loading reactions",
"roomsCreateNew": "Create new room"
}
30 changes: 30 additions & 0 deletions packages/neon/neon_talk/lib/l10n/localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,36 @@ abstract class TalkLocalizations {
/// In en, this message translates to:
/// **'Send a message...'**
String get roomSendMessage;

/// No description provided for @roomMessageAddEmoji.
///
/// In en, this message translates to:
/// **'Add emoji to message'**
String get roomMessageAddEmoji;

/// No description provided for @roomMessageSend.
///
/// In en, this message translates to:
/// **'Send message'**
String get roomMessageSend;

/// No description provided for @reactionsAddNew.
///
/// In en, this message translates to:
/// **'Add a new reaction'**
String get reactionsAddNew;

/// No description provided for @reactionsLoading.
///
/// In en, this message translates to:
/// **'Loading reactions'**
String get reactionsLoading;

/// No description provided for @roomsCreateNew.
///
/// In en, this message translates to:
/// **'Create new room'**
String get roomsCreateNew;
}

class _TalkLocalizationsDelegate extends LocalizationsDelegate<TalkLocalizations> {
Expand Down
Loading

0 comments on commit 45823d0

Please sign in to comment.