test: give the wipe test a subject and count waiting changes per account

Both follow the review's fixes: a policy without a subject no longer decides,
and the fallback count of changes is per account.
This commit is contained in:
Linus Rath
2026-11-03 12:40:28 +01:00
parent 8d802e4601
commit 1c6720c3a8
3 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ export function useKeepFileOffline(client: IJMAPClient | null | undefined) {
const t = useTranslations('offlineStorage');
const account = useAuthStore((s) => s.activeAccountId);
const { active, pinned, pin, unpin } = useKeptFiles(account);
const own = client?.getAccountId() ?? '';
const own = client?.getAccountId?.() ?? '';
const keptOffline = useMemo(() => new Set(pinned.map((file) => (file.jmap === own ? file.id : `${file.jmap}:${file.id}`))), [pinned, own]);
+1
View File
@@ -426,6 +426,7 @@ describe('wiping offline data', () => {
useAuthStore.setState({ client: client as never, activeAccountId: 'acc' });
writeEnabled(['acc']);
stop = startOfflineMode();
usePolicyStore.getState().setPolicySubject({ email: 'alice@example.org', groups: [] });
usePolicyStore.setState({ policy: { ...usePolicyStore.getState().policy, organisation: { ...DEFAULT_ORGANISATION_POLICY, devices: { ...DEFAULT_ORGANISATION_POLICY.devices, noOffline: true } } } });
enforcePolicy();
await vi.waitFor(async () => expect(useOfflineStore.getState().enabled).toEqual([]));
+1 -1
View File
@@ -368,7 +368,7 @@ describe('what a sign-out would delete', () => {
});
it('answers with the last known count when the store hangs', async () => {
useOfflineStore.setState({ outbox: [{ id: 1, account: 'acc', createdAt: 1, subject: 'A', to: [], status: 'waiting' }] as never, pendingChanges: 2 });
useOfflineStore.setState({ outbox: [{ id: 1, account: 'acc', createdAt: 1, subject: 'A', to: [], status: 'waiting' }] as never, changesBy: { acc: 2 } });
const hung: Array<(error: Error) => void> = [];
vi.spyOn(store, 'area').mockImplementation(() => new Promise((_resolve, reject) => { hung.push(reject); }));
expect(await unsentCount('acc', 10)).toEqual({ messages: 1, changes: 2 });