Skip to content

Commit 8460ddd

Browse files
committed
test: remove redundant profile rename tests from SettingsView.spec.tsx
1 parent ba13a9d commit 8460ddd

File tree

1 file changed

+0
-191
lines changed

1 file changed

+0
-191
lines changed

webview-ui/src/components/settings/__tests__/SettingsView.spec.tsx

Lines changed: 0 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -681,194 +681,3 @@ describe("SettingsView - Duplicate Commands", () => {
681681
)
682682
})
683683
})
684-
685-
describe("SettingsView - Profile Rename Change Detection", () => {
686-
beforeEach(() => {
687-
vi.clearAllMocks()
688-
})
689-
690-
it("enables save button when profile is renamed", () => {
691-
// Render settings view
692-
renderSettingsView()
693-
694-
// Start rename process
695-
const renameButton = screen.getByTestId("rename-profile-button")
696-
fireEvent.click(renameButton)
697-
698-
// Enter new name and confirm
699-
const renameInput = screen.getByTestId("rename-input")
700-
fireEvent.change(renameInput, { target: { value: "newProfileName" } })
701-
702-
const confirmButton = screen.getByTestId("confirm-rename-button")
703-
fireEvent.click(confirmButton)
704-
705-
// Save button should now be enabled due to change detection
706-
const saveButton = screen.getByTestId("save-button")
707-
expect(saveButton).not.toBeDisabled()
708-
})
709-
710-
it("sends rename message to vscode when profile is renamed", () => {
711-
// Render settings view
712-
renderSettingsView()
713-
714-
// Start rename process
715-
const renameButton = screen.getByTestId("rename-profile-button")
716-
fireEvent.click(renameButton)
717-
718-
// Enter new name and confirm
719-
const renameInput = screen.getByTestId("rename-input")
720-
fireEvent.change(renameInput, { target: { value: "renamedProfile" } })
721-
722-
const confirmButton = screen.getByTestId("confirm-rename-button")
723-
fireEvent.click(confirmButton)
724-
725-
// Verify that the rename message was sent to vscode with dynamic values
726-
// Note: The actual oldName will depend on the current API config name from the extension state
727-
expect(vscode.postMessage).toHaveBeenCalledWith(
728-
expect.objectContaining({
729-
type: "renameApiConfiguration",
730-
values: expect.objectContaining({
731-
newName: "renamedProfile",
732-
}),
733-
}),
734-
)
735-
})
736-
737-
it("saves changes when save button is clicked after profile rename", () => {
738-
// Render settings view
739-
renderSettingsView()
740-
741-
// Start rename process
742-
const renameButton = screen.getByTestId("rename-profile-button")
743-
fireEvent.click(renameButton)
744-
745-
// Enter new name and confirm
746-
const renameInput = screen.getByTestId("rename-input")
747-
fireEvent.change(renameInput, { target: { value: "renamedProfile" } })
748-
749-
const confirmButton = screen.getByTestId("confirm-rename-button")
750-
fireEvent.click(confirmButton)
751-
752-
// Click save button
753-
const saveButton = screen.getByTestId("save-button")
754-
fireEvent.click(saveButton)
755-
756-
// Verify that all settings are saved, including the renamed configuration
757-
expect(vscode.postMessage).toHaveBeenCalledWith(
758-
expect.objectContaining({
759-
type: "upsertApiConfiguration",
760-
}),
761-
)
762-
})
763-
764-
it("disables save button after successful save following profile rename", () => {
765-
// Render settings view
766-
renderSettingsView()
767-
768-
// Start rename process
769-
const renameButton = screen.getByTestId("rename-profile-button")
770-
fireEvent.click(renameButton)
771-
772-
// Enter new name and confirm
773-
const renameInput = screen.getByTestId("rename-input")
774-
fireEvent.change(renameInput, { target: { value: "renamedProfile" } })
775-
776-
const confirmButton = screen.getByTestId("confirm-rename-button")
777-
fireEvent.click(confirmButton)
778-
779-
// Verify save button is enabled
780-
const saveButton = screen.getByTestId("save-button")
781-
expect(saveButton).not.toBeDisabled()
782-
783-
// Click save button
784-
fireEvent.click(saveButton)
785-
786-
// Save button should be disabled again after save
787-
expect(saveButton).toBeDisabled()
788-
})
789-
790-
it("shows unsaved changes dialog when attempting to leave after profile rename", () => {
791-
// Render with activateTab helper
792-
const { onDone } = renderSettingsView()
793-
794-
// Start rename process
795-
const renameButton = screen.getByTestId("rename-profile-button")
796-
fireEvent.click(renameButton)
797-
798-
// Enter new name and confirm to create unsaved changes
799-
const renameInput = screen.getByTestId("rename-input")
800-
fireEvent.change(renameInput, { target: { value: "renamedProfile" } })
801-
802-
const confirmButton = screen.getByTestId("confirm-rename-button")
803-
fireEvent.click(confirmButton)
804-
805-
// Try to leave by clicking Done
806-
const doneButton = screen.getByText("settings:common.done")
807-
fireEvent.click(doneButton)
808-
809-
// Should show unsaved changes dialog
810-
expect(screen.getByText("settings:unsavedChangesDialog.title")).toBeInTheDocument()
811-
expect(screen.getByText("settings:unsavedChangesDialog.description")).toBeInTheDocument()
812-
813-
// Verify onDone was not called yet
814-
expect(onDone).not.toHaveBeenCalled()
815-
})
816-
817-
it("allows leaving after discarding changes from profile rename", () => {
818-
// Render with activateTab helper
819-
const { onDone } = renderSettingsView()
820-
821-
// Start rename process
822-
const renameButton = screen.getByTestId("rename-profile-button")
823-
fireEvent.click(renameButton)
824-
825-
// Enter new name and confirm to create unsaved changes
826-
const renameInput = screen.getByTestId("rename-input")
827-
fireEvent.change(renameInput, { target: { value: "renamedProfile" } })
828-
829-
const confirmButton = screen.getByTestId("confirm-rename-button")
830-
fireEvent.click(confirmButton)
831-
832-
// Try to leave by clicking Done
833-
const doneButton = screen.getByText("settings:common.done")
834-
fireEvent.click(doneButton)
835-
836-
// Click discard in the dialog
837-
const discardButton = screen.getByTestId("alert-dialog-action")
838-
fireEvent.click(discardButton)
839-
840-
// Verify onDone was called
841-
expect(onDone).toHaveBeenCalled()
842-
})
843-
844-
it("stays on page when canceling discard dialog after profile rename", () => {
845-
// Render with activateTab helper
846-
const { onDone } = renderSettingsView()
847-
848-
// Start rename process
849-
const renameButton = screen.getByTestId("rename-profile-button")
850-
fireEvent.click(renameButton)
851-
852-
// Enter new name and confirm to create unsaved changes
853-
const renameInput = screen.getByTestId("rename-input")
854-
fireEvent.change(renameInput, { target: { value: "renamedProfile" } })
855-
856-
const confirmButton = screen.getByTestId("confirm-rename-button")
857-
fireEvent.click(confirmButton)
858-
859-
// Try to leave by clicking Done
860-
const doneButton = screen.getByText("settings:common.done")
861-
fireEvent.click(doneButton)
862-
863-
// Click cancel in the dialog
864-
const cancelButton = screen.getByTestId("alert-dialog-cancel")
865-
fireEvent.click(cancelButton)
866-
867-
// Verify onDone was not called
868-
expect(onDone).not.toHaveBeenCalled()
869-
870-
// Verify save button is still enabled (changes not discarded)
871-
const saveButton = screen.getByTestId("save-button")
872-
expect(saveButton).not.toBeDisabled()
873-
})
874-
})

0 commit comments

Comments
 (0)