feat: improve initial load performance on mobile (#2126)

This commit is contained in:
Mo
2023-01-03 14:15:45 -06:00
committed by GitHub
parent a447fa1ad7
commit 3c332a35f6
59 changed files with 868 additions and 3003 deletions

View File

@@ -3,7 +3,7 @@ chai.use(chaiAsPromised)
const expect = chai.expect
describe('migrations', () => {
const allMigrations = ['2.0.0', '2.0.15', '2.7.0', '2.20.0', '2.36.0', '2.42.0']
const allMigrations = ['2.0.15', '2.7.0', '2.20.0', '2.36.0', '2.42.0']
beforeEach(async () => {
localStorage.clear()
@@ -25,34 +25,13 @@ describe('migrations', () => {
})
it('should return correct required migrations if stored version is 2.0.0', async function () {
expect((await SNMigrationService.getRequiredMigrations('2.0.0')).length).to.equal(allMigrations.length - 1)
expect((await SNMigrationService.getRequiredMigrations('2.0.0')).length).to.equal(allMigrations.length)
})
it('should return 0 required migrations if stored version is futuristic', async function () {
expect((await SNMigrationService.getRequiredMigrations('100.0.1')).length).to.equal(0)
})
it('after running base migration, legacy structure should set version as 1.0.0', async function () {
const application = await Factory.createAppWithRandNamespace()
/** Set up 1.0.0 structure with tell-tale storage key */
await application.deviceInterface.setRawStorageValue('migrations', JSON.stringify(['anything']))
await application.migrationService.runBaseMigrationPreRun()
expect(await application.migrationService.getStoredSnjsVersion()).to.equal('1.0.0')
await Factory.safeDeinit(application)
})
it('after running base migration, 2.0.0 structure set version as 2.0.0', async function () {
const application = await Factory.createAppWithRandNamespace()
/** Set up 2.0.0 structure with tell-tale storage key */
await application.deviceInterface.setRawStorageValue(
namespacedKey(application.identifier, 'last_migration_timestamp'),
'anything',
)
await application.migrationService.runBaseMigrationPreRun()
expect(await application.migrationService.getStoredSnjsVersion()).to.equal('2.0.0')
await Factory.safeDeinit(application)
})
it('after running base migration with no present storage values, should set version to current', async function () {
const application = await Factory.createAppWithRandNamespace()
await application.migrationService.runBaseMigrationPreRun()
@@ -60,18 +39,6 @@ describe('migrations', () => {
await Factory.safeDeinit(application)
})
it('after running all migrations from a 1.0.0 installation, should set stored version to current', async function () {
const application = await Factory.createAppWithRandNamespace()
/** Set up 1.0.0 structure with tell-tale storage key */
await application.deviceInterface.setRawStorageValue('migrations', JSON.stringify(['anything']))
await application.prepareForLaunch({
receiveChallenge: () => {},
})
await application.launch(true)
expect(await application.migrationService.getStoredSnjsVersion()).to.equal(SnjsVersion)
await Factory.safeDeinit(application)
})
it('after running all migrations from a 2.0.0 installation, should set stored version to current', async function () {
const application = await Factory.createAppWithRandNamespace()
/** Set up 2.0.0 structure with tell-tale storage key */
@@ -84,24 +51,6 @@ describe('migrations', () => {
await Factory.safeDeinit(application)
})
it('should be correct migration count coming from 1.0.0', async function () {
const application = await Factory.createAppWithRandNamespace()
await application.deviceInterface.setRawStorageValue('migrations', 'anything')
await application.migrationService.runBaseMigrationPreRun()
expect(await application.migrationService.getStoredSnjsVersion()).to.equal('1.0.0')
const pendingMigrations = await SNMigrationService.getRequiredMigrations(
await application.migrationService.getStoredSnjsVersion(),
)
expect(pendingMigrations.length).to.equal(allMigrations.length)
expect(pendingMigrations[0].version()).to.equal('2.0.0')
await application.prepareForLaunch({
receiveChallenge: () => {},
})
await application.launch(true)
expect(await application.migrationService.getStoredSnjsVersion()).to.equal(SnjsVersion)
await Factory.safeDeinit(application)
})
it('2.20.0 remove mfa migration', async function () {
const application = await Factory.createAppWithRandNamespace()