mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 08:15:41 +00:00
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:
@@ -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]);
|
||||
|
||||
|
||||
@@ -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([]));
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user