1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-06 09:19:22 +02:00

Server: Disable beta account once expired

This commit is contained in:
Laurent Cozic
2021-08-02 17:56:25 +01:00
parent 89d4d5e642
commit 785248b27f
4 changed files with 57 additions and 7 deletions

View File

@@ -138,4 +138,26 @@ describe('UserModel', function() {
stripeConfig().enabled = false;
});
test('should disable beta account once expired', async function() {
stripeConfig().enabled = true;
const { user: user1 } = await createUserAndSession(1, false, { email: 'toto@example.com' });
const range = betaUserDateRange();
await models().user().save({
id: user1.id,
created_time: range[0],
account_type: AccountType.Pro,
});
Date.now = jest.fn(() => range[0] + 8640000 * 1000); // 100 days later
await models().user().handleBetaUserEmails();
expect((await models().email().all()).length).toBe(4);
const email = (await models().email().all()).pop();
expect(email.subject.indexOf('beta account is expired') > 0).toBe(true);
const reloadedUser = await models().user().load(user1.id);
expect(reloadedUser.can_upload).toBe(0);
});
});