feat: add commands for clearing candidates and reusing candidate settings, update UI controls
This commit is contained in:
@@ -5,6 +5,8 @@ import {
|
||||
generationAddCandidateCommand,
|
||||
generationApplyCandidateAsLayerCommand,
|
||||
generationRemoveCandidateCommand,
|
||||
generationClearCandidatesCommand,
|
||||
generationReuseCandidateSettingsCommand,
|
||||
generationReplaceCandidatePixelsCommand,
|
||||
generationSetCompareModeCommand,
|
||||
generationFailJobCommand,
|
||||
@@ -38,6 +40,38 @@ describe("generation commands", () => {
|
||||
expect(next.editor.generation.compareMode).toBe("split");
|
||||
});
|
||||
|
||||
test("clears the candidate session and resets comparison", () => {
|
||||
const withCandidate = generationAddCandidateCommand.execute(
|
||||
{ state: createInitialAppState("Test") },
|
||||
{ candidate: generationCandidate("candidate-1") },
|
||||
);
|
||||
const comparing = generationSetCompareModeCommand.execute({ state: withCandidate }, { mode: "split" });
|
||||
|
||||
const next = generationClearCandidatesCommand.execute({ state: comparing }, undefined);
|
||||
|
||||
expect(next.editor.generation.candidates).toEqual([]);
|
||||
expect(next.editor.generation.selectedCandidateId).toBeUndefined();
|
||||
expect(next.editor.generation.compareMode).toBe("result");
|
||||
});
|
||||
|
||||
test("reuses a candidate's full settings with its resolved seed", () => {
|
||||
const candidate = generationCandidate("candidate-1");
|
||||
candidate.settings = {
|
||||
...candidate.settings,
|
||||
prompt: "Stored prompt",
|
||||
model: "stored-model.safetensors",
|
||||
seed: -1,
|
||||
inpaint: { ...candidate.settings.inpaint, maskBlur: 7 },
|
||||
};
|
||||
candidate.seed = 987654;
|
||||
const state = generationAddCandidateCommand.execute({ state: createInitialAppState("Test") }, { candidate });
|
||||
|
||||
const next = generationReuseCandidateSettingsCommand.execute({ state }, { candidateId: candidate.id });
|
||||
|
||||
expect(next.editor.tools.generate).toEqual({ ...candidate.settings, seed: 987654 });
|
||||
expect(next.editor.generation).toBe(state.editor.generation);
|
||||
});
|
||||
|
||||
test("applies candidates as top-level layers", () => {
|
||||
const withRemainingCandidate = generationAddCandidateCommand.execute(
|
||||
{ state: documentWithSourceLayer() },
|
||||
|
||||
Reference in New Issue
Block a user