Skip to content

Commit

Permalink
Add migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Dec 24, 2024
1 parent 178227c commit 1547b52
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 10 deletions.
8 changes: 1 addition & 7 deletions lib/extension/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type {Zigbee2MQTTAPI, Zigbee2MQTTDevice, Zigbee2MQTTResponse, Zigbee2MQTTResponseEndpoints} from 'lib/types/api';

import crypto from 'node:crypto';
import fs from 'node:fs';
import path from 'node:path';

import bind from 'bind-decorator';
import stringify from 'json-stable-stringify-without-jsonify';
Expand Down Expand Up @@ -438,11 +436,7 @@ export default class Bridge extends Extension {
if (message.options.icon) {
const base64Match = utils.isBase64File(message.options.icon);
if (base64Match) {
const md5Hash = crypto.createHash('md5').update(base64Match.data).digest('hex');
const fileSettings = `device_icons/${md5Hash}.${base64Match.extension}`;
const file = path.join(data.getPath(), fileSettings);
fs.mkdirSync(path.dirname(file), {recursive: true});
fs.writeFileSync(file, base64Match.data, {encoding: 'base64'});
const fileSettings = utils.saveBase64DeviceIcon(base64Match);
message.options.icon = fileSettings;
logger.debug(`Saved base64 image as file to '${fileSettings}'`);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import utils from './utils';
import yaml, {YAMLFileException} from './yaml';

export {schemaJson};
export const CURRENT_VERSION = 3;
export const CURRENT_VERSION = 4;
/** NOTE: by order of priority, lower index is lower level (more important) */
export const LOG_LEVELS: readonly string[] = ['error', 'warning', 'info', 'debug'] as const;
export type LogLevel = 'error' | 'warning' | 'info' | 'debug';
Expand Down
46 changes: 44 additions & 2 deletions lib/util/settingsMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {copyFileSync, writeFileSync} from 'node:fs';

import data from './data';
import * as settings from './settings';
import utils from './utils';

interface SettingsMigration {
path: string[];
Expand All @@ -28,7 +29,7 @@ interface SettingsCustomHandler extends Omit<SettingsMigration, 'path'> {
execute: (currentSettings: Partial<Settings>) => [validPath: boolean, previousValue: unknown, changed: boolean];
}

const SUPPORTED_VERSIONS: Settings['version'][] = [undefined, 2, settings.CURRENT_VERSION];
const SUPPORTED_VERSIONS: Settings['version'][] = [undefined, 2, 3, settings.CURRENT_VERSION];

function backupSettings(version: number): void {
const filePath = data.joinPath('configuration.yaml');
Expand Down Expand Up @@ -438,6 +439,43 @@ function migrateToThree(
);
}

function migrateToFour(
currentSettings: Partial<Settings>,
transfers: SettingsTransfer[],
changes: SettingsChange[],
additions: SettingsAdd[],
removals: SettingsRemove[],
customHandlers: SettingsCustomHandler[],
): void {
transfers.push();
changes.push({
path: ['version'],
note: `Migrated settings to version 4`,
newValue: 4,
});
additions.push();
removals.push();

const saveBase64DeviceIconsAsImage = (currentSettings: Partial<Settings>): ReturnType<SettingsCustomHandler['execute']> => {
const [validPath, previousValue] = getValue(currentSettings, ['devices']);

for (const deviceKey in currentSettings.devices) {
const base64Match = utils.isBase64File(currentSettings.devices[deviceKey].icon ?? '');
if (base64Match) {
currentSettings.devices[deviceKey].icon = utils.saveBase64DeviceIcon(base64Match);
}
}

return [validPath, previousValue, validPath];
};

customHandlers.push({
note: `Device icons are now saved as images.`,
noteIf: () => true,
execute: (currentSettings) => saveBase64DeviceIconsAsImage(currentSettings),
});
}

/**
* Order of execution:
* - Transfer
Expand Down Expand Up @@ -482,7 +520,11 @@ export function migrateIfNecessary(): void {
migrationNotesFileName = 'migration-2-to-3.log';

migrateToThree(currentSettings, transfers, changes, additions, removals, customHandlers);
} /* else if (currentSettings.version === 2.1) {} */
} else if (currentSettings.version === 3) {
migrationNotesFileName = 'migration-3-to-4.log';

migrateToFour(currentSettings, transfers, changes, additions, removals, customHandlers);
}

for (const transfer of transfers) {
const [validPath, previousValue, transfered] = transferValue(currentSettings, transfer);
Expand Down
13 changes: 13 additions & 0 deletions lib/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import type {Zigbee2MQTTAPI, Zigbee2MQTTResponse, Zigbee2MQTTResponseEndpoints,
import type * as zhc from 'zigbee-herdsman-converters';

import assert from 'node:assert';
import crypto from 'node:crypto';
import fs from 'node:fs';
import path from 'node:path';

import equals from 'fast-deep-equal/es6';
import humanizeDuration from 'humanize-duration';

import data from './data';

const BASE64_IMAGE_REGEX = new RegExp(`data:image/(?<extension>.+);base64,(?<data>.+)`);

function pad(num: number): string {
Expand Down Expand Up @@ -381,11 +384,21 @@ function isBase64File(value: string): {extension: string; data: string} | false
return false;
}

function saveBase64DeviceIcon(base64Match: {extension: string; data: string}): string {
const md5Hash = crypto.createHash('md5').update(base64Match.data).digest('hex');
const fileSettings = `device_icons/${md5Hash}.${base64Match.extension}`;
const file = path.join(data.getPath(), fileSettings);
fs.mkdirSync(path.dirname(file), {recursive: true});
fs.writeFileSync(file, base64Match.data, {encoding: 'base64'});
return fileSettings;
}

/* v8 ignore next */
const noop = (): void => {};

export default {
isBase64File,
saveBase64DeviceIcon,
capitalize,
getZigbee2MQTTVersion,
getDependencyVersion,
Expand Down
84 changes: 84 additions & 0 deletions test/settingsMigration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,4 +808,88 @@ describe('Settings Migration', () => {
expect(migrationNotesContent).toContain(`[SPECIAL] Property 'availability' is now always an object.`);
});
});

describe('Migrates v3 to v4', () => {
const BASE_CONFIG = {
version: 3,
mqtt: {
server: 'mqtt://localhost',
},
};

beforeEach(() => {
settings.testing.CURRENT_VERSION = 4; // stop update after this version
data.writeDefaultConfiguration(BASE_CONFIG);
settings.reRead();
});

it('onlythis Update', () => {
// @ts-expect-error workaround
const beforeSettings = objectAssignDeep.noMutate({}, settings.getPersistedSettings());
// @ts-expect-error workaround
const afterSettings = objectAssignDeep.noMutate({}, settings.getPersistedSettings());
afterSettings.version = 4;
afterSettings.devices = {
'0x123127fffe8d96bc': {
friendly_name: '0x847127fffe8d96bc',
icon: 'device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png',
},
'0x223127fffe8d96bc': {
friendly_name: '0x223127fffe8d96bc',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ',
},
'0x323127fffe8d96bc': {
friendly_name: '0x323127fffe8d96bc',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ',
},
};

settings.set(['devices'], {
'0x123127fffe8d96bc': {
friendly_name: '0x847127fffe8d96bc',
icon: 'device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png',
},
'0x223127fffe8d96bc': {
friendly_name: '0x223127fffe8d96bc',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ',
},
'0x323127fffe8d96bc': {
friendly_name: '0x323127fffe8d96bc',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ',
},
});

expect(settings.getPersistedSettings()).toStrictEqual(
// @ts-expect-error workaround
objectAssignDeep.noMutate(beforeSettings, {
devices: {
'0x123127fffe8d96bc': {
friendly_name: '0x847127fffe8d96bc',
icon: 'device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png',
},
'0x223127fffe8d96bc': {
friendly_name: '0x223127fffe8d96bc',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ',
},
'0x323127fffe8d96bc': {
friendly_name: '0x323127fffe8d96bc',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ',
},
},
}),
);

settingsMigration.migrateIfNecessary();

const migratedSettings = settings.getPersistedSettings();

expect(migratedSettings).toStrictEqual(afterSettings);

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / ci

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest, 18)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest, 20)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / ci

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest, 22)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (macos-latest, 18)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest, 18)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest, 20)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (macos-latest, 20)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest, 22)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (macos-latest, 22)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (macos-latest, 18)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (windows-latest, 18)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (macos-latest, 20)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (windows-latest, 20)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (windows-latest, 22)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (macos-latest, 22)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (windows-latest, 18)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (windows-latest, 20)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38

Check failure on line 886 in test/settingsMigration.test.ts

View workflow job for this annotation

GitHub Actions / tests (windows-latest, 22)

test/settingsMigration.test.ts > Settings Migration > Migrates v3 to v4 > onlythis Update

AssertionError: expected { version: 4, …(2) } to strictly equal { version: 4, …(2) } - Expected + Received Object { "devices": Object { "0x123127fffe8d96bc": Object { "friendly_name": "0x847127fffe8d96bc", "icon": "device_icons/08a9016bbc0657cf5f581ae9c19c31a5.png", }, "0x223127fffe8d96bc": Object { "friendly_name": "0x223127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, "0x323127fffe8d96bc": Object { "friendly_name": "0x323127fffe8d96bc", - "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ", + "icon": "device_icons/effcad234beeb56ea7c457cf2d36d10b.png", }, }, "mqtt": Object { "server": "mqtt://localhost", }, "version": 4, } ❯ test/settingsMigration.test.ts:886:38
// const migrationNotes = mockedData.joinPath('migration-2-to-3.log');
// expect(existsSync(migrationNotes)).toStrictEqual(true);
// const migrationNotesContent = readFileSync(migrationNotes, 'utf8');
// expect(migrationNotesContent).toContain(`[SPECIAL] Property 'homeassistant' is now always an object.`);
// expect(migrationNotesContent).toContain(`[SPECIAL] Property 'frontend' is now always an object.`);
// expect(migrationNotesContent).toContain(`[SPECIAL] Property 'availability' is now always an object.`);
});
});
});

0 comments on commit 1547b52

Please sign in to comment.