|
@@ -89,19 +89,17 @@ describe("TaskActions", () => {
|
|
|
it("renders share button when item has id", () => {
|
|
it("renders share button when item has id", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
|
|
+ // ShareButton now uses data-testid for reliable testing
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
expect(shareButton).toBeInTheDocument()
|
|
expect(shareButton).toBeInTheDocument()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it("does not render share button when item has no id", () => {
|
|
it("does not render share button when item has no id", () => {
|
|
|
render(<TaskActions item={undefined} buttonsDisabled={false} />)
|
|
render(<TaskActions item={undefined} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.queryAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).not.toBeDefined()
|
|
|
|
|
|
|
+ // ShareButton returns null when no item ID
|
|
|
|
|
+ const shareButton = screen.queryByTestId("share-button")
|
|
|
|
|
+ expect(shareButton).toBeNull()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it("renders share button even when not authenticated", () => {
|
|
it("renders share button even when not authenticated", () => {
|
|
@@ -112,9 +110,8 @@ describe("TaskActions", () => {
|
|
|
|
|
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
|
|
+ // ShareButton should still render when not authenticated
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
expect(shareButton).toBeInTheDocument()
|
|
expect(shareButton).toBeInTheDocument()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -123,11 +120,9 @@ describe("TaskActions", () => {
|
|
|
it("shows organization and public share options when authenticated and sharing enabled", () => {
|
|
it("shows organization and public share options when authenticated and sharing enabled", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).toBeDefined()
|
|
|
|
|
- fireEvent.click(shareButton!)
|
|
|
|
|
|
|
+ // Find share button by its test ID and click it
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
|
|
+ fireEvent.click(shareButton)
|
|
|
|
|
|
|
|
expect(screen.getByText("Share with Organization")).toBeInTheDocument()
|
|
expect(screen.getByText("Share with Organization")).toBeInTheDocument()
|
|
|
expect(screen.getByText("Share Publicly")).toBeInTheDocument()
|
|
expect(screen.getByText("Share Publicly")).toBeInTheDocument()
|
|
@@ -136,11 +131,9 @@ describe("TaskActions", () => {
|
|
|
it("sends shareCurrentTask message when organization option is selected", () => {
|
|
it("sends shareCurrentTask message when organization option is selected", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).toBeDefined()
|
|
|
|
|
- fireEvent.click(shareButton!)
|
|
|
|
|
|
|
+ // Find share button by its test ID and click it
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
|
|
+ fireEvent.click(shareButton)
|
|
|
|
|
|
|
|
const orgOption = screen.getByText("Share with Organization")
|
|
const orgOption = screen.getByText("Share with Organization")
|
|
|
fireEvent.click(orgOption)
|
|
fireEvent.click(orgOption)
|
|
@@ -154,11 +147,9 @@ describe("TaskActions", () => {
|
|
|
it("sends shareCurrentTask message when public option is selected", () => {
|
|
it("sends shareCurrentTask message when public option is selected", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).toBeDefined()
|
|
|
|
|
- fireEvent.click(shareButton!)
|
|
|
|
|
|
|
+ // Find share button by its test ID and click it
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
|
|
+ fireEvent.click(shareButton)
|
|
|
|
|
|
|
|
const publicOption = screen.getByText("Share Publicly")
|
|
const publicOption = screen.getByText("Share Publicly")
|
|
|
fireEvent.click(publicOption)
|
|
fireEvent.click(publicOption)
|
|
@@ -180,11 +171,9 @@ describe("TaskActions", () => {
|
|
|
|
|
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).toBeDefined()
|
|
|
|
|
- fireEvent.click(shareButton!)
|
|
|
|
|
|
|
+ // Find share button by its test ID and click it
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
|
|
+ fireEvent.click(shareButton)
|
|
|
|
|
|
|
|
expect(screen.queryByText("Share with Organization")).not.toBeInTheDocument()
|
|
expect(screen.queryByText("Share with Organization")).not.toBeInTheDocument()
|
|
|
expect(screen.getByText("Share Publicly")).toBeInTheDocument()
|
|
expect(screen.getByText("Share Publicly")).toBeInTheDocument()
|
|
@@ -202,11 +191,9 @@ describe("TaskActions", () => {
|
|
|
it("shows connect to cloud option when not authenticated", () => {
|
|
it("shows connect to cloud option when not authenticated", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).toBeDefined()
|
|
|
|
|
- fireEvent.click(shareButton!)
|
|
|
|
|
|
|
+ // Find share button by its test ID and click it
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
|
|
+ fireEvent.click(shareButton)
|
|
|
|
|
|
|
|
expect(screen.getByText("Connect to Roo Code Cloud")).toBeInTheDocument()
|
|
expect(screen.getByText("Connect to Roo Code Cloud")).toBeInTheDocument()
|
|
|
expect(screen.getByText("Sign in to Roo Code Cloud to share tasks")).toBeInTheDocument()
|
|
expect(screen.getByText("Sign in to Roo Code Cloud to share tasks")).toBeInTheDocument()
|
|
@@ -216,11 +203,9 @@ describe("TaskActions", () => {
|
|
|
it("does not show organization and public options when not authenticated", () => {
|
|
it("does not show organization and public options when not authenticated", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).toBeDefined()
|
|
|
|
|
- fireEvent.click(shareButton!)
|
|
|
|
|
|
|
+ // Find share button by its test ID and click it
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
|
|
+ fireEvent.click(shareButton)
|
|
|
|
|
|
|
|
expect(screen.queryByText("Share with Organization")).not.toBeInTheDocument()
|
|
expect(screen.queryByText("Share with Organization")).not.toBeInTheDocument()
|
|
|
expect(screen.queryByText("Share Publicly")).not.toBeInTheDocument()
|
|
expect(screen.queryByText("Share Publicly")).not.toBeInTheDocument()
|
|
@@ -229,11 +214,9 @@ describe("TaskActions", () => {
|
|
|
it("sends rooCloudSignIn message when connect to cloud is selected", () => {
|
|
it("sends rooCloudSignIn message when connect to cloud is selected", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).toBeDefined()
|
|
|
|
|
- fireEvent.click(shareButton!)
|
|
|
|
|
|
|
+ // Find share button by its test ID and click it
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
|
|
+ fireEvent.click(shareButton)
|
|
|
|
|
|
|
|
const connectOption = screen.getByText("Connect")
|
|
const connectOption = screen.getByText("Connect")
|
|
|
fireEvent.click(connectOption)
|
|
fireEvent.click(connectOption)
|
|
@@ -253,9 +236,8 @@ describe("TaskActions", () => {
|
|
|
|
|
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- // Find button by its icon class
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
|
|
+ // Find share button by its test ID
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
expect(shareButton).toBeInTheDocument()
|
|
expect(shareButton).toBeInTheDocument()
|
|
|
expect(shareButton).toBeDisabled()
|
|
expect(shareButton).toBeDisabled()
|
|
|
|
|
|
|
@@ -303,10 +285,8 @@ describe("TaskActions", () => {
|
|
|
const { rerender } = render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
const { rerender } = render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
// Click share button to open connect modal
|
|
// Click share button to open connect modal
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
- expect(shareButton).toBeDefined()
|
|
|
|
|
- fireEvent.click(shareButton!)
|
|
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
|
|
+ fireEvent.click(shareButton)
|
|
|
|
|
|
|
|
// Click connect button to initiate authentication
|
|
// Click connect button to initiate authentication
|
|
|
const connectButton = screen.getByText("Connect")
|
|
const connectButton = screen.getByText("Connect")
|
|
@@ -353,12 +333,11 @@ describe("TaskActions", () => {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it("renders delete button and file size when item has size", () => {
|
|
|
|
|
|
|
+ it("renders delete button when item has size", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
const deleteButton = screen.getByLabelText("Delete Task (Shift + Click to skip confirmation)")
|
|
const deleteButton = screen.getByLabelText("Delete Task (Shift + Click to skip confirmation)")
|
|
|
expect(deleteButton).toBeInTheDocument()
|
|
expect(deleteButton).toBeInTheDocument()
|
|
|
- expect(screen.getByText("1024 B")).toBeInTheDocument()
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it("does not render delete button when item has no size", () => {
|
|
it("does not render delete button when item has no size", () => {
|
|
@@ -374,11 +353,10 @@ describe("TaskActions", () => {
|
|
|
it("keeps share, export, and copy buttons enabled but disables delete button when buttonsDisabled is true", () => {
|
|
it("keeps share, export, and copy buttons enabled but disables delete button when buttonsDisabled is true", () => {
|
|
|
render(<TaskActions item={mockItem} buttonsDisabled={true} />)
|
|
render(<TaskActions item={mockItem} buttonsDisabled={true} />)
|
|
|
|
|
|
|
|
- // Find buttons by their labels/icons
|
|
|
|
|
- const buttons = screen.getAllByRole("button")
|
|
|
|
|
- const shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
|
|
+ // Find buttons by their labels/test IDs
|
|
|
|
|
+ const shareButton = screen.getByTestId("share-button")
|
|
|
const exportButton = screen.getByLabelText("Export task history")
|
|
const exportButton = screen.getByLabelText("Export task history")
|
|
|
- const copyButton = buttons.find((btn) => btn.querySelector(".codicon-copy"))
|
|
|
|
|
|
|
+ const copyButton = screen.getByLabelText("history:copyPrompt")
|
|
|
const deleteButton = screen.getByLabelText("Delete Task (Shift + Click to skip confirmation)")
|
|
const deleteButton = screen.getByLabelText("Delete Task (Shift + Click to skip confirmation)")
|
|
|
|
|
|
|
|
// Share, export, and copy buttons should be enabled regardless of buttonsDisabled
|
|
// Share, export, and copy buttons should be enabled regardless of buttonsDisabled
|
|
@@ -393,10 +371,9 @@ describe("TaskActions", () => {
|
|
|
// Test with buttonsDisabled = false
|
|
// Test with buttonsDisabled = false
|
|
|
const { rerender } = render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
const { rerender } = render(<TaskActions item={mockItem} buttonsDisabled={false} />)
|
|
|
|
|
|
|
|
- let buttons = screen.getAllByRole("button")
|
|
|
|
|
- let shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
|
|
+ let shareButton = screen.getByTestId("share-button")
|
|
|
let exportButton = screen.getByLabelText("Export task history")
|
|
let exportButton = screen.getByLabelText("Export task history")
|
|
|
- let copyButton = buttons.find((btn) => btn.querySelector(".codicon-copy"))
|
|
|
|
|
|
|
+ let copyButton = screen.getByLabelText("history:copyPrompt")
|
|
|
let deleteButton = screen.getByLabelText("Delete Task (Shift + Click to skip confirmation)")
|
|
let deleteButton = screen.getByLabelText("Delete Task (Shift + Click to skip confirmation)")
|
|
|
|
|
|
|
|
expect(shareButton).not.toBeDisabled()
|
|
expect(shareButton).not.toBeDisabled()
|
|
@@ -407,10 +384,9 @@ describe("TaskActions", () => {
|
|
|
// Test with buttonsDisabled = true
|
|
// Test with buttonsDisabled = true
|
|
|
rerender(<TaskActions item={mockItem} buttonsDisabled={true} />)
|
|
rerender(<TaskActions item={mockItem} buttonsDisabled={true} />)
|
|
|
|
|
|
|
|
- buttons = screen.getAllByRole("button")
|
|
|
|
|
- shareButton = buttons.find((btn) => btn.querySelector(".codicon-link"))
|
|
|
|
|
|
|
+ shareButton = screen.getByTestId("share-button")
|
|
|
exportButton = screen.getByLabelText("Export task history")
|
|
exportButton = screen.getByLabelText("Export task history")
|
|
|
- copyButton = buttons.find((btn) => btn.querySelector(".codicon-copy"))
|
|
|
|
|
|
|
+ copyButton = screen.getByLabelText("history:copyPrompt")
|
|
|
deleteButton = screen.getByLabelText("Delete Task (Shift + Click to skip confirmation)")
|
|
deleteButton = screen.getByLabelText("Delete Task (Shift + Click to skip confirmation)")
|
|
|
|
|
|
|
|
// Share, export, and copy remain enabled
|
|
// Share, export, and copy remain enabled
|