From f14b047d7e5f45368082b485e88af1827d89cfcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Thu, 18 May 2023 12:26:38 +0200 Subject: [PATCH] chore: add possibility to skip paid features in the e2e test suite --- packages/snjs/mocha/files.test.js | 12 ++++++------ packages/snjs/mocha/settings.test.js | 4 ++-- packages/snjs/mocha/subscriptions.test.js | 8 ++++---- packages/snjs/mocha/test.html | 12 +++++++++--- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/snjs/mocha/files.test.js b/packages/snjs/mocha/files.test.js index ade39efa9..2e2e2390e 100644 --- a/packages/snjs/mocha/files.test.js +++ b/packages/snjs/mocha/files.test.js @@ -62,7 +62,7 @@ describe('files', function () { localStorage.clear() }) - it('should create valet token from server', async function () { + it('should create valet token from server - @paidfeature', async function () { await setup({ fakeCrypto: true, subscription: true }) const remoteIdentifier = Utils.generateUuid() @@ -80,7 +80,7 @@ describe('files', function () { expect(tokenOrError.tag).to.equal('no-subscription') }) - it('should not create valet token from server when user has an expired subscription', async function () { + it('should not create valet token from server when user has an expired subscription - @paidfeature', async function () { await setup({ fakeCrypto: true, subscription: false }) await Factory.publishMockedEvent('SUBSCRIPTION_PURCHASED', { @@ -107,7 +107,7 @@ describe('files', function () { expect(tokenOrError.tag).to.equal('expired-subscription') }) - it('creating two upload sessions successively should succeed', async function () { + it('creating two upload sessions successively should succeed - @paidfeature', async function () { await setup({ fakeCrypto: true, subscription: true }) const firstToken = await application.apiService.createFileValetToken(Utils.generateUuid(), 'write') @@ -121,7 +121,7 @@ describe('files', function () { expect(secondSession.uploadId).to.be.ok }) - it('should encrypt and upload small file', async function () { + it('should encrypt and upload small file - @paidfeature', async function () { await setup({ fakeCrypto: false, subscription: true }) const response = await fetch('/packages/snjs/mocha/assets/small_file.md') @@ -134,7 +134,7 @@ describe('files', function () { expect(downloadedBytes).to.eql(buffer) }) - it('should encrypt and upload big file', async function () { + it('should encrypt and upload big file - @paidfeature', async function () { await setup({ fakeCrypto: false, subscription: true }) const response = await fetch('/packages/snjs/mocha/assets/two_mb_file.md') @@ -147,7 +147,7 @@ describe('files', function () { expect(downloadedBytes).to.eql(buffer) }) - it('should delete file', async function () { + it('should delete file - @paidfeature', async function () { await setup({ fakeCrypto: false, subscription: true }) const response = await fetch('/packages/snjs/mocha/assets/small_file.md') diff --git a/packages/snjs/mocha/settings.test.js b/packages/snjs/mocha/settings.test.js index 785942026..cb8feae08 100644 --- a/packages/snjs/mocha/settings.test.js +++ b/packages/snjs/mocha/settings.test.js @@ -116,7 +116,7 @@ describe('settings service', function () { expect(settings.getSettingValue(SettingName.create(SettingName.NAMES.MfaSecret).getValue())).to.not.be.ok }) - it('reads a subscription setting', async () => { + it('reads a subscription setting - @paidfeature', async () => { await Factory.publishMockedEvent('SUBSCRIPTION_PURCHASED', { userEmail: context.email, subscriptionId: subscriptionId++, @@ -139,7 +139,7 @@ describe('settings service', function () { expect(setting).to.be.a('string') }) - it('persist irreplaceable subscription settings between subsequent subscriptions', async () => { + it('persist irreplaceable subscription settings between subsequent subscriptions - @paidfeature', async () => { await reInitializeApplicationWithRealCrypto() await Factory.publishMockedEvent('SUBSCRIPTION_PURCHASED', { diff --git a/packages/snjs/mocha/subscriptions.test.js b/packages/snjs/mocha/subscriptions.test.js index a415055de..d787bafc2 100644 --- a/packages/snjs/mocha/subscriptions.test.js +++ b/packages/snjs/mocha/subscriptions.test.js @@ -49,7 +49,7 @@ describe('subscriptions', function () { await Factory.sleep(2) }) - it('should invite a user by email to a shared subscription', async () => { + it('should invite a user by email to a shared subscription - @paidfeature', async () => { await subscriptionManager.inviteToSubscription('test@test.te') const existingInvites = await subscriptionManager.listSubscriptionInvitations() @@ -59,7 +59,7 @@ describe('subscriptions', function () { expect(newlyCreatedInvite.status).to.equal('sent') }) - it('should not invite a user by email if the limit of shared subscription is breached', async () => { + it('should not invite a user by email if the limit of shared subscription is breached - @paidfeature', async () => { await subscriptionManager.inviteToSubscription('test1@test.te') await subscriptionManager.inviteToSubscription('test2@test.te') await subscriptionManager.inviteToSubscription('test3@test.te') @@ -77,7 +77,7 @@ describe('subscriptions', function () { expect(existingInvites.length).to.equal(5) }) - it('should cancel a user invitation to a shared subscription', async () => { + it('should cancel a user invitation to a shared subscription - @paidfeature', async () => { await subscriptionManager.inviteToSubscription('test@test.te') await subscriptionManager.inviteToSubscription('test2@test.te') @@ -96,7 +96,7 @@ describe('subscriptions', function () { expect(existingInvites.filter(invite => invite.status === 'canceled').length).to.equal(1) }) - it('should invite a user by email if the limit of shared subscription is restored', async () => { + it('should invite a user by email if the limit of shared subscription is restored - @paidfeature', async () => { await subscriptionManager.inviteToSubscription('test1@test.te') await subscriptionManager.inviteToSubscription('test2@test.te') await subscriptionManager.inviteToSubscription('test3@test.te') diff --git a/packages/snjs/mocha/test.html b/packages/snjs/mocha/test.html index 715d4459a..b67b53353 100644 --- a/packages/snjs/mocha/test.html +++ b/packages/snjs/mocha/test.html @@ -16,6 +16,7 @@ const urlParams = new URLSearchParams(window.location.search); const syncServerHostName = urlParams.get('sync_server_host_name') ?? 'syncing-server-proxy'; const bail = urlParams.get('bail') === 'false' ? false : true; + const skipPaidFeatures = urlParams.get('skip_paid_features') === 'true' ? true : false; Object.assign(window, SNCrypto); @@ -29,9 +30,14 @@ console.error(error); }; - mocha.setup('bdd'); - mocha.timeout(5000); - mocha.bail(bail); + mocha.setup({ + ui: 'bdd', + timeout: 5000, + bail: bail, + }); + if (skipPaidFeatures) { + mocha.grep('@paidfeature').invert(); + }