From b91830e3d4eff0b51a96fb0d4523d41307f9d92b Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Sun, 22 Dec 2024 00:36:24 +0900 Subject: [PATCH] =?UTF-8?q?Add:=20ConfigManager=E3=81=AE=E3=83=9E=E3=82=A4?= =?UTF-8?q?=E3=82=B0=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E6=99=82?= =?UTF-8?q?=E3=81=AB=E3=82=B9=E3=83=8A=E3=83=83=E3=83=97=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=20(#2357)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/common/ConfigManager.ts | 6 + .../__snapshots__/configManager.spec.ts.snap | 256 ++++++++++++++++++ .../unit/backend/common/configManager.spec.ts | 8 + 3 files changed, 270 insertions(+) create mode 100644 tests/unit/backend/common/__snapshots__/configManager.spec.ts.snap diff --git a/src/backend/common/ConfigManager.ts b/src/backend/common/ConfigManager.ts index ac23b792dd..7c216464b1 100644 --- a/src/backend/common/ConfigManager.ts +++ b/src/backend/common/ConfigManager.ts @@ -343,6 +343,12 @@ export abstract class BaseConfigManager { this._save(); } + /** 全ての設定を取得する。テスト用。 */ + public getAll(): ConfigType { + if (!this.config) throw new Error("Config is not initialized"); + return this.config; + } + private _save() { void this.lock.acquire(lockKey, async () => { await this.save({ diff --git a/tests/unit/backend/common/__snapshots__/configManager.spec.ts.snap b/tests/unit/backend/common/__snapshots__/configManager.spec.ts.snap new file mode 100644 index 0000000000..27c1b4d8f6 --- /dev/null +++ b/tests/unit/backend/common/__snapshots__/configManager.spec.ts.snap @@ -0,0 +1,256 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`0.13.0からマイグレーションできる 1`] = ` +{ + "acceptRetrieveTelemetry": "Accepted", + "acceptTerms": "Accepted", + "activePointScrollMode": "OFF", + "confirmedTips": { + "engineStartedOnAltPort": false, + "notifyOnGenerate": false, + "tweakableSliderByScroll": false, + }, + "currentTheme": "Default", + "defaultPresetKeys": {}, + "defaultStyleIds": [], + "editorFont": "default", + "enableMemoNotation": false, + "enableMultiEngine": false, + "enablePreset": false, + "enableRubyNotation": false, + "engineSettings": { + "074fc39e-678b-4c13-8916-ffca8d505d1d": { + "outputSamplingRate": "engineDefault", + "useGpu": false, + }, + }, + "experimentalSetting": { + "enableInterrogativeUpspeak": false, + "enableMorphing": false, + "enableMultiSelect": false, + "shouldKeepTuningOnTextChange": false, + }, + "hotkeySettings": [ + { + "action": "音声書き出し", + "combination": "Ctrl E", + }, + { + "action": "選択音声を書き出し", + "combination": "E", + }, + { + "action": "音声を繋げて書き出し", + "combination": "", + }, + { + "action": "再生/停止", + "combination": "Space", + }, + { + "action": "連続再生/停止", + "combination": "Shift Space", + }, + { + "action": "アクセント欄を表示", + "combination": "1", + }, + { + "action": "イントネーション欄を表示", + "combination": "2", + }, + { + "action": "長さ欄を表示", + "combination": "3", + }, + { + "action": "テキスト欄を追加", + "combination": "Shift Enter", + }, + { + "action": "テキスト欄を複製", + "combination": "Ctrl D", + }, + { + "action": "テキスト欄を削除", + "combination": "Shift Delete", + }, + { + "action": "テキスト欄からフォーカスを外す", + "combination": "Escape", + }, + { + "action": "テキスト欄にフォーカスを戻す", + "combination": "Enter", + }, + { + "action": "元に戻す", + "combination": "Ctrl Z", + }, + { + "action": "やり直す", + "combination": "Ctrl Y", + }, + { + "action": "拡大", + "combination": "", + }, + { + "action": "縮小", + "combination": "", + }, + { + "action": "拡大率のリセット", + "combination": "", + }, + { + "action": "新規プロジェクト", + "combination": "Ctrl N", + }, + { + "action": "全画面表示を切り替え", + "combination": "F11", + }, + { + "action": "プロジェクトを名前を付けて保存", + "combination": "Ctrl Shift S", + }, + { + "action": "プロジェクトを上書き保存", + "combination": "Ctrl S", + }, + { + "action": "プロジェクトを読み込む", + "combination": "Ctrl O", + }, + { + "action": "テキストを読み込む", + "combination": "", + }, + { + "action": "全体のイントネーションをリセット", + "combination": "Ctrl G", + }, + { + "action": "選択中のアクセント句のイントネーションをリセット", + "combination": "R", + }, + { + "action": "コピー", + "combination": "Ctrl C", + }, + { + "action": "切り取り", + "combination": "Ctrl X", + }, + { + "action": "貼り付け", + "combination": "Ctrl V", + }, + { + "action": "すべて選択", + "combination": "Ctrl A", + }, + { + "action": "選択解除", + "combination": "", + }, + { + "action": "1番目のキャラクターを選択", + "combination": "Ctrl 1", + }, + { + "action": "2番目のキャラクターを選択", + "combination": "Ctrl 2", + }, + { + "action": "3番目のキャラクターを選択", + "combination": "Ctrl 3", + }, + { + "action": "4番目のキャラクターを選択", + "combination": "Ctrl 4", + }, + { + "action": "5番目のキャラクターを選択", + "combination": "Ctrl 5", + }, + { + "action": "6番目のキャラクターを選択", + "combination": "Ctrl 6", + }, + { + "action": "7番目のキャラクターを選択", + "combination": "Ctrl 7", + }, + { + "action": "8番目のキャラクターを選択", + "combination": "Ctrl 8", + }, + { + "action": "9番目のキャラクターを選択", + "combination": "Ctrl 9", + }, + { + "action": "10番目のキャラクターを選択", + "combination": "Ctrl 0", + }, + ], + "inheritAudioInfo": true, + "openedEditor": "talk", + "playheadPositionDisplayFormat": "MINUTES_SECONDS", + "presets": { + "items": {}, + "keys": [], + }, + "recentlyUsedProjects": [], + "registeredEngineDirs": [], + "savingSetting": { + "audioOutputDevice": "default", + "avoidOverwrite": false, + "exportLab": false, + "exportText": false, + "fileEncoding": "UTF-8", + "fileNamePattern": "", + "fixedExportDir": "", + "fixedExportEnabled": false, + "outputStereo": false, + "songTrackFileNamePattern": "", + }, + "shouldApplyDefaultPresetOnVoiceChanged": false, + "showAddAudioItemButton": true, + "showSingCharacterPortrait": true, + "showTextLineNumber": false, + "splitTextWhenPaste": "PERIOD_AND_NEW_LINE", + "splitterPosition": {}, + "toolbarSetting": [ + "PLAY_CONTINUOUSLY", + "STOP", + "EXPORT_AUDIO_SELECTED", + "EMPTY", + "UNDO", + "REDO", + ], + "undoableTrackOperations": { + "panAndGain": true, + "soloAndMute": true, + }, + "userCharacterOrder": [ + "7ffcb7ce-00ec-4bdc-82cd-45a8889e43ff", + "388f246b-8c41-4ac1-8e2d-5d79f3ff56d9", + "35b2c544-660e-401e-b503-0e14c635303a", + "3474ee95-c274-47f9-aa1a-8322163d96f1", + "b1a81618-b27b-40d2-b0ea-27a9ad408c4b", + "c30dc15a-0992-4f8d-8bb8-ad3b314e6a6f", + "e5020595-5c5d-4e87-b849-270a518d0dcf", + "4f51116a-d9ee-4516-925d-21f183e2afad", + "8eaad775-3119-417e-8cf4-2a10bfd592c8", + "481fb609-6446-4870-9f46-90c4dd623403", + "9f3ee141-26ad-437e-97bd-d22298d02ad2", + "1a17ca16-7ee5-4ea5-b191-2f02ace24d21", + "67d5d8da-acd7-4207-bb10-b5542d3a663b", + "0f56c2f2-644c-49c9-8989-94e11f7129d0", + "044830d2-f23b-44d6-ac0d-b5d733caa900", + ], +} +`; diff --git a/tests/unit/backend/common/configManager.spec.ts b/tests/unit/backend/common/configManager.spec.ts index a24cfc0b5f..d1109ada57 100644 --- a/tests/unit/backend/common/configManager.spec.ts +++ b/tests/unit/backend/common/configManager.spec.ts @@ -1,5 +1,6 @@ import pastConfigs from "./pastConfigs"; import configBugDefaultPreset1996 from "./pastConfigs/0.19.1-bug_default_preset.json"; +import { isMac } from "@/helpers/platform"; import { BaseConfigManager } from "@/backend/common/ConfigManager"; import { configSchema } from "@/type/preload"; @@ -85,6 +86,13 @@ for (const [version, data] of pastConfigs) { const configManager = new TestConfigManager(); await configManager.initialize(); expect(configManager).toBeTruthy(); + + // マイグレーション後のデータが正しいことをスナップショットで確認 + // NOTE: Macはショートカットキーが異なるためパス + // TODO: ConfigManagerにOSを引数指定できるようにしてテストを分ける + if (!isMac) { + expect(configManager.getAll()).toMatchSnapshot(); + } }); }