From c40b17bd4cdb943b299e3cb17f0cbb5ce8e736e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Thu, 24 Nov 2022 11:40:23 +0100 Subject: [PATCH] fix(snjs): factory timeout to propagate subscription purchase --- packages/snjs/mocha/files.test.js | 11 +++-------- packages/snjs/mocha/settings.test.js | 19 +++++++++---------- packages/snjs/mocha/subscriptions.test.js | 2 +- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/packages/snjs/mocha/files.test.js b/packages/snjs/mocha/files.test.js index e8a8fdceb..b55714090 100644 --- a/packages/snjs/mocha/files.test.js +++ b/packages/snjs/mocha/files.test.js @@ -52,7 +52,7 @@ describe('files', function () { billingFrequency: 12, payAmount: 59.00 }) - await Factory.sleep(1) + await Factory.sleep(2) } } @@ -65,6 +65,7 @@ describe('files', function () { await setup({ fakeCrypto: true, subscription: true }) const remoteIdentifier = Utils.generateUuid() const token = await application.apiService.createFileValetToken(remoteIdentifier, 'write') + console.log(token) expect(token.length).to.be.above(0) }) @@ -97,7 +98,7 @@ describe('files', function () { payAmount: 59.00 }) - await Factory.sleep(1) + await Factory.sleep(2) const remoteIdentifier = Utils.generateUuid() const tokenOrError = await application.apiService.createFileValetToken(remoteIdentifier, 'write') @@ -163,10 +164,4 @@ describe('files', function () { expect(downloadError).to.be.ok }) - - it.skip('should cancel file download', async function () { - await setup({ fakeCrypto: false, subscription: true }) - - // ... - }) }) diff --git a/packages/snjs/mocha/settings.test.js b/packages/snjs/mocha/settings.test.js index 9d58c5b73..5447ab265 100644 --- a/packages/snjs/mocha/settings.test.js +++ b/packages/snjs/mocha/settings.test.js @@ -5,7 +5,7 @@ chai.use(chaiAsPromised) const expect = chai.expect describe('settings service', function () { - this.timeout(Factory.TwentySecondTimeout) + this.timeout(Factory.ThirtySecondTimeout) const validSetting = SettingName.GoogleDriveBackupFrequency const fakePayload = 'Im so meta even this acronym' @@ -13,21 +13,20 @@ describe('settings service', function () { let application let context - let user beforeEach(async function () { + localStorage.clear() context = await Factory.createAppContextWithFakeCrypto() await context.launch() application = context.application - const registerResponse = await Factory.registerUserToApplication({ + await Factory.registerUserToApplication({ application: context.application, email: context.email, password: context.password, }) - user = registerResponse.user }) const reInitializeApplicationWithRealCrypto = async () => { @@ -39,16 +38,16 @@ describe('settings service', function () { application = context.application - const registerResponse = await Factory.registerUserToApplication({ + await Factory.registerUserToApplication({ application: context.application, email: context.email, password: context.password, }) - user = registerResponse.user } afterEach(async function () { await Factory.safeDeinit(application) + localStorage.clear() }) it('creates and reads a setting', async function () { @@ -133,7 +132,7 @@ describe('settings service', function () { payAmount: 59.00 }) - await Factory.sleep(1) + await Factory.sleep(2) const setting = await application.settings.getSubscriptionSetting('FILE_UPLOAD_BYTES_LIMIT') expect(setting).to.be.a('string') @@ -157,7 +156,7 @@ describe('settings service', function () { billingFrequency: 12, payAmount: 59.00 }) - await Factory.sleep(1) + await Factory.sleep(2) const response = await fetch('/packages/snjs/mocha/assets/small_file.md') const buffer = new Uint8Array(await response.arrayBuffer()) @@ -183,7 +182,7 @@ describe('settings service', function () { billingFrequency: 12, payAmount: 59.00 }) - await Factory.sleep(1) + await Factory.sleep(2) await Factory.publishMockedEvent('SUBSCRIPTION_PURCHASED', { userEmail: context.email, @@ -200,7 +199,7 @@ describe('settings service', function () { billingFrequency: 12, payAmount: 59.00 }) - await Factory.sleep(1) + await Factory.sleep(2) const limitSettingAfter = await application.settings.getSubscriptionSetting('FILE_UPLOAD_BYTES_LIMIT') expect(limitSettingAfter).to.equal(limitSettingBefore) diff --git a/packages/snjs/mocha/subscriptions.test.js b/packages/snjs/mocha/subscriptions.test.js index 0adb08b99..888ec4761 100644 --- a/packages/snjs/mocha/subscriptions.test.js +++ b/packages/snjs/mocha/subscriptions.test.js @@ -45,7 +45,7 @@ describe('subscriptions', function () { billingFrequency: 12, payAmount: 59.00 }) - await Factory.sleep(0.25) + await Factory.sleep(2) }) it('should invite a user by email to a shared subscription', async () => {