From 971c2c99277dd0ecfcbd9213399c3e9b1a5f0aef Mon Sep 17 00:00:00 2001 From: NOZAIS Julien Date: Fri, 4 Oct 2024 17:47:10 +0200 Subject: [PATCH] Add frontend tests for the reset connector offsets button --- .../Actions/__tests__/Actions.spec.tsx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/frontend/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx b/frontend/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx index 693b90bf0..4de6c6335 100644 --- a/frontend/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx +++ b/frontend/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx @@ -84,6 +84,23 @@ describe('Actions', () => { expect(screen.getByText('Resume')).toBeInTheDocument(); expect(screen.queryByText('Pause')).not.toBeInTheDocument(); expect(screen.queryByText('Stop')).not.toBeInTheDocument(); + expect(screen.queryByText('Reset Connector Offsets')).toBeInTheDocument(); + expect(screen.getByText('Reset Connector Offsets')).toBeDisabled(); + expectActionButtonsExists(); + }); + + it('renders buttons when stopped', async () => { + (useConnector as jest.Mock).mockImplementation(() => ({ + data: setConnectorStatus(connector, ConnectorState.PAUSED), + })); + renderComponent(); + await afterClickRestartButton(); + expect(screen.getAllByRole('menuitem').length).toEqual(4); + expect(screen.getByText('Resume')).toBeInTheDocument(); + expect(screen.queryByText('Pause')).not.toBeInTheDocument(); + expect(screen.queryByText('Stop')).not.toBeInTheDocument(); + expect(screen.queryByText('Reset Connector Offsets')).toBeInTheDocument(); + expect(screen.getByText('Reset Connector Offsets')).not.toBeDisabled(); expectActionButtonsExists(); }); @@ -97,6 +114,8 @@ describe('Actions', () => { expect(screen.queryByText('Resume')).not.toBeInTheDocument(); expect(screen.queryByText('Pause')).not.toBeInTheDocument(); expect(screen.queryByText('Stop')).not.toBeInTheDocument(); + expect(screen.queryByText('Reset Connector Offsets')).toBeInTheDocument(); + expect(screen.getByText('Reset Connector Offsets')).toBeDisabled(); expectActionButtonsExists(); }); @@ -110,6 +129,8 @@ describe('Actions', () => { expect(screen.queryByText('Resume')).not.toBeInTheDocument(); expect(screen.queryByText('Pause')).not.toBeInTheDocument(); expect(screen.queryByText('Stop')).not.toBeInTheDocument(); + expect(screen.queryByText('Reset Connector Offsets')).toBeInTheDocument(); + expect(screen.getByText('Reset Connector Offsets')).toBeDisabled(); expectActionButtonsExists(); }); @@ -123,6 +144,8 @@ describe('Actions', () => { expect(screen.queryByText('Resume')).not.toBeInTheDocument(); expect(screen.getByText('Pause')).toBeInTheDocument(); expect(screen.getByText('Stop')).toBeInTheDocument(); + expect(screen.queryByText('Reset Connector Offsets')).toBeInTheDocument(); + expect(screen.getByText('Reset Connector Offsets')).toBeDisabled(); expectActionButtonsExists(); });