mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-11 08:46:16 +00:00
committed by
Rainer Killinger
parent
7276525dfa
commit
7afc24f1bc
5
.changeset/cold-years-read.md
Normal file
5
.changeset/cold-years-read.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@openstapps/app": patch
|
||||
---
|
||||
|
||||
fixed config version comparison
|
||||
@@ -132,6 +132,8 @@ describe('ConfigProvider', () => {
|
||||
wrongConfig.backend.SCVersion = '0.1.0';
|
||||
storageProviderSpy.get.and.returnValue(Promise.resolve(wrongConfig));
|
||||
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
|
||||
// sets StApps core version which has a different major version
|
||||
configProvider.scVersion = '1.0.0';
|
||||
await configProvider.init();
|
||||
|
||||
expect(ngxLogger.warn).toHaveBeenCalledWith(
|
||||
@@ -139,6 +141,19 @@ describe('ConfigProvider', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should load from storage if offline and same major version stored', async () => {
|
||||
internetConnectionServiceMock = {offline$: new BehaviorSubject<boolean>(true)};
|
||||
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
|
||||
const configInStorage = structuredClone(sampleIndexResponse);
|
||||
configInStorage.backend.SCVersion = '1.0.0';
|
||||
storageProviderSpy.get.and.returnValue(Promise.resolve(configInStorage));
|
||||
// sets StApps core version which has the same major version
|
||||
configProvider.scVersion = '1.1.1';
|
||||
await configProvider.init();
|
||||
|
||||
expect(configProvider.getAnyValue('app')).toEqual(configInStorage.app);
|
||||
});
|
||||
|
||||
it('should throw error on saved app configuration not available', async () => {
|
||||
storageProviderSpy.has.and.returnValue(Promise.resolve(false));
|
||||
// eslint-disable-next-line unicorn/error-message
|
||||
|
||||
@@ -132,7 +132,7 @@ export class ConfigProvider {
|
||||
this.config = await this.loadLocal();
|
||||
this.firstSession = false;
|
||||
this.logger.log(`initialised configuration from storage`);
|
||||
if (this.config.backend.SCVersion !== this.scVersion) {
|
||||
if (this.config.backend.SCVersion.split('.')[0] !== this.scVersion.split('.')[0]) {
|
||||
loadError = new WrongConfigVersionInStorage(this.scVersion, this.config.backend.SCVersion);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user