From b274baf67e27d79fd4e764607ded7c5aa755ee8b Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:06:48 -0500 Subject: [PATCH 1/5] unit test coverage for HostNameTableCell --- .../AccessKeyTable/HostNameTableCell.test.tsx | 115 ++++++++++++++++++ .../AccessKeyTable/HostNameTableCell.tsx | 17 +-- 2 files changed, 124 insertions(+), 8 deletions(-) create mode 100644 packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.test.tsx diff --git a/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.test.tsx b/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.test.tsx new file mode 100644 index 00000000000..92c072ca4e9 --- /dev/null +++ b/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.test.tsx @@ -0,0 +1,115 @@ +import '@testing-library/jest-dom'; +import { waitFor } from '@testing-library/react'; +import React from 'react'; + +import { regionFactory } from 'src/factories'; +import { makeResourcePage } from 'src/mocks/serverHandlers'; +import { HttpResponse, http, server } from 'src/mocks/testServer'; +import { renderWithThemeAndHookFormContext } from 'src/utilities/testHelpers'; + +import { HostNameTableCell } from './HostNameTableCell'; + +const storageKeyData = { + access_key: 'test_key', + bucket_access: null, + id: 12345, + label: 'this is regular key', + limited: false, + regions: [ + { + id: 'us-east', + s3_endpoint: 'alpha.test.com', + }, + ], + secret_key: '[test]', +}; + +describe('HostNameTableCell', () => { + it('should render "None" when there are no regions', () => { + const { getByText } = renderWithThemeAndHookFormContext({ + component: ( + + ), + }); + + expect(getByText('None')).toBeInTheDocument(); + }); + + test('should render "Regions/S3 Hostnames" cell when there are regions', async () => { + const region = regionFactory.build({ + capabilities: ['Object Storage'], + id: 'us-east', + label: 'Newark, NJ', + }); + + server.use( + http.get('*/v4/regions', () => { + return HttpResponse.json(makeResourcePage([region])); + }) + ); + const { findByText } = renderWithThemeAndHookFormContext({ + component: ( + + ), + }); + + const hostname = await findByText('Newark, NJ: alpha.test.com'); + + await waitFor(() => expect(hostname).toBeInTheDocument()); + }); + test('should render all "Regions/S3 Hostnames" in the cell when there are multiple regions', async () => { + const region = regionFactory.build({ + capabilities: ['Object Storage'], + id: 'us-east', + label: 'Newark, NJ', + }); + + server.use( + http.get('*/v4/regions', () => { + return HttpResponse.json(makeResourcePage([region])); + }) + ); + const { findByText } = renderWithThemeAndHookFormContext({ + component: ( + + ), + }); + const hostname = await findByText('Newark, NJ: alpha.test.com'); + const moreButton = await findByText(/and\s+1\s+more\.\.\./); + await waitFor(() => expect(hostname).toBeInTheDocument()); + + await expect(moreButton).toBeInTheDocument(); + }); +}); diff --git a/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.tsx b/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.tsx index e5fb3ce88db..644e2558d5d 100644 --- a/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.tsx +++ b/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.tsx @@ -1,7 +1,3 @@ -import { - ObjectStorageKey, - RegionS3EndpointAndID, -} from '@linode/api-v4/lib/object-storage'; import { styled } from '@mui/material/styles'; import React from 'react'; @@ -11,6 +7,11 @@ import { TableCell } from 'src/components/TableCell'; import { useRegionsQuery } from 'src/queries/regions/regions'; import { getRegionsByRegionId } from 'src/utilities/regions'; +import type { + ObjectStorageKey, + RegionS3EndpointAndID, +} from '@linode/api-v4/lib/object-storage'; + type Props = { setHostNames: (hostNames: RegionS3EndpointAndID[]) => void; setShowHostNamesDrawers: (show: boolean) => void; @@ -31,14 +32,14 @@ export const HostNameTableCell = ({ if (!regionsLookup || !regionsData || !regions || regions.length === 0) { return None; } + const label = regionsLookup[storageKeyData.regions[0].id]?.label; + const s3endPoint = storageKeyData?.regions[0]?.s3_endpoint; return ( - {`${regionsLookup[storageKeyData.regions[0].id].label}: ${ - storageKeyData?.regions[0]?.s3_endpoint - } `} + {`${label}: ${s3endPoint} `} {storageKeyData?.regions?.length === 1 && ( - + )} {storageKeyData.regions.length > 1 && ( Date: Wed, 19 Jun 2024 09:09:10 -0500 Subject: [PATCH 2/5] Revert "unit test coverage for HostNameTableCell" This reverts commit b274baf67e27d79fd4e764607ded7c5aa755ee8b. --- .../AccessKeyTable/HostNameTableCell.test.tsx | 115 ------------------ .../AccessKeyTable/HostNameTableCell.tsx | 17 ++- 2 files changed, 8 insertions(+), 124 deletions(-) delete mode 100644 packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.test.tsx diff --git a/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.test.tsx b/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.test.tsx deleted file mode 100644 index 92c072ca4e9..00000000000 --- a/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.test.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import '@testing-library/jest-dom'; -import { waitFor } from '@testing-library/react'; -import React from 'react'; - -import { regionFactory } from 'src/factories'; -import { makeResourcePage } from 'src/mocks/serverHandlers'; -import { HttpResponse, http, server } from 'src/mocks/testServer'; -import { renderWithThemeAndHookFormContext } from 'src/utilities/testHelpers'; - -import { HostNameTableCell } from './HostNameTableCell'; - -const storageKeyData = { - access_key: 'test_key', - bucket_access: null, - id: 12345, - label: 'this is regular key', - limited: false, - regions: [ - { - id: 'us-east', - s3_endpoint: 'alpha.test.com', - }, - ], - secret_key: '[test]', -}; - -describe('HostNameTableCell', () => { - it('should render "None" when there are no regions', () => { - const { getByText } = renderWithThemeAndHookFormContext({ - component: ( - - ), - }); - - expect(getByText('None')).toBeInTheDocument(); - }); - - test('should render "Regions/S3 Hostnames" cell when there are regions', async () => { - const region = regionFactory.build({ - capabilities: ['Object Storage'], - id: 'us-east', - label: 'Newark, NJ', - }); - - server.use( - http.get('*/v4/regions', () => { - return HttpResponse.json(makeResourcePage([region])); - }) - ); - const { findByText } = renderWithThemeAndHookFormContext({ - component: ( - - ), - }); - - const hostname = await findByText('Newark, NJ: alpha.test.com'); - - await waitFor(() => expect(hostname).toBeInTheDocument()); - }); - test('should render all "Regions/S3 Hostnames" in the cell when there are multiple regions', async () => { - const region = regionFactory.build({ - capabilities: ['Object Storage'], - id: 'us-east', - label: 'Newark, NJ', - }); - - server.use( - http.get('*/v4/regions', () => { - return HttpResponse.json(makeResourcePage([region])); - }) - ); - const { findByText } = renderWithThemeAndHookFormContext({ - component: ( - - ), - }); - const hostname = await findByText('Newark, NJ: alpha.test.com'); - const moreButton = await findByText(/and\s+1\s+more\.\.\./); - await waitFor(() => expect(hostname).toBeInTheDocument()); - - await expect(moreButton).toBeInTheDocument(); - }); -}); diff --git a/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.tsx b/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.tsx index 644e2558d5d..e5fb3ce88db 100644 --- a/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.tsx +++ b/packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyTable/HostNameTableCell.tsx @@ -1,3 +1,7 @@ +import { + ObjectStorageKey, + RegionS3EndpointAndID, +} from '@linode/api-v4/lib/object-storage'; import { styled } from '@mui/material/styles'; import React from 'react'; @@ -7,11 +11,6 @@ import { TableCell } from 'src/components/TableCell'; import { useRegionsQuery } from 'src/queries/regions/regions'; import { getRegionsByRegionId } from 'src/utilities/regions'; -import type { - ObjectStorageKey, - RegionS3EndpointAndID, -} from '@linode/api-v4/lib/object-storage'; - type Props = { setHostNames: (hostNames: RegionS3EndpointAndID[]) => void; setShowHostNamesDrawers: (show: boolean) => void; @@ -32,14 +31,14 @@ export const HostNameTableCell = ({ if (!regionsLookup || !regionsData || !regions || regions.length === 0) { return None; } - const label = regionsLookup[storageKeyData.regions[0].id]?.label; - const s3endPoint = storageKeyData?.regions[0]?.s3_endpoint; return ( - {`${label}: ${s3endPoint} `} + {`${regionsLookup[storageKeyData.regions[0].id].label}: ${ + storageKeyData?.regions[0]?.s3_endpoint + } `} {storageKeyData?.regions?.length === 1 && ( - + )} {storageKeyData.regions.length > 1 && ( Date: Thu, 26 Sep 2024 14:38:58 -0400 Subject: [PATCH 3/5] chore: [M3-8662] - Update Github Actions actions (#11009) * update actions * add changeset --------- Co-authored-by: Banks Nussman --- .github/workflows/ci.yml | 161 ++++++++---------- .github/workflows/coverage.yml | 16 +- .github/workflows/coverage_badge.yml | 6 +- .github/workflows/coverage_comment.yml | 4 +- .github/workflows/docs.yml | 10 +- .github/workflows/e2e_schedule_and_push.yml | 8 +- .github/workflows/security_scan.yml | 2 +- .../pr-11009-tech-stories-1727310949305.md | 5 + 8 files changed, 102 insertions(+), 110 deletions(-) create mode 100644 packages/manager/.changeset/pr-11009-tech-stories-1727310949305.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 014410c88cb..962897a5748 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,11 +15,11 @@ jobs: package: ["linode-manager", "@linode/api-v4", "@linode/validation"] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules @@ -30,35 +30,32 @@ jobs: build-validation: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - run: yarn --frozen-lockfile - run: yarn workspace @linode/validation run build - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: packages-validation-lib - path: | - packages/validation/index.js - packages/validation/lib + path: packages/validation/lib publish-validation: runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' - needs: - - build-validation + needs: build-validation steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: packages-validation-lib - path: packages/validation + path: packages/validation/lib - uses: JS-DevTools/npm-publish@v1 id: npm-publish with: @@ -80,69 +77,64 @@ jobs: runs-on: ubuntu-latest needs: build-validation steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - run: yarn --frozen-lockfile - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: packages-validation-lib - path: packages/validation + path: packages/validation/lib - run: yarn workspace @linode/api-v4 run test build-sdk: runs-on: ubuntu-latest - needs: - - build-validation + needs: build-validation steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: packages-validation-lib - path: packages/validation + path: packages/validation/lib - run: yarn --frozen-lockfile - run: yarn workspace @linode/api-v4 run build - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: packages-api-v4-lib - path: | - packages/api-v4/index.js - packages/api-v4/index.node.js - packages/api-v4/lib + path: packages/api-v4/lib validate-sdk: runs-on: ubuntu-latest - needs: - - build-sdk + needs: build-sdk steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" # Download the validation and api-v4 artifacts (built packages) - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: packages-validation-lib - path: packages/validation - - uses: actions/download-artifact@v3 + path: packages/validation/lib + - uses: actions/download-artifact@v4 with: name: packages-api-v4-lib - path: packages/api-v4 + path: packages/api-v4/lib # Create an api-v4 tarball - run: cd packages/api-v4 && npm pack --pack-destination ../../ @@ -162,37 +154,36 @@ jobs: test-manager: runs-on: ubuntu-latest - needs: - - build-sdk + needs: build-sdk steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: packages-validation-lib - path: packages/validation - - uses: actions/download-artifact@v3 + path: packages/validation/lib + - uses: actions/download-artifact@v4 with: name: packages-api-v4-lib - path: packages/api-v4 + path: packages/api-v4/lib - run: yarn --frozen-lockfile - run: yarn workspace linode-manager run test test-search: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules @@ -202,55 +193,53 @@ jobs: typecheck-manager: runs-on: ubuntu-latest - needs: - - build-sdk + needs: build-sdk steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: packages-validation-lib - path: packages/validation - - uses: actions/download-artifact@v3 + path: packages/validation/lib + - uses: actions/download-artifact@v4 with: name: packages-api-v4-lib - path: packages/api-v4 + path: packages/api-v4/lib - run: yarn --frozen-lockfile - run: yarn workspace linode-manager run typecheck build-manager: runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' - needs: - - build-sdk + needs: build-sdk steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: packages-validation-lib - path: packages/validation + path: packages/validation/lib - uses: actions/download-artifact@v3 with: name: packages-api-v4-lib - path: packages/api-v4 + path: packages/api-v4/lib - run: yarn --frozen-lockfile - run: yarn workspace linode-manager run build - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: packages-manager-build path: packages/manager/build @@ -264,11 +253,11 @@ jobs: # If the validation publish failed we could have mismatched versions and a broken JS client - publish-validation steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: packages-api-v4-lib - path: packages/api-v4 + path: packages/api-v4/lib - uses: JS-DevTools/npm-publish@v1 id: npm-publish with: @@ -288,31 +277,30 @@ jobs: build-storybook: runs-on: ubuntu-latest - needs: - - build-sdk + needs: build-sdk env: NODE_OPTIONS: --max-old-space-size=4096 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: packages-validation-lib - path: packages/validation - - uses: actions/download-artifact@v3 + path: packages/validation/lib + - uses: actions/download-artifact@v4 with: name: packages-api-v4-lib - path: packages/api-v4 + path: packages/api-v4/lib - run: yarn --frozen-lockfile - run: yarn workspace linode-manager run build-storybook - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: storybook-build path: packages/manager/storybook-static @@ -320,11 +308,10 @@ jobs: publish-storybook: runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' - needs: - - build-storybook + needs: build-storybook steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: storybook-build path: storybook/build diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 84399b8323f..144f802594d 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -7,16 +7,16 @@ jobs: if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.base_ref }} # The base branch of the PR (develop) - name: Use Node.js v20.17 LTS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules @@ -52,14 +52,14 @@ jobs: needs: base_branch steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js v20.17 LTS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules @@ -88,13 +88,13 @@ jobs: echo "$pct" > current_code_coverage.txt - name: Upload PR Number Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pr_number path: pr_number.txt - name: Upload Current Coverage Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: current_code_coverage path: current_code_coverage.txt diff --git a/.github/workflows/coverage_badge.yml b/.github/workflows/coverage_badge.yml index 0a73b196138..ca07bfd7f27 100644 --- a/.github/workflows/coverage_badge.yml +++ b/.github/workflows/coverage_badge.yml @@ -11,14 +11,14 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use Node.js v20.17 LTS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | **/node_modules diff --git a/.github/workflows/coverage_comment.yml b/.github/workflows/coverage_comment.yml index 07fe3682a9b..8ddd29c1ce6 100644 --- a/.github/workflows/coverage_comment.yml +++ b/.github/workflows/coverage_comment.yml @@ -15,10 +15,10 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use Node.js v20.17 LTS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20.17" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0f73e3e58b6..4a81cf374f9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,12 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Pages - uses: actions/configure-pages@v3 + uses: actions/configure-pages@v5 - - uses: oven-sh/setup-bun@v1 + - uses: oven-sh/setup-bun@v2 with: bun-version: 1.0.21 @@ -26,7 +26,7 @@ jobs: run: bunx vitepress@1.0.0-rc.35 build docs - name: Upload artifact - uses: actions/upload-pages-artifact@v2 + uses: actions/upload-pages-artifact@v3 with: path: docs/.vitepress/dist @@ -40,4 +40,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 \ No newline at end of file + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/e2e_schedule_and_push.yml b/.github/workflows/e2e_schedule_and_push.yml index 61176d8fb15..63578c1a25c 100644 --- a/.github/workflows/e2e_schedule_and_push.yml +++ b/.github/workflows/e2e_schedule_and_push.yml @@ -26,11 +26,11 @@ jobs: steps: - name: install command line utilities run: sudo apt-get install -y expect - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "20.17" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | node_modules @@ -60,7 +60,7 @@ jobs: yarn build yarn start:manager:ci & - name: Run tests - uses: cypress-io/github-action@v5 + uses: cypress-io/github-action@v6 with: working-directory: packages/manager wait-on: "http://localhost:3000" diff --git a/.github/workflows/security_scan.yml b/.github/workflows/security_scan.yml index a7cb1b14fbe..37ed12a241f 100644 --- a/.github/workflows/security_scan.yml +++ b/.github/workflows/security_scan.yml @@ -12,7 +12,7 @@ jobs: container: image: returntocorp/semgrep steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Perform scanning using Semgrep # Pass even when it identifies issues or encounters errors. diff --git a/packages/manager/.changeset/pr-11009-tech-stories-1727310949305.md b/packages/manager/.changeset/pr-11009-tech-stories-1727310949305.md new file mode 100644 index 00000000000..4ad6da2dfc5 --- /dev/null +++ b/packages/manager/.changeset/pr-11009-tech-stories-1727310949305.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tech Stories +--- + +Update Github Actions actions ([#11009](https://github.com/linode/manager/pull/11009)) From 9b9f995d53230f92c916b1bb3930edcc6c489d54 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Wed, 9 Oct 2024 07:16:48 -0500 Subject: [PATCH 4/5] fix: [M3-7197] - "Support Ticket" button in network tab not working properly --- .../LinodeNetworking/AddIPDrawer.tsx | 37 ++++-------- .../LinodeNetworking/ExplainerCopy.test.tsx | 60 +++++++++++++++++++ .../LinodeNetworking/ExplainerCopy.tsx | 43 +++++++++++++ 3 files changed, 114 insertions(+), 26 deletions(-) create mode 100644 packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/ExplainerCopy.test.tsx create mode 100644 packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/ExplainerCopy.tsx diff --git a/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/AddIPDrawer.tsx b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/AddIPDrawer.tsx index c03017df1d7..57642f09997 100644 --- a/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/AddIPDrawer.tsx +++ b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/AddIPDrawer.tsx @@ -19,10 +19,12 @@ import { } from 'src/queries/linodes/networking'; import { useCreateIPv6RangeMutation } from 'src/queries/networking/networking'; +import { ExplainerCopy } from './ExplainerCopy'; + import type { IPv6Prefix } from '@linode/api-v4/lib/networking'; import type { Item } from 'src/components/EnhancedSelect/Select'; -type IPType = 'v4Private' | 'v4Public'; +export type IPType = 'v4Private' | 'v4Public'; const ipOptions: Item[] = [ { label: 'Public', value: 'v4Public' }, @@ -34,27 +36,6 @@ const prefixOptions = [ { label: '/56', value: '56' }, ]; -// @todo: Pre-fill support tickets. -const explainerCopy: Record = { - v4Private: ( - <> - Add a private IP address to your Linode. Data sent explicitly to and from - private IP addresses in the same data center does not incur transfer quota - usage. To ensure that the private IP is properly configured once added, - it’s best to reboot your Linode. - - ), - v4Public: ( - <> - Public IP addresses, over and above the one included with each Linode, - incur an additional monthly charge. If you need an additional Public IP - Address you must request one. Please open a{' '} - Support Ticket if you have not done so - already. - - ), -}; - const IPv6ExplanatoryCopy = { 56: ( <> @@ -70,7 +51,7 @@ const IPv6ExplanatoryCopy = { ), }; -const tooltipCopy: Record = { +const tooltipCopy: Record = { v4Private: 'This Linode already has a private IP address.', v4Public: null, }; @@ -197,11 +178,11 @@ export const AddIPDrawer = (props: Props) => { {ipOptions.map((option, idx) => ( } - data-qa-radio={option.label} disabled={ option.value === 'v4Private' && linodeIsInDistributedRegion } + control={} + data-qa-radio={option.label} key={idx} label={option.label} value={option.value} @@ -209,7 +190,11 @@ export const AddIPDrawer = (props: Props) => { ))} - {selectedIPv4 && {explainerCopy[selectedIPv4]}} + {selectedIPv4 && ( + + + + )} {_tooltipCopy ? ( diff --git a/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/ExplainerCopy.test.tsx b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/ExplainerCopy.test.tsx new file mode 100644 index 00000000000..5281267a1f9 --- /dev/null +++ b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/ExplainerCopy.test.tsx @@ -0,0 +1,60 @@ +import { screen } from '@testing-library/react'; +import * as React from 'react'; +import { vi } from 'vitest'; + +import { renderWithTheme } from 'src/utilities/testHelpers'; + +import { ExplainerCopy } from './ExplainerCopy'; + +const queryMocks = vi.hoisted(() => ({ + useLinodeQuery: vi.fn().mockReturnValue({ data: undefined }), +})); + +vi.mock('src/queries/linodes/linodes', async () => { + const actual = await vi.importActual('src/queries/linodes/linodes'); + return { + ...actual, + useLinodeQuery: queryMocks.useLinodeQuery, + }; +}); + +describe('ExplainerCopy Component', () => { + const linodeId = 1234; + + beforeEach(() => { + queryMocks.useLinodeQuery.mockReturnValue({ + data: { label: 'Test Linode' }, + }); + }); + + afterEach(() => { + vi.resetAllMocks(); + }); + + it('renders the correct content for v4Private IPType', () => { + renderWithTheme(); + + expect( + screen.getByText(/Add a private IP address to your Linode/i) + ).toBeVisible(); + expect( + screen.getByText(/Data sent explicitly to and from private IP addresses/i) + ).toBeVisible(); + }); + + it('renders the correct content for v4Public IPType with SupportLink', () => { + renderWithTheme(); + + expect( + screen.getByText(/Public IP addresses, over and above the one included/i) + ).toBeVisible(); + expect(screen.getByRole('link', { name: 'Support Ticket' })).toBeVisible(); + }); + + it('displays no content when an unknown IPType is provided', () => { + renderWithTheme(); + + expect(screen.queryByText(/Add a private IP address/i)).toBeNull(); + expect(screen.queryByText(/Support Ticket/)).toBeNull(); + }); +}); diff --git a/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/ExplainerCopy.tsx b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/ExplainerCopy.tsx new file mode 100644 index 00000000000..7328db2ddbe --- /dev/null +++ b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/ExplainerCopy.tsx @@ -0,0 +1,43 @@ +import * as React from 'react'; + +import { SupportLink } from 'src/components/SupportLink'; +import { useLinodeQuery } from 'src/queries/linodes/linodes'; + +import type { IPType } from './AddIPDrawer'; + +interface ExplainerCopyProps { + ipType: IPType; + linodeId: number; +} + +export const ExplainerCopy = ({ ipType, linodeId }: ExplainerCopyProps) => { + const { data: linode } = useLinodeQuery(linodeId); + + switch (ipType) { + case 'v4Private': + return ( + <> + Add a private IP address to your Linode. Data sent explicitly to and + from private IP addresses in the same data center does not incur + transfer quota usage. To ensure that the private IP is properly + configured once added, it’s best to reboot your Linode. + + ); + case 'v4Public': + return ( + <> + Public IP addresses, over and above the one included with each Linode, + incur an additional monthly charge. If you need an additional Public + IP Address you must request one. Please open a{' '} + {' '} + if you have not done so already. + + ); + default: + return null; + } +}; From a23ac7f6c72d064e31bd021e4e103f8e56c48747 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Wed, 9 Oct 2024 07:26:50 -0500 Subject: [PATCH 5/5] Create pr-11074-fixed-1728476792585.md --- packages/manager/.changeset/pr-11074-fixed-1728476792585.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/manager/.changeset/pr-11074-fixed-1728476792585.md diff --git a/packages/manager/.changeset/pr-11074-fixed-1728476792585.md b/packages/manager/.changeset/pr-11074-fixed-1728476792585.md new file mode 100644 index 00000000000..5fd48a4c63f --- /dev/null +++ b/packages/manager/.changeset/pr-11074-fixed-1728476792585.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Fixed +--- + +"Support Ticket" button in network tab not working properly ([#11074](https://github.com/linode/manager/pull/11074))