Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ハミング/ソングスタイルを使用して作成されてしまったデフォルトプリセットを削除するマイグレーション処理に対してのテストを追加する #2064

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion tests/unit/backend/common/configManager.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pastConfigs from "./pastConfigs";
import config0_19_1 from "./pastConfigs/0.19.1-bug_default_preset.json";
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
import { BaseConfigManager } from "@/backend/common/ConfigManager";
import { configSchema } from "@/type/preload";
import { Preset, PresetKey, VoiceId, configSchema } from "@/type/preload";

const configBase = {
...configSchema.parse({}),
Expand Down Expand Up @@ -83,6 +84,45 @@ for (const [version, data] of pastConfigs) {
});
}

it("0.19.1からのマイグレーション時にハミング・ソングスタイル由来のデフォルトプリセットを削除できている", async () => {
const data = config0_19_1;
vi.spyOn(TestConfigManager.prototype, "exists").mockImplementation(
async () => true,
);
vi.spyOn(TestConfigManager.prototype, "save").mockImplementation(
async () => undefined,
);
vi.spyOn(TestConfigManager.prototype, "load").mockImplementation(
async () => data,
);

const configManager = new TestConfigManager();
await configManager.initialize();
const presets = configManager.get("presets");
const defaultPresetKeys = configManager.get("defaultPresetKeys");

expect(Object.keys(defaultPresetKeys).length).toEqual(presets.keys.length);
expect(Object.keys(presets.items).length).toEqual(presets.keys.length);
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved

for (const key of Object.keys(defaultPresetKeys)) {
// VoiceIdの3番目はスタイルIDなので、それが3000以上3085以下または6000のものをソング・ハミングスタイルとみなす
const voiceId = key as VoiceId;
const splited = voiceId.split(":");
const styleId = parseInt(splited[2]);
expect(
(styleId >= 3000 && styleId <= 3085) || styleId === 6000,
).toBeFalsy();

const presetsKey: PresetKey | undefined = defaultPresetKeys[voiceId];
expect(presetsKey).toBeTruthy();
if (presetsKey != undefined) {
expect(presets.keys.find((v) => v === presetsKey)).toBeTruthy();
const preset: Preset | undefined = presets.items[presetsKey];
expect(preset).toBeTruthy();
}
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
}
});

it("getできる", async () => {
vi.spyOn(TestConfigManager.prototype, "exists").mockImplementation(
async () => true,
Expand Down
Loading
Loading