scenarioAccessRemoval function
- FakeServer server,
- WorldSeed w,
- ScenarioClient client
04 16.4: access to a channel is removed while the client is connected: its content goes, the view closes with a notice, and later events of the channel never arrive.
Implementation
Future<void> scenarioAccessRemoval(
FakeServer server,
WorldSeed w,
ScenarioClient client,
) async {
await client.start();
await client.focusThread(w.printer);
w.post(w.sam, w.printer, 'The printer is out of paper');
await waitFor(
'the printer message',
() async => (await client.messages(w.printer)).isNotEmpty,
);
final number = server.gateway.connections.last.number;
server.world.setAccess(w.alex.id, w.support, null);
final removedAt = server.gateway.sentOn(number).length;
await waitFor(
'the removal notice',
() => client.notices.contains('removed:channel:${w.support}'),
);
await waitFor(
'the channel is gone',
() async => !await client.holdsChannel(w.support),
);
_check(
(await client.messages(w.printer)).isEmpty,
'the channel content was deleted',
);
_check(
!server.gateway.connections.last.focus.contains(w.printer),
'the server ended the focus of the removed channel',
);
w.post(w.sam, w.printer, 'Fixed the printer');
final marker = w.post(w.sam, w.releaseNotes, 'Marker after the removal');
await waitFor(
'the marker',
() async =>
[for (final m in await client.messages(w.releaseNotes)) m.id]
.contains(marker['id']),
);
final later = server.gateway.sentOn(number).skip(removedAt);
_check(
later.every(
(f) =>
f.op != 'dispatch' ||
(f.data['scope'] as Map?)?['channel_id'] != w.support,
),
'no later event of the removed channel arrived',
);
_check(
(await client.messages(w.printer)).isEmpty,
'nothing of the channel came back',
);
_contract(server);
}