Skip to content

Commit b91830e

Browse files
authored
Add: ConfigManagerのマイグレーション時にスナップショットテストを追加 (#2357)
1 parent 586ac69 commit b91830e

File tree

3 files changed

+270
-0
lines changed

3 files changed

+270
-0
lines changed

src/backend/common/ConfigManager.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ export abstract class BaseConfigManager {
343343
this._save();
344344
}
345345

346+
/** 全ての設定を取得する。テスト用。 */
347+
public getAll(): ConfigType {
348+
if (!this.config) throw new Error("Config is not initialized");
349+
return this.config;
350+
}
351+
346352
private _save() {
347353
void this.lock.acquire(lockKey, async () => {
348354
await this.save({

tests/unit/backend/common/__snapshots__/configManager.spec.ts.snap

Lines changed: 256 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit/backend/common/configManager.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pastConfigs from "./pastConfigs";
22
import configBugDefaultPreset1996 from "./pastConfigs/0.19.1-bug_default_preset.json";
3+
import { isMac } from "@/helpers/platform";
34
import { BaseConfigManager } from "@/backend/common/ConfigManager";
45
import { configSchema } from "@/type/preload";
56

@@ -85,6 +86,13 @@ for (const [version, data] of pastConfigs) {
8586
const configManager = new TestConfigManager();
8687
await configManager.initialize();
8788
expect(configManager).toBeTruthy();
89+
90+
// マイグレーション後のデータが正しいことをスナップショットで確認
91+
// NOTE: Macはショートカットキーが異なるためパス
92+
// TODO: ConfigManagerにOSを引数指定できるようにしてテストを分ける
93+
if (!isMac) {
94+
expect(configManager.getAll()).toMatchSnapshot();
95+
}
8896
});
8997
}
9098

0 commit comments

Comments
 (0)