fix(snjs): factory timeout to propagate subscription purchase

This commit is contained in:
Karol Sójko
2022-11-24 11:40:23 +01:00
parent 858fa6835c
commit c40b17bd4c
3 changed files with 13 additions and 19 deletions

View File

@@ -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)