Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa committed Jan 10, 2025
1 parent df2e745 commit d366469
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions web/packages/teleport/src/Apps/AddApp/Automatically.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { act } from '@testing-library/react';

import { fireEvent, render, screen } from 'design/utils/testing';

import { Automatically, createAppBashCommand } from './Automatically';
Expand All @@ -33,14 +31,14 @@ test('render command only after form submit', async () => {
roles: [],
content: '',
};
render(
const { rerender } = render(
<Automatically
token={token}
attempt={{ status: 'success' }}
onClose={() => {}}
onCreate={() => Promise.resolve(true)}
labels={[]}
setLabels={() => null}
token={null}
/>
);

Expand All @@ -58,8 +56,21 @@ test('render command only after form submit', async () => {
target: { value: 'https://gravitational.com' },
});

rerender(
<Automatically
attempt={{ status: 'success' }}
onClose={() => {}}
onCreate={() => Promise.resolve(true)}
labels={[]}
setLabels={() => null}
token={token}
/>
);

// click button
act(() => screen.getByRole('button', { name: /Generate Script/i }).click());
fireEvent.click(screen.getByRole('button', { name: /Generate Script/i }));

await screen.findByText(/Regenerate Script/i);

// after form submission should show the command
cmd = createAppBashCommand(token.id, 'app-name', 'https://gravitational.com');
Expand Down

0 comments on commit d366469

Please sign in to comment.