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/7] 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/7] 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/7] 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 aefedb2a9e9578c614419f28df0ab931a0d3a153 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Wed, 16 Oct 2024 08:42:01 -0500 Subject: [PATCH 4/7] Add capability to search linode by id from main search tool --- .../e2e/core/linodes/search-linodes.spec.ts | 44 +++++++++++++++++++ .../src/features/Search/refinedSearch.ts | 12 ++++- .../src/features/Search/search.interfaces.ts | 2 +- .../src/store/selectors/getSearchEntities.ts | 2 +- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts diff --git a/packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts b/packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts new file mode 100644 index 00000000000..f8a0fdaf0c6 --- /dev/null +++ b/packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts @@ -0,0 +1,44 @@ +import { ui } from 'support/ui'; +import { cleanUp } from 'support/util/cleanup'; +import { authenticate } from 'support/api/authentication'; +import { createTestLinode } from 'support/util/linodes'; +import type { Linode } from '@linode/api-v4'; + +authenticate(); +describe('Search Linodes', () => { + beforeEach(() => { + cleanUp(['linodes']); + cy.tag('method:e2e'); + }); + + /* + * - Confirm that linodes are searchable and filtered in the UI. + */ + it('create a linode and make sure it show up in the table and searchable in main search tool', () => { + cy.defer(() => createTestLinode({ booted: true })).then( + (linode: Linode) => { + cy.visitWithLogin('/linodes'); + cy.get(`[data-qa-linode="${linode.label}"]`) + .should('be.visible') + .within(() => { + cy.contains('Running').should('be.visible'); + }); + + // Confirm that linode is listed on the landing page. + cy.findByText(linode.label).should('be.visible'); + + // Use the main search bar to search and filter linode by label + cy.get('[id="main-search"').type(linode.label); + ui.autocompletePopper.findByTitle(linode.label).should('be.visible'); + + // Use the main search bar to search and filter linode by id value + cy.get('[id="main-search"').clear().type(`${linode.id}`); + ui.autocompletePopper.findByTitle(linode.label).should('be.visible'); + + // Use the main search bar to search and filter linode by id: pattern + cy.get('[id="main-search"').clear().type(`id:${linode.id}`); + ui.autocompletePopper.findByTitle(linode.label).should('be.visible'); + } + ); + }); +}); diff --git a/packages/manager/src/features/Search/refinedSearch.ts b/packages/manager/src/features/Search/refinedSearch.ts index 2624d2fce4c..d844566d379 100644 --- a/packages/manager/src/features/Search/refinedSearch.ts +++ b/packages/manager/src/features/Search/refinedSearch.ts @@ -5,7 +5,7 @@ import searchString from 'search-string'; import type { SearchField, SearchableItem } from './search.interfaces'; export const COMPRESSED_IPV6_REGEX = /^([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,7})?::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,7})?$/; -const DEFAULT_SEARCH_FIELDS = ['label', 'tags', 'ips']; +const DEFAULT_SEARCH_FIELDS = ['label', 'tags', 'ips', 'value']; // ============================================================================= // REFINED SEARCH @@ -166,6 +166,11 @@ export const doesSearchTermMatchItemField = ( const fieldValue = ensureValueIsString(flattenedItem[field]); + // Handle numeric comparison (e.g., for the "value" field to search linode by id) + if (typeof fieldValue === 'number') { + return fieldValue === Number(query); // Ensure exact match for numeric fields + } + if (caseSensitive) { return fieldValue.includes(query); } else { @@ -177,6 +182,7 @@ export const doesSearchTermMatchItemField = ( export const flattenSearchableItem = (item: SearchableItem) => ({ label: item.label, type: item.entityType, + value: item.value, ...item.data, }); @@ -203,7 +209,7 @@ export const getQueryInfo = (parsedQuery: any) => { }; }; -// Our entities have several fields we'd like to search: "tags", "label", "ips". +// Our entities have several fields we'd like to search: "tags", "label", "ips", "value". // A user might submit the query "tag:my-app". In this case, we want to trade // "tag" for "tags", since "tags" is the actual name of the intended property. export const getRealEntityKey = (key: string): SearchField | string => { @@ -211,9 +217,11 @@ export const getRealEntityKey = (key: string): SearchField | string => { const LABEL: SearchField = 'label'; const IPS: SearchField = 'ips'; const TYPE: SearchField = 'type'; + const VALUE: SearchField = 'value'; const substitutions = { group: TAGS, + id: VALUE, ip: IPS, is: TYPE, name: LABEL, diff --git a/packages/manager/src/features/Search/search.interfaces.ts b/packages/manager/src/features/Search/search.interfaces.ts index e8c45d5c334..a5d035f5f55 100644 --- a/packages/manager/src/features/Search/search.interfaces.ts +++ b/packages/manager/src/features/Search/search.interfaces.ts @@ -22,7 +22,7 @@ export type SearchableEntityType = | 'volume'; // These are the properties on our entities we'd like to search -export type SearchField = 'ips' | 'label' | 'tags' | 'type'; +export type SearchField = 'ips' | 'label' | 'tags' | 'type' | 'value'; export interface SearchResultsByEntity { buckets: SearchableItem[]; diff --git a/packages/manager/src/store/selectors/getSearchEntities.ts b/packages/manager/src/store/selectors/getSearchEntities.ts index f7cbef079f3..d7e9bf8d653 100644 --- a/packages/manager/src/store/selectors/getSearchEntities.ts +++ b/packages/manager/src/store/selectors/getSearchEntities.ts @@ -158,7 +158,7 @@ export const bucketToSearchableItem = ( cluster: bucket.cluster, created: bucket.created, description: readableBytes(bucket.size).formatted, - icon: 'bucket', + icon: 'storage', label: bucket.label, path: `/object-storage/buckets/${bucket.cluster}/${bucket.label}`, }, From 3c136c85729e7136fe7440246db63642213e63d3 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Wed, 16 Oct 2024 08:56:30 -0500 Subject: [PATCH 5/7] Added changeset: Add the capability to search for a Linode by ID using the main search tool. --- packages/manager/.changeset/pr-11112-added-1729086990373.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/manager/.changeset/pr-11112-added-1729086990373.md diff --git a/packages/manager/.changeset/pr-11112-added-1729086990373.md b/packages/manager/.changeset/pr-11112-added-1729086990373.md new file mode 100644 index 00000000000..4184fb9d691 --- /dev/null +++ b/packages/manager/.changeset/pr-11112-added-1729086990373.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Added +--- + +Add the capability to search for a Linode by ID using the main search tool. ([#11112](https://github.com/linode/manager/pull/11112)) From 9c9875cfc6815996d0c4d85a334ca55514651d3b Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Thu, 17 Oct 2024 08:44:12 -0500 Subject: [PATCH 6/7] Update packages/manager/.changeset/pr-11112-added-1729086990373.md Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com> --- packages/manager/.changeset/pr-11112-added-1729086990373.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/manager/.changeset/pr-11112-added-1729086990373.md b/packages/manager/.changeset/pr-11112-added-1729086990373.md index 4184fb9d691..12a00fcc645 100644 --- a/packages/manager/.changeset/pr-11112-added-1729086990373.md +++ b/packages/manager/.changeset/pr-11112-added-1729086990373.md @@ -2,4 +2,4 @@ "@linode/manager": Added --- -Add the capability to search for a Linode by ID using the main search tool. ([#11112](https://github.com/linode/manager/pull/11112)) +Add the capability to search for a Linode by ID using the main search tool ([#11112](https://github.com/linode/manager/pull/11112)) From 1a11f03e856f35893c74eb74414146cac971efbb Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Thu, 17 Oct 2024 09:08:18 -0500 Subject: [PATCH 7/7] Update packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com> --- .../manager/cypress/e2e/core/linodes/search-linodes.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts b/packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts index f8a0fdaf0c6..dcc0b7c133a 100644 --- a/packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts +++ b/packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts @@ -14,7 +14,7 @@ describe('Search Linodes', () => { /* * - Confirm that linodes are searchable and filtered in the UI. */ - it('create a linode and make sure it show up in the table and searchable in main search tool', () => { + it('create a linode and make sure it shows up in the table and is searchable in main search tool', () => { cy.defer(() => createTestLinode({ booted: true })).then( (linode: Linode) => { cy.visitWithLogin('/linodes');