mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 17:14:28 +00:00
Fix instance management tests
This commit is contained in:
@@ -160,7 +160,7 @@ describe('App Component - Critical Business Logic Only', () => {
|
|||||||
expect(screen.getAllByTitle('Start instance').length).toBeGreaterThan(0)
|
expect(screen.getAllByTitle('Start instance').length).toBeGreaterThan(0)
|
||||||
expect(screen.getAllByTitle('Stop instance').length).toBeGreaterThan(0)
|
expect(screen.getAllByTitle('Stop instance').length).toBeGreaterThan(0)
|
||||||
expect(screen.getAllByTitle('Edit instance').length).toBe(2)
|
expect(screen.getAllByTitle('Edit instance').length).toBe(2)
|
||||||
expect(screen.getAllByTitle('Delete instance').length).toBeGreaterThan(0)
|
expect(screen.getAllByTitle('More actions').length).toBe(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('delete confirmation calls correct API', async () => {
|
it('delete confirmation calls correct API', async () => {
|
||||||
@@ -174,8 +174,17 @@ describe('App Component - Critical Business Logic Only', () => {
|
|||||||
expect(screen.getByText('test-instance-1')).toBeInTheDocument()
|
expect(screen.getByText('test-instance-1')).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
const deleteButtons = screen.getAllByTitle('Delete instance')
|
// First click the "More actions" button to reveal the delete button
|
||||||
await user.click(deleteButtons[0])
|
const moreActionsButtons = screen.getAllByTitle('More actions')
|
||||||
|
await user.click(moreActionsButtons[0])
|
||||||
|
|
||||||
|
// Wait for the delete button to appear and click it
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(screen.getByTitle('Delete instance')).toBeInTheDocument()
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteButton = screen.getByTitle('Delete instance')
|
||||||
|
await user.click(deleteButton)
|
||||||
|
|
||||||
// Verify confirmation and API call
|
// Verify confirmation and API call
|
||||||
expect(confirmSpy).toHaveBeenCalledWith('Are you sure you want to delete instance "test-instance-1"?')
|
expect(confirmSpy).toHaveBeenCalledWith('Are you sure you want to delete instance "test-instance-1"?')
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ afterEach(() => {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// First click "More actions" to reveal the logs button
|
||||||
|
const moreActionsButton = screen.getByTitle('More actions')
|
||||||
|
await user.click(moreActionsButton)
|
||||||
|
|
||||||
const logsButton = screen.getByTitle('View logs')
|
const logsButton = screen.getByTitle('View logs')
|
||||||
await user.click(logsButton)
|
await user.click(logsButton)
|
||||||
|
|
||||||
@@ -136,6 +140,10 @@ afterEach(() => {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// First click "More actions" to reveal the delete button
|
||||||
|
const moreActionsButton = screen.getByTitle('More actions')
|
||||||
|
await user.click(moreActionsButton)
|
||||||
|
|
||||||
const deleteButton = screen.getByTitle('Delete instance')
|
const deleteButton = screen.getByTitle('Delete instance')
|
||||||
await user.click(deleteButton)
|
await user.click(deleteButton)
|
||||||
|
|
||||||
@@ -159,6 +167,10 @@ afterEach(() => {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// First click "More actions" to reveal the delete button
|
||||||
|
const moreActionsButton = screen.getByTitle('More actions')
|
||||||
|
await user.click(moreActionsButton)
|
||||||
|
|
||||||
const deleteButton = screen.getByTitle('Delete instance')
|
const deleteButton = screen.getByTitle('Delete instance')
|
||||||
await user.click(deleteButton)
|
await user.click(deleteButton)
|
||||||
|
|
||||||
@@ -170,7 +182,9 @@ afterEach(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('Button State Based on Instance Status', () => {
|
describe('Button State Based on Instance Status', () => {
|
||||||
it('disables start button and enables stop button for running instance', () => {
|
it('disables start button and enables stop button for running instance', async () => {
|
||||||
|
const user = userEvent.setup()
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<InstanceCard
|
<InstanceCard
|
||||||
instance={runningInstance}
|
instance={runningInstance}
|
||||||
@@ -181,12 +195,19 @@ afterEach(() => {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(screen.getByTitle('Start instance')).toBeDisabled()
|
expect(screen.queryByTitle('Start instance')).not.toBeInTheDocument()
|
||||||
expect(screen.getByTitle('Stop instance')).not.toBeDisabled()
|
expect(screen.getByTitle('Stop instance')).not.toBeDisabled()
|
||||||
|
|
||||||
|
// Expand more actions to access delete button
|
||||||
|
const moreActionsButton = screen.getByTitle('More actions')
|
||||||
|
await user.click(moreActionsButton)
|
||||||
|
|
||||||
expect(screen.getByTitle('Delete instance')).toBeDisabled() // Can't delete running instance
|
expect(screen.getByTitle('Delete instance')).toBeDisabled() // Can't delete running instance
|
||||||
})
|
})
|
||||||
|
|
||||||
it('enables start button and disables stop button for stopped instance', () => {
|
it('enables start button and disables stop button for stopped instance', async () => {
|
||||||
|
const user = userEvent.setup()
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<InstanceCard
|
<InstanceCard
|
||||||
instance={stoppedInstance}
|
instance={stoppedInstance}
|
||||||
@@ -198,11 +219,18 @@ afterEach(() => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(screen.getByTitle('Start instance')).not.toBeDisabled()
|
expect(screen.getByTitle('Start instance')).not.toBeDisabled()
|
||||||
expect(screen.getByTitle('Stop instance')).toBeDisabled()
|
expect(screen.queryByTitle('Stop instance')).not.toBeInTheDocument()
|
||||||
|
|
||||||
|
// Expand more actions to access delete button
|
||||||
|
const moreActionsButton = screen.getByTitle('More actions')
|
||||||
|
await user.click(moreActionsButton)
|
||||||
|
|
||||||
expect(screen.getByTitle('Delete instance')).not.toBeDisabled() // Can delete stopped instance
|
expect(screen.getByTitle('Delete instance')).not.toBeDisabled() // Can delete stopped instance
|
||||||
})
|
})
|
||||||
|
|
||||||
it('edit and logs buttons are always enabled', () => {
|
it('edit and logs buttons are always enabled', async () => {
|
||||||
|
const user = userEvent.setup()
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<InstanceCard
|
<InstanceCard
|
||||||
instance={runningInstance}
|
instance={runningInstance}
|
||||||
@@ -214,6 +242,11 @@ afterEach(() => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(screen.getByTitle('Edit instance')).not.toBeDisabled()
|
expect(screen.getByTitle('Edit instance')).not.toBeDisabled()
|
||||||
|
|
||||||
|
// Expand more actions to access logs button
|
||||||
|
const moreActionsButton = screen.getByTitle('More actions')
|
||||||
|
await user.click(moreActionsButton)
|
||||||
|
|
||||||
expect(screen.getByTitle('View logs')).not.toBeDisabled()
|
expect(screen.getByTitle('View logs')).not.toBeDisabled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -279,6 +312,10 @@ afterEach(() => {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// First click "More actions" to reveal the logs button
|
||||||
|
const moreActionsButton = screen.getByTitle('More actions')
|
||||||
|
await user.click(moreActionsButton)
|
||||||
|
|
||||||
// Open logs dialog
|
// Open logs dialog
|
||||||
await user.click(screen.getByTitle('View logs'))
|
await user.click(screen.getByTitle('View logs'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user