fix(snjs): subscription events in tests
This commit is contained in:
@@ -38,19 +38,21 @@ export class SNWebSocketsService extends AbstractService<WebSocketsServiceEvent,
|
||||
}
|
||||
|
||||
async startWebSocketConnection(): Promise<void> {
|
||||
if (!this.webSocketUrl) {
|
||||
return
|
||||
}
|
||||
|
||||
const webSocketConectionToken = await this.createWebSocketConnectionToken()
|
||||
if (webSocketConectionToken === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.webSocketUrl) {
|
||||
try {
|
||||
this.webSocket = new WebSocket(`${this.webSocketUrl}?authToken=${webSocketConectionToken}`)
|
||||
this.webSocket.onmessage = this.onWebSocketMessage.bind(this)
|
||||
this.webSocket.onclose = this.onWebSocketClose.bind(this)
|
||||
} catch (e) {
|
||||
console.error('Error starting WebSocket connection', e)
|
||||
}
|
||||
try {
|
||||
this.webSocket = new WebSocket(`${this.webSocketUrl}?authToken=${webSocketConectionToken}`)
|
||||
this.webSocket.onmessage = this.onWebSocketMessage.bind(this)
|
||||
this.webSocket.onclose = this.onWebSocketClose.bind(this)
|
||||
} catch (e) {
|
||||
console.error('Error starting WebSocket connection', e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,13 @@ describe('files', function () {
|
||||
subscriptionExpiresAt: (new Date().getTime() + 3_600_000) * 1_000,
|
||||
timestamp: Date.now(),
|
||||
offline: false,
|
||||
discountCode: null,
|
||||
limitedDiscountPurchased: false,
|
||||
newSubscriber: true,
|
||||
totalActiveSubscriptionsCount: 1,
|
||||
userRegisteredAt: 1,
|
||||
billingFrequency: 12,
|
||||
payAmount: 59.00
|
||||
})
|
||||
await Factory.sleep(0.25)
|
||||
}
|
||||
@@ -81,6 +88,13 @@ describe('files', function () {
|
||||
subscriptionExpiresAt: (new Date().getTime() - 3_600_000) * 1_000,
|
||||
timestamp: Date.now(),
|
||||
offline: false,
|
||||
discountCode: null,
|
||||
limitedDiscountPurchased: false,
|
||||
newSubscriber: true,
|
||||
totalActiveSubscriptionsCount: 1,
|
||||
userRegisteredAt: 1,
|
||||
billingFrequency: 12,
|
||||
payAmount: 59.00
|
||||
})
|
||||
|
||||
await Factory.sleep(0.25)
|
||||
|
||||
@@ -124,6 +124,13 @@ describe('settings service', function () {
|
||||
subscriptionExpiresAt: (new Date().getTime() + 3_600_000) * 1_000,
|
||||
timestamp: Date.now(),
|
||||
offline: false,
|
||||
discountCode: null,
|
||||
limitedDiscountPurchased: false,
|
||||
newSubscriber: true,
|
||||
totalActiveSubscriptionsCount: 1,
|
||||
userRegisteredAt: 1,
|
||||
billingFrequency: 12,
|
||||
payAmount: 59.00
|
||||
})
|
||||
|
||||
await Factory.sleep(1)
|
||||
@@ -142,6 +149,13 @@ describe('settings service', function () {
|
||||
subscriptionExpiresAt: (new Date().getTime() + 3_600_000) * 1_000,
|
||||
timestamp: Date.now(),
|
||||
offline: false,
|
||||
discountCode: null,
|
||||
limitedDiscountPurchased: false,
|
||||
newSubscriber: true,
|
||||
totalActiveSubscriptionsCount: 1,
|
||||
userRegisteredAt: 1,
|
||||
billingFrequency: 12,
|
||||
payAmount: 59.00
|
||||
})
|
||||
await Factory.sleep(1)
|
||||
|
||||
@@ -164,13 +178,16 @@ describe('settings service', function () {
|
||||
const usedSettingBefore = await application.settings.getSubscriptionSetting('FILE_UPLOAD_BYTES_USED')
|
||||
expect(usedSettingBefore).to.equal('123')
|
||||
|
||||
|
||||
await Factory.publishMockedEvent('SUBSCRIPTION_EXPIRED', {
|
||||
userEmail: context.email,
|
||||
subscriptionId: 1,
|
||||
subscriptionName: 'PRO_PLAN',
|
||||
timestamp: Date.now(),
|
||||
offline: false,
|
||||
totalActiveSubscriptionsCount: 1,
|
||||
userExistingSubscriptionsCount: 1,
|
||||
billingFrequency: 12,
|
||||
payAmount: 59.00
|
||||
})
|
||||
await Factory.sleep(1)
|
||||
|
||||
@@ -181,6 +198,13 @@ describe('settings service', function () {
|
||||
subscriptionExpiresAt: (new Date().getTime() + 3_600_000) * 1_000,
|
||||
timestamp: Date.now(),
|
||||
offline: false,
|
||||
discountCode: null,
|
||||
limitedDiscountPurchased: false,
|
||||
newSubscriber: false,
|
||||
totalActiveSubscriptionsCount: 2,
|
||||
userRegisteredAt: 1,
|
||||
billingFrequency: 12,
|
||||
payAmount: 59.00
|
||||
})
|
||||
await Factory.sleep(1)
|
||||
|
||||
|
||||
@@ -37,6 +37,13 @@ describe('subscriptions', function () {
|
||||
subscriptionExpiresAt: (new Date().getTime() + 3_600_000) * 1_000,
|
||||
timestamp: Date.now(),
|
||||
offline: false,
|
||||
discountCode: null,
|
||||
limitedDiscountPurchased: false,
|
||||
newSubscriber: true,
|
||||
totalActiveSubscriptionsCount: 1,
|
||||
userRegisteredAt: 1,
|
||||
billingFrequency: 12,
|
||||
payAmount: 59.00
|
||||
})
|
||||
await Factory.sleep(0.25)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user