Skip to content

Conversation

@charliepark
Copy link
Contributor

A small logic update to check for the presence of a selected instance before showing the "plz stop instance" message box. Also updates the copy from "An instance" to "This instance"

Closes #2943

No selected instance:
Screenshot 2025-11-03 at 9 17 09 PM

A not-stopped instance has been selected:
Screenshot 2025-11-03 at 9 21 15 PM

O ho! A stopped instance has been selected:
Screenshot 2025-11-03 at 9 17 26 PM

@vercel
Copy link

vercel bot commented Nov 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
console Ready Ready Preview Nov 4, 2025 5:22am

@charliepark
Copy link
Contributor Author

I think adding a test here is overkill, but on the off chance we want to add one, this one is ready to go.

test('add instance modal shows notice only for non-stopped instances', async ({ page }) => {
  await page.goto('/projects/mock-project/affinity/oil-water')

  const addInstanceButton = page.getByRole('button', { name: 'Add instance' })
  const addInstanceModal = page.getByRole('dialog', { name: 'Add instance to group' })
  const instanceCombobox = page.getByRole('combobox', { name: 'Instance' })
  const notice = page.getByText('An instance must be stopped to add it to a group')
  const modalAddButton = page.getByRole('button', { name: 'Add to group' })

  // Open modal - notice should not be visible when no instance is selected
  await addInstanceButton.click()
  await expect(addInstanceModal).toBeVisible()
  await expect(notice).toBeHidden()

  // Select a running instance - notice should appear and button should be disabled
  await page.getByRole('option', { name: 'db1' }).click()
  await expect(instanceCombobox).toHaveValue('db1')
  await expect(notice).toBeVisible()
  await expect(modalAddButton).toBeDisabled()

  // Close modal and stop db1
  await page.getByRole('button', { name: 'Cancel' }).click()
  await expect(addInstanceModal).toBeHidden()
  await page.getByRole('link', { name: 'Instances' }).click()
  await clickRowAction(page, 'db1', 'Stop')
  await page.getByRole('button', { name: 'Confirm' }).click()
  await expectRowVisible(page.getByRole('table'), {
    name: 'db1',
    state: expect.stringContaining('stopped'),
  })

  // Go back to the anti-affinity group
  await page.getByRole('link', { name: 'Affinity' }).click()
  await page.getByRole('link', { name: 'oil-water' }).click()

  // Open modal again and select the now-stopped instance
  await addInstanceButton.click()
  await expect(addInstanceModal).toBeVisible()
  await page.getByRole('option', { name: 'db1' }).click()
  await expect(instanceCombobox).toHaveValue('db1')

  // Notice should NOT appear and button should be enabled for stopped instance
  await expect(notice).toBeHidden()
  await expect(modalAddButton).toBeEnabled()

  // Close modal
  await page.getByRole('button', { name: 'Cancel' }).click()
  await expect(addInstanceModal).toBeHidden()
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only show canAddInstance notice on affinity group if instance is selected

2 participants