From 29e48ec442103658aa45e6d09c059a80aa075fe3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 15:35:11 +0000 Subject: [PATCH 1/4] Bump eslint-plugin-testing-library from 5.11.1 to 6.2.2 Bumps [eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library) from 5.11.1 to 6.2.2. - [Release notes](https://github.com/testing-library/eslint-plugin-testing-library/releases) - [Changelog](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/.releaserc.json) - [Commits](https://github.com/testing-library/eslint-plugin-testing-library/compare/v5.11.1...v6.2.2) --- updated-dependencies: - dependency-name: eslint-plugin-testing-library dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- web/packages/build/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/packages/build/package.json b/web/packages/build/package.json index 8279e7aa1c215..c2baf3e9f51b7 100644 --- a/web/packages/build/package.json +++ b/web/packages/build/package.json @@ -59,7 +59,7 @@ "eslint-plugin-jest-dom": "^5.4.0", "eslint-plugin-react": "^7.34.2", "eslint-plugin-react-hooks": "^4.6.2", - "eslint-plugin-testing-library": "^5.11.1", + "eslint-plugin-testing-library": "^6.2.2", "events": "3.3.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", diff --git a/yarn.lock b/yarn.lock index e6554eee1b8ca..731bab4feae46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7301,10 +7301,10 @@ eslint-plugin-react@^7.34.2: semver "^6.3.1" string.prototype.matchall "^4.0.11" -eslint-plugin-testing-library@^5.11.1: - version "5.11.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-testing-library/-/eslint-plugin-testing-library-5.11.1.tgz#5b46cdae96d4a78918711c0b4792f90088e62d20" - integrity sha512-5eX9e1Kc2PqVRed3taaLnAAqPZGEX75C+M/rXzUAI3wIg/ZxzUm1OVAwfe/O+vE+6YXOLetSe9g5GKD2ecXipw== +eslint-plugin-testing-library@^6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-testing-library/-/eslint-plugin-testing-library-6.2.2.tgz#67e84ff891a2b3a8078ced0afa95ee6f343c00c1" + integrity sha512-1E94YOTUDnOjSLyvOwmbVDzQi/WkKm3WVrMXu6SmBr6DN95xTGZmI6HJ/eOkSXh/DlheRsxaPsJvZByDBhWLVQ== dependencies: "@typescript-eslint/utils" "^5.58.0" From 7cb47a0d55ac72433f25b3f6dbc5d7adb507e5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Cie=C5=9Blak?= Date: Mon, 8 Jul 2024 16:06:50 +0200 Subject: [PATCH 2/4] Add automatic error fixes --- .../CreateAppAccess/CreateAppAccess.test.tsx | 2 +- .../EditAwsOidcIntegrationDialog.test.tsx | 36 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/web/packages/teleport/src/Discover/AwsMangementConsole/CreateAppAccess/CreateAppAccess.test.tsx b/web/packages/teleport/src/Discover/AwsMangementConsole/CreateAppAccess/CreateAppAccess.test.tsx index fd5c85926dec6..28eccfbca3e22 100644 --- a/web/packages/teleport/src/Discover/AwsMangementConsole/CreateAppAccess/CreateAppAccess.test.tsx +++ b/web/packages/teleport/src/Discover/AwsMangementConsole/CreateAppAccess/CreateAppAccess.test.tsx @@ -61,7 +61,7 @@ test('create app access', async () => { renderCreateAppAccess(ctx, discoverCtx); await screen.findByText(/bash/i); - userEvent.click(screen.getByRole('button', { name: /next/i })); + await userEvent.click(screen.getByRole('button', { name: /next/i })); await screen.findByText(/aws-console/i); expect(integrationService.createAwsAppAccess).toHaveBeenCalledTimes(1); }); diff --git a/web/packages/teleport/src/Integrations/EditAwsOidcIntegrationDialog.test.tsx b/web/packages/teleport/src/Integrations/EditAwsOidcIntegrationDialog.test.tsx index 2b4bd61998c36..1b4343ea780e9 100644 --- a/web/packages/teleport/src/Integrations/EditAwsOidcIntegrationDialog.test.tsx +++ b/web/packages/teleport/src/Integrations/EditAwsOidcIntegrationDialog.test.tsx @@ -67,7 +67,7 @@ test('user acknowledging script was ran when s3 bucket fields are edited', async // - checkbox to confirm user has ran command // - edit button replaces generate command button // - save button still disabled - userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click(screen.getByRole('button', { name: /generate command/i })); await screen.findByRole('button', { name: /edit/i }); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); expect( @@ -77,20 +77,20 @@ test('user acknowledging script was ran when s3 bucket fields are edited', async expect(screen.getByTestId('scriptbox')).toBeInTheDocument(); // Click on checkbox should enable save button and disable edit button. - userEvent.click(screen.getByRole('checkbox')); + await userEvent.click(screen.getByRole('checkbox')); await waitFor(() => expect(screen.getByRole('button', { name: /save/i })).toBeEnabled() ); expect(screen.getByRole('button', { name: /edit/i })).toBeDisabled(); // Unchecking the checkbox should disable save button. - userEvent.click(screen.getByRole('checkbox')); + await userEvent.click(screen.getByRole('checkbox')); await waitFor(() => expect(screen.getByRole('button', { name: /save/i })).toBeDisabled() ); // Click on edit, should replace it with generate command - userEvent.click(screen.getByRole('button', { name: /edit/i })); + await userEvent.click(screen.getByRole('button', { name: /edit/i })); await waitFor(() => expect( screen.getByRole('button', { name: /generate command/i }) @@ -139,29 +139,29 @@ test('render warning on save when leaving s3 fields empty', async () => { expect(screen.queryByLabelText(/I ran the command/i)).not.toBeInTheDocument(); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); - userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click(screen.getByRole('button', { name: /generate command/i })); await screen.findByRole('button', { name: /edit/i }); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); - userEvent.click(screen.getByLabelText(/I ran the command/i)); + await userEvent.click(screen.getByLabelText(/I ran the command/i)); await waitFor(() => expect(screen.getByRole('button', { name: /save/i })).toBeEnabled() ); // Clicking on save without defining s3 fields, should render // a warning. - userEvent.click(screen.getByRole('button', { name: /save/i })); + await userEvent.click(screen.getByRole('button', { name: /save/i })); await screen.findByText(/recommended to use an S3 bucket/i); expect(edit).not.toHaveBeenCalled(); // Canceling and saving should re-render the warning. - userEvent.click(screen.getByRole('button', { name: /cancel/i })); + await userEvent.click(screen.getByRole('button', { name: /cancel/i })); await screen.findByRole('button', { name: /save/i }); - userEvent.click(screen.getByRole('button', { name: /save/i })); + await userEvent.click(screen.getByRole('button', { name: /save/i })); await screen.findByText(/recommended to use an S3 bucket/i); - userEvent.click(screen.getByRole('button', { name: /continue/i })); + await userEvent.click(screen.getByRole('button', { name: /continue/i })); await waitFor(() => expect(edit).toHaveBeenCalledTimes(1)); }); @@ -205,24 +205,24 @@ test('render warning on save when deleting existing s3 fields', async () => { expect(screen.queryByLabelText(/I ran the command/i)).not.toBeInTheDocument(); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); - userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click(screen.getByRole('button', { name: /generate command/i })); await screen.findByRole('button', { name: /edit/i }); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); - userEvent.click(screen.getByLabelText(/I ran the command/i)); + await userEvent.click(screen.getByLabelText(/I ran the command/i)); await waitFor(() => expect(screen.getByRole('button', { name: /save/i })).toBeEnabled() ); // Test for warning render. - userEvent.click(screen.getByRole('button', { name: /save/i })); + await userEvent.click(screen.getByRole('button', { name: /save/i })); await screen.findByText(/recommended to use an S3 bucket/i); expect(edit).not.toHaveBeenCalled(); expect( screen.getByText(/recommended to use an S3 bucket/i) ).toBeInTheDocument(); - userEvent.click(screen.getByRole('button', { name: /continue/i })); + await userEvent.click(screen.getByRole('button', { name: /continue/i })); await waitFor(() => expect(edit).toHaveBeenCalledTimes(1)); }); @@ -248,7 +248,7 @@ test('edit invalid fields', async () => { ).toBeEnabled() ); - userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click(screen.getByRole('button', { name: /generate command/i })); await screen.findByText(/invalid role ARN format/i); }); @@ -283,14 +283,14 @@ test('edit submit called with proper fields', async () => { ).toBeEnabled() ); - userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click(screen.getByRole('button', { name: /generate command/i })); await screen.findByRole('button', { name: /edit/i }); - userEvent.click(screen.getByLabelText(/I ran the command/i)); + await userEvent.click(screen.getByLabelText(/I ran the command/i)); await waitFor(() => expect(screen.getByRole('button', { name: /save/i })).toBeEnabled() ); - userEvent.click(screen.getByRole('button', { name: /save/i })); + await userEvent.click(screen.getByRole('button', { name: /save/i })); await waitFor(() => expect(mockEditFn).toHaveBeenCalledTimes(1)); expect(mockEditFn).toHaveBeenCalledWith({ From 6c87fc60713c2b14813ac426e1a8c8fef19c901b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Cie=C5=9Blak?= Date: Mon, 8 Jul 2024 16:08:42 +0200 Subject: [PATCH 3/4] Remove unnecessary await from fireEvent.click --- web/packages/teleport/src/Bots/List/BotList.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/packages/teleport/src/Bots/List/BotList.test.tsx b/web/packages/teleport/src/Bots/List/BotList.test.tsx index 1439890e675cb..fa03222f9beb7 100644 --- a/web/packages/teleport/src/Bots/List/BotList.test.tsx +++ b/web/packages/teleport/src/Bots/List/BotList.test.tsx @@ -72,7 +72,7 @@ test('renders View options if type is github actions ssh', async () => { const props = makeProps(); props.bots = [bot]; render(); - await fireEvent.click(await screen.findByText('OPTIONS')); + fireEvent.click(await screen.findByText('OPTIONS')); expect(screen.getByText('View...')).toBeInTheDocument(); }); @@ -95,6 +95,6 @@ test('doesnt renders View options if bot type is not github actions', async () = const props = makeProps(); props.bots = [bot]; render(); - await fireEvent.click(await screen.findByText('OPTIONS')); + fireEvent.click(await screen.findByText('OPTIONS')); expect(screen.queryByText('View...')).not.toBeInTheDocument(); }); From e4cc600f9f8214a7611774adfbb75e895b13ca67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Cie=C5=9Blak?= Date: Mon, 8 Jul 2024 16:20:37 +0200 Subject: [PATCH 4/4] Fix formatting --- .../EditAwsOidcIntegrationDialog.test.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/web/packages/teleport/src/Integrations/EditAwsOidcIntegrationDialog.test.tsx b/web/packages/teleport/src/Integrations/EditAwsOidcIntegrationDialog.test.tsx index 1b4343ea780e9..ed6151770e7cb 100644 --- a/web/packages/teleport/src/Integrations/EditAwsOidcIntegrationDialog.test.tsx +++ b/web/packages/teleport/src/Integrations/EditAwsOidcIntegrationDialog.test.tsx @@ -67,7 +67,9 @@ test('user acknowledging script was ran when s3 bucket fields are edited', async // - checkbox to confirm user has ran command // - edit button replaces generate command button // - save button still disabled - await userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click( + screen.getByRole('button', { name: /generate command/i }) + ); await screen.findByRole('button', { name: /edit/i }); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); expect( @@ -139,7 +141,9 @@ test('render warning on save when leaving s3 fields empty', async () => { expect(screen.queryByLabelText(/I ran the command/i)).not.toBeInTheDocument(); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); - await userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click( + screen.getByRole('button', { name: /generate command/i }) + ); await screen.findByRole('button', { name: /edit/i }); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); @@ -205,7 +209,9 @@ test('render warning on save when deleting existing s3 fields', async () => { expect(screen.queryByLabelText(/I ran the command/i)).not.toBeInTheDocument(); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); - await userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click( + screen.getByRole('button', { name: /generate command/i }) + ); await screen.findByRole('button', { name: /edit/i }); expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); @@ -248,7 +254,9 @@ test('edit invalid fields', async () => { ).toBeEnabled() ); - await userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click( + screen.getByRole('button', { name: /generate command/i }) + ); await screen.findByText(/invalid role ARN format/i); }); @@ -283,7 +291,9 @@ test('edit submit called with proper fields', async () => { ).toBeEnabled() ); - await userEvent.click(screen.getByRole('button', { name: /generate command/i })); + await userEvent.click( + screen.getByRole('button', { name: /generate command/i }) + ); await screen.findByRole('button', { name: /edit/i }); await userEvent.click(screen.getByLabelText(/I ran the command/i));