purchasesSessionAppTest function
The test of the purchases of the users of the session that the CLI keeps
in its app_tests/purchases_session, for the apps with the purchases
role and the auth role, whichever modules provide them, that among
accepts, or all of them, in each mode of the auth role: a user without
an account who buys a plan keeps the premium access after a sign-up;
after a sign-out the next user of the device has none of the purchases
of the user who signed out, whose account has them again after a
sign-in; the user without an account keeps what it bought at the next
start; and a sign-in to an account that exists already leaves the
purchases with the user of the device, while the next user of the device
after that account signs out has none of them.
It is a test of the purchases role, whose template makes appPurchases
follow the session of the app, and whose contract says whose purchases
they are. It reads the mode of the app from authMode of the app, so
the matrix fills in nothing. It uses the helpers of the test of the
purchases role (purchasesRoleAppTest), which every such app among
those that among accepts has. It has no probe for the start check:
nobody can sign in on a device.
Implementation
Future<MatrixAppTest> purchasesSessionAppTest({
bool Function(MatrixApp app)? among,
}) async =>
MatrixAppTest(
'${await appTestsDirectoryOf('smf_flutter_cli')}/purchases_session',
appliesTo: (app) =>
app.hook!.presentRoles.containsAll(const [purchasesRole, authRole]) &&
(among?.call(app) ?? true),
roles: {purchasesRole},
);