From 3a4fdeabec54e8d89f27967411d9ce2295921d52 Mon Sep 17 00:00:00 2001
From: Sam Schumacher <42777208+sam-schu@users.noreply.github.com>
Date: Mon, 30 Sep 2024 12:51:40 -0400
Subject: [PATCH] Test snapshot action menu disabled prop
---
src/workflows/SnapshotActionMenu.test.tsx | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/workflows/SnapshotActionMenu.test.tsx b/src/workflows/SnapshotActionMenu.test.tsx
index b89d0cf326..fe72fe693b 100644
--- a/src/workflows/SnapshotActionMenu.test.tsx
+++ b/src/workflows/SnapshotActionMenu.test.tsx
@@ -7,6 +7,18 @@ import SnapshotActionMenu from 'src/workflows/SnapshotActionMenu';
const mockOnDelete = jest.fn();
describe('snapshot action menu', () => {
+ it('honors the disabled prop', async () => {
+ // Act
+ await act(async () => {
+ render();
+ });
+
+ // Assert
+ const snapshotActionMenu = screen.getByRole('button', { name: 'Snapshot action menu' });
+
+ expect(snapshotActionMenu).toHaveAttribute('disabled');
+ expect(snapshotActionMenu).toHaveAttribute('aria-disabled');
+ });
it('renders and enables the menu buttons if you are the snapshot owner', async () => {
// Arrange
const user: UserEvent = userEvent.setup();
@@ -16,13 +28,18 @@ describe('snapshot action menu', () => {
render();
});
- await user.click(screen.getByRole('button', { name: 'Snapshot action menu' }));
+ const snapshotActionMenu = screen.getByRole('button', { name: 'Snapshot action menu' });
+
+ await user.click(snapshotActionMenu);
const deleteSnapshotButton = screen.getByRole('button', { name: 'Delete snapshot' });
await user.pointer({ target: deleteSnapshotButton });
// Assert
+ expect(snapshotActionMenu).not.toHaveAttribute('disabled');
+ expect(snapshotActionMenu).toHaveAttribute('aria-disabled', 'false');
+
expect(deleteSnapshotButton).toBeInTheDocument();
expect(deleteSnapshotButton).toHaveAttribute('aria-disabled', 'false');
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();