feat: refine candidate handling in generation commands and update UI interactions
This commit is contained in:
@@ -36,7 +36,15 @@ describe("generation commands", () => {
|
||||
});
|
||||
|
||||
test("applies candidates as top-level layers", () => {
|
||||
const state = generationAddCandidateCommand.execute({ state: documentWithSourceLayer() }, { candidate: generationCandidate("candidate-1") });
|
||||
const withRemainingCandidate = generationAddCandidateCommand.execute(
|
||||
{ state: documentWithSourceLayer() },
|
||||
{ candidate: generationCandidate("candidate-2") },
|
||||
);
|
||||
const withSelectedCandidate = generationAddCandidateCommand.execute(
|
||||
{ state: withRemainingCandidate },
|
||||
{ candidate: generationCandidate("candidate-1") },
|
||||
);
|
||||
const state = generationSetCompareModeCommand.execute({ state: withSelectedCandidate }, { mode: "split" });
|
||||
|
||||
const next = generationApplyCandidateAsLayerCommand.execute(
|
||||
{ state },
|
||||
@@ -52,11 +60,23 @@ describe("generation commands", () => {
|
||||
});
|
||||
expect(next.document.artboards[0]?.layers[0]?.id).toBe("generated-layer");
|
||||
expect(next.editor.selection).toEqual({ artboardId: "a1", layerIds: ["generated-layer"] });
|
||||
expect(next.editor.generation).toEqual({ candidates: [], selectedCandidateId: undefined, compareMode: "result" });
|
||||
expect(next.editor.generation).toEqual({
|
||||
candidates: [generationCandidate("candidate-2")],
|
||||
selectedCandidateId: "candidate-2",
|
||||
compareMode: "split",
|
||||
});
|
||||
});
|
||||
|
||||
test("replaces source asset pixels for inpaint candidates", () => {
|
||||
const state = generationAddCandidateCommand.execute({ state: documentWithSourceLayer() }, { candidate: generationCandidate("candidate-1", true) });
|
||||
const withRemainingCandidate = generationAddCandidateCommand.execute(
|
||||
{ state: documentWithSourceLayer() },
|
||||
{ candidate: generationCandidate("candidate-2", true) },
|
||||
);
|
||||
const withSelectedCandidate = generationAddCandidateCommand.execute(
|
||||
{ state: withRemainingCandidate },
|
||||
{ candidate: generationCandidate("candidate-1", true) },
|
||||
);
|
||||
const state = generationSetCompareModeCommand.execute({ state: withSelectedCandidate }, { mode: "before" });
|
||||
|
||||
const next = generationReplaceCandidatePixelsCommand.execute(
|
||||
{ state },
|
||||
@@ -75,7 +95,11 @@ describe("generation commands", () => {
|
||||
},
|
||||
});
|
||||
expect(next.editor.selection).toEqual({ artboardId: "a1", layerIds: ["source-layer"] });
|
||||
expect(next.editor.generation).toEqual({ candidates: [], selectedCandidateId: undefined, compareMode: "result" });
|
||||
expect(next.editor.generation).toEqual({
|
||||
candidates: [generationCandidate("candidate-2", true)],
|
||||
selectedCandidateId: "candidate-2",
|
||||
compareMode: "before",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user