fc7dbb0ac0
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat tool notify, auto-switch and schedule notices), the chat push outbox (its table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*. The app_notifications stream, subscribe/clear and kinds are unchanged. Notification settings keep run_finished/chat_needs_you/chat_reply_finished; ntfy_enabled is accepted and ignored and its stored row is never read. Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to the Pipelines apps — use the stage notify hook". The notify hook remains. Installer: no ntfy build, accounts, config or supervisor child; manifest gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log, with a note in logs/install.log); uninstall cleans leftovers. App: ntfy settings section replaced by "Notification events"; texts updated. Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli, author skill references updated; security review M1 marked resolved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
266 lines
7.9 KiB
Dart
266 lines
7.9 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/settings/settings_search_page.dart';
|
|
import 'package:pipelines_app/features/settings/settings_section.dart';
|
|
import 'package:pipelines_app/features/settings/settings_server_load.dart';
|
|
import 'package:pipelines_app/features/settings/settings_server_view.dart';
|
|
|
|
/// Fills the page so a section placed after it starts far below the viewport.
|
|
List<SettingsSection> _filler(int count) => [
|
|
for (var i = 0; i < count; i++)
|
|
SettingsSection(
|
|
id: 'filler-$i',
|
|
title: 'Filler $i',
|
|
builder: (_) => const SizedBox(height: 400, child: Text('filler body')),
|
|
),
|
|
];
|
|
|
|
Future<void> _pump(
|
|
WidgetTester tester,
|
|
List<SettingsSection> sections, {
|
|
Size size = const Size(800, 600),
|
|
}) async {
|
|
await tester.binding.setSurfaceSize(size);
|
|
addTearDown(() => tester.binding.setSurfaceSize(null));
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(body: SettingsSearchPage(sections: sections)),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('local settings render while a server section has not answered', (
|
|
tester,
|
|
) async {
|
|
var fetches = 0;
|
|
final reply = Completer<int>();
|
|
final load = ServerLoad<int>(() {
|
|
fetches++;
|
|
return reply.future;
|
|
});
|
|
addTearDown(load.dispose);
|
|
await _pump(tester, [
|
|
..._filler(6),
|
|
SettingsSection(
|
|
id: 'server',
|
|
title: 'Notification events',
|
|
lazy: true,
|
|
builder: (_) => ServerSettingsView<int>(
|
|
load: load,
|
|
builder: (_, value) => Text('Server $value'),
|
|
),
|
|
),
|
|
]);
|
|
|
|
// The local sections are built and the server section is only a skeleton:
|
|
// no request runs until the list reaches it.
|
|
expect(find.text('filler body'), findsWidgets);
|
|
expect(find.text('Notification events'), findsOneWidget);
|
|
expect(fetches, 0);
|
|
expect(tester.takeException(), isNull);
|
|
|
|
await tester.ensureVisible(find.text('Notification events'));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(fetches, 1);
|
|
// The reply is still pending, and the page keeps working.
|
|
expect(find.bySemanticsLabel('Loading'), findsOneWidget);
|
|
expect(find.text('filler body'), findsWidgets);
|
|
reply.complete(3);
|
|
await tester.pump();
|
|
expect(find.text('Server 3'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('search filters sections by title and keywords', (tester) async {
|
|
await _pump(tester, [
|
|
SettingsSection(
|
|
id: 'animations',
|
|
title: 'Animations',
|
|
keywords: 'motion speed',
|
|
builder: _titled('Animations'),
|
|
),
|
|
SettingsSection(
|
|
id: 'terminal',
|
|
title: 'Terminal',
|
|
keywords: 'layout split',
|
|
builder: _titled('Terminal'),
|
|
),
|
|
]);
|
|
expect(find.text('Animations'), findsOneWidget);
|
|
expect(find.text('Terminal'), findsOneWidget);
|
|
|
|
await tester.enterText(
|
|
find.byKey(const ValueKey('settings.search')),
|
|
'motion',
|
|
);
|
|
await tester.pump();
|
|
expect(find.text('Animations'), findsOneWidget);
|
|
expect(find.text('Terminal'), findsNothing);
|
|
|
|
// Every word must match: "motion layout" matches neither section.
|
|
await tester.enterText(
|
|
find.byKey(const ValueKey('settings.search')),
|
|
'motion layout',
|
|
);
|
|
await tester.pump();
|
|
expect(find.text('Animations'), findsNothing);
|
|
expect(find.text('Terminal'), findsNothing);
|
|
expect(find.textContaining('No settings match'), findsOneWidget);
|
|
|
|
await tester.tap(find.byTooltip('Clear search'));
|
|
await tester.pump();
|
|
expect(find.text('Animations'), findsOneWidget);
|
|
expect(find.text('Terminal'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('a search that matches a server section loads it at once', (
|
|
tester,
|
|
) async {
|
|
var fetches = 0;
|
|
final load = ServerLoad<int>(() async {
|
|
fetches++;
|
|
return 9;
|
|
});
|
|
addTearDown(load.dispose);
|
|
await _pump(tester, [
|
|
..._filler(6),
|
|
SettingsSection(
|
|
id: 'server',
|
|
title: 'Notification events',
|
|
keywords: 'push devices',
|
|
lazy: true,
|
|
builder: (_) => ServerSettingsView<int>(
|
|
load: load,
|
|
builder: (_, value) => Text('Server $value'),
|
|
),
|
|
),
|
|
]);
|
|
expect(fetches, 0);
|
|
|
|
await tester.enterText(
|
|
find.byKey(const ValueKey('settings.search')),
|
|
'devices',
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(fetches, 1);
|
|
expect(find.text('Server 9'), findsOneWidget);
|
|
expect(find.text('filler body'), findsNothing);
|
|
});
|
|
|
|
testWidgets(
|
|
'a failing server section shows its own Retry; others are unaffected',
|
|
(tester) async {
|
|
var attempts = 0;
|
|
final load = ServerLoad<String>(() async {
|
|
attempts++;
|
|
if (attempts == 1) throw StateError('server unreachable');
|
|
return 'Stored';
|
|
});
|
|
addTearDown(load.dispose);
|
|
await _pump(tester, [
|
|
SettingsSection(
|
|
id: 'local',
|
|
title: 'Animations',
|
|
builder: (_) =>
|
|
const Column(children: [Text('Animations'), Text('Local value')]),
|
|
),
|
|
SettingsSection(
|
|
id: 'server',
|
|
title: 'Sign-in security',
|
|
lazy: true,
|
|
builder: (_) => ServerSettingsView<String>(
|
|
load: load,
|
|
retryKey: const Key('server-retry'),
|
|
builder: (_, value) => Text('Security $value'),
|
|
),
|
|
),
|
|
]);
|
|
await tester.pump();
|
|
|
|
expect(find.textContaining('server unreachable'), findsOneWidget);
|
|
expect(find.byKey(const Key('server-retry')), findsOneWidget);
|
|
expect(find.text('Local value'), findsOneWidget);
|
|
expect(find.text('Animations'), findsOneWidget);
|
|
|
|
await tester.tap(find.byKey(const Key('server-retry')));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(attempts, 2);
|
|
expect(find.text('Security Stored'), findsOneWidget);
|
|
expect(find.byKey(const Key('server-retry')), findsNothing);
|
|
expect(find.text('Local value'), findsOneWidget);
|
|
},
|
|
);
|
|
|
|
testWidgets('wide layouts list every visible section in the jump index', (
|
|
tester,
|
|
) async {
|
|
final sections = [
|
|
SettingsSection(
|
|
id: 'animations',
|
|
title: 'Animations',
|
|
builder: _titled('Animations'),
|
|
),
|
|
SettingsSection(
|
|
id: 'terminal',
|
|
title: 'Terminal',
|
|
builder: _titled('Terminal'),
|
|
),
|
|
];
|
|
await _pump(tester, sections, size: const Size(1200, 800));
|
|
expect(
|
|
find.byKey(const ValueKey('settings.index.animations')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.byKey(const ValueKey('settings.index.terminal')),
|
|
findsOneWidget,
|
|
);
|
|
|
|
await tester.tap(find.byKey(const ValueKey('settings.index.terminal')));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('a short wide window scrolls the jump index to its last link', (
|
|
tester,
|
|
) async {
|
|
// More links than a 600 px tall index fits: it must scroll, not overflow.
|
|
await _pump(tester, _filler(30), size: const Size(1200, 600));
|
|
expect(tester.takeException(), isNull);
|
|
|
|
final last = find.byKey(const ValueKey('settings.index.filler-29'));
|
|
await tester.ensureVisible(last);
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(last);
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Filler 29'), findsWidgets);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('a narrow layout has no jump index', (tester) async {
|
|
await _pump(tester, [
|
|
SettingsSection(
|
|
id: 'animations',
|
|
title: 'Animations',
|
|
builder: _titled('Animations'),
|
|
),
|
|
], size: const Size(390, 844));
|
|
expect(
|
|
find.byKey(const ValueKey('settings.index.animations')),
|
|
findsNothing,
|
|
);
|
|
});
|
|
}
|
|
|
|
WidgetBuilder _titled(String title) =>
|
|
(_) => Text(title);
|