refactor(web): keep pending action labels private (#10075)
This commit is contained in:
1 parent
19ea3c5beb
commit
688e594804
2 files changed
+2
-92
No files matched your search
@@ -15,7 +15,7 @@ vi.mock("../SidebarStageBackdrop", () => ({
|
||||
useSidebarStageBackdropVariant: (enabled = true) => (enabled ? stageArtworkState.variant : null),
|
||||
}));
|
||||
|
||||
import { ComposerPrimaryActions, formatPendingPrimaryActionLabel } from "./ComposerPrimaryActions";
|
||||
import { ComposerPrimaryActions } from "./ComposerPrimaryActions";
|
||||
|
||||
function renderPendingActions(isRunning: boolean) {
|
||||
return renderToStaticMarkup(
|
||||
@@ -92,96 +92,6 @@ afterEach(() => {
|
||||
stageArtworkState.variant = null;
|
||||
});
|
||||
|
||||
describe("formatPendingPrimaryActionLabel", () => {
|
||||
it("returns 'Submitting...' while responding", () => {
|
||||
expect(
|
||||
formatPendingPrimaryActionLabel({
|
||||
compact: false,
|
||||
isLastQuestion: false,
|
||||
isResponding: true,
|
||||
questionIndex: 0,
|
||||
}),
|
||||
).toBe("Submitting...");
|
||||
});
|
||||
|
||||
it("returns 'Submitting...' while responding regardless of other flags", () => {
|
||||
expect(
|
||||
formatPendingPrimaryActionLabel({
|
||||
compact: true,
|
||||
isLastQuestion: true,
|
||||
isResponding: true,
|
||||
questionIndex: 3,
|
||||
}),
|
||||
).toBe("Submitting...");
|
||||
});
|
||||
|
||||
it("returns 'Submit' in compact mode on the last question", () => {
|
||||
expect(
|
||||
formatPendingPrimaryActionLabel({
|
||||
compact: true,
|
||||
isLastQuestion: true,
|
||||
isResponding: false,
|
||||
questionIndex: 0,
|
||||
}),
|
||||
).toBe("Submit");
|
||||
});
|
||||
|
||||
it("returns 'Next' in compact mode when not the last question", () => {
|
||||
expect(
|
||||
formatPendingPrimaryActionLabel({
|
||||
compact: true,
|
||||
isLastQuestion: false,
|
||||
isResponding: false,
|
||||
questionIndex: 1,
|
||||
}),
|
||||
).toBe("Next");
|
||||
});
|
||||
|
||||
it("returns 'Next question' when not the last question", () => {
|
||||
expect(
|
||||
formatPendingPrimaryActionLabel({
|
||||
compact: false,
|
||||
isLastQuestion: false,
|
||||
isResponding: false,
|
||||
questionIndex: 0,
|
||||
}),
|
||||
).toBe("Next question");
|
||||
});
|
||||
|
||||
it("returns singular 'Submit answer' on the last question when it is the only question", () => {
|
||||
expect(
|
||||
formatPendingPrimaryActionLabel({
|
||||
compact: false,
|
||||
isLastQuestion: true,
|
||||
isResponding: false,
|
||||
questionIndex: 0,
|
||||
}),
|
||||
).toBe("Submit answer");
|
||||
});
|
||||
|
||||
it("returns plural 'Submit answers' on the last question when there are multiple questions", () => {
|
||||
expect(
|
||||
formatPendingPrimaryActionLabel({
|
||||
compact: false,
|
||||
isLastQuestion: true,
|
||||
isResponding: false,
|
||||
questionIndex: 1,
|
||||
}),
|
||||
).toBe("Submit answers");
|
||||
});
|
||||
|
||||
it("returns plural 'Submit answers' for higher question indices", () => {
|
||||
expect(
|
||||
formatPendingPrimaryActionLabel({
|
||||
compact: false,
|
||||
isLastQuestion: true,
|
||||
isResponding: false,
|
||||
questionIndex: 5,
|
||||
}),
|
||||
).toBe("Submit answers");
|
||||
});
|
||||
});
|
||||
|
||||
describe("ComposerPrimaryActions", () => {
|
||||
it("disables and labels the send button while feedback is uploading", () => {
|
||||
const markup = renderSendButton("Sending feedback");
|
||||
|
||||
@@ -37,7 +37,7 @@ interface ComposerPrimaryActionsProps {
|
||||
onImplementPlanInNewThread: () => void;
|
||||
}
|
||||
|
||||
export const formatPendingPrimaryActionLabel = (input: {
|
||||
const formatPendingPrimaryActionLabel = (input: {
|
||||
compact: boolean;
|
||||
isLastQuestion: boolean;
|
||||
isResponding: boolean;
|
||||
|
||||
Reference in new issue
Block a user