Skip to content

Updated existing Playwright tests and added new Playwright tests using a mock server.#1349

Merged
PatrikMatiasko merged 6 commits intomainfrom
pm/playwright-ui-tests
Jul 23, 2024
Merged

Updated existing Playwright tests and added new Playwright tests using a mock server.#1349
PatrikMatiasko merged 6 commits intomainfrom
pm/playwright-ui-tests

Conversation

@PatrikMatiasko
Copy link
Copy Markdown
Contributor

  • Updated Playwright Tests: The existing Playwright tests have been revised to improve accuracy, reliability, and coverage. This includes refactoring test scripts, updating test data, and enhancing test assertions.

  • New Playwright Tests with Mock Server: Introduced new Playwright tests that utilize a mock server to simulate API responses. This allows for more controlled and isolated testing environments, ensuring that tests can run independently of external service dependencies.

@PatrikMatiasko PatrikMatiasko requested a review from jkralik July 17, 2024 20:41
@PatrikMatiasko PatrikMatiasko self-assigned this Jul 17, 2024
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 17, 2024

Walkthrough

The recent updates to the project mainly enhance the mock server, shared UI, and testing infrastructure. Key changes include adding body-parsing middleware and environment configuration for the mock server, improving route handling for device and snippet services, and refining test setups and scenarios using Playwright. Post-validation and new routes have been introduced in the snippet-service backend. Additionally, UI components received improvements for better interaction and testing capabilities.

Changes

Files/Paths Change Summaries
src/index.js Added body-parser middleware, dotenv for configuration, and caching for GitHub API responses using versionData.
src/routes/devices.js Updated device routes with loadResponseStreamFromFile and lodash get for query handling.
src/routes/snippet-service.js Added validation, new routes, flags (configurationsAdd, configurationsDeleted), and enhanced filtering logic.
shared-ui (subproject) Commit hash update from 49a3f3fd1e3935345bef18df891a2f3d6e251c52 to 2b72225d968c1ecb82e79af045086d61228bba26.
playwright/global-setup.ts Replaced direct URL navigation with login(page), added version data storage in local storage.
playwright/playwright.config.ts Enhanced expect methods and updated viewport settings for tests.
playwright/tests/devices/detail.spec.ts Updated device detail tests with new interactions, expectations, and viewport adjustments.
playwright/tests/devices/list.spec.ts Enhanced device list tests with viewport settings and improved screenshot expectations.
playwright/tests/login.spec.ts Removed and commented out Keycloak login interactions.
playwright/tests/logout.spec.ts Commented out logout action test logic.
playwright/tests/snippet-service/configurations/detail.spec.ts Added tests for configuration details including views, interactions, and validations.
playwright/tests/snippet-service/configurations/list.spec.ts Introduced tests for configuration list including form interactions and modal handling.
playwright/tests/utils.ts Added login function for handling Playwright login procedures.
src/containers/Common/DetailHeaderLayout/DetailHeaderLayout.tsx Added dataTestId prop to DeleteModal component.
src/containers/Common/DetailHeaderLayout/DetailHeaderLayout.types.ts Added deleteModal property to Props type.
src/containers/Common/PageListTemplate/PageListTemplate.tsx Modified actions for invoking, deleting, and viewing items in a table row.
src/containers/Devices/Detail/DevicesDetailsPage/Tabs/Tab2/Tab2.tsx Added logging statements before updateDevicesResourceApi function call.
src/containers/SnippetService/Configurations/AddPage/AddPage.tsx Added dataTestId attributes to buttons for testing purposes.
src/containers/SnippetService/Configurations/DetailPage/DetailHeader.tsx Added dataTestId to buttons and delete modal in the DetailHeader component.
src/containers/SnippetService/Configurations/DetailPage/DetailPage.tsx Added dataTestId attributes to InvokeModal and improved button event handling.
src/containers/SnippetService/Configurations/DetailPage/JsonConfigModal.tsx Enhanced JsonConfigModal with useMemo, validation, and dataTestId attributes.
src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab1/Tab1.tsx Added dataTestId attributes to components for better identification in tests.
src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab2/Tab2.tsx Added dataTestId attributes to table and button elements.
src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab3/Tab3.tsx Added data-test-id and dataTestId attributes to elements.
src/containers/SnippetService/Configurations/InvokeModal/InvokeModal.tsx Added truncate for labels and dataTestId for various elements in InvokeModal.
src/containers/SnippetService/Configurations/InvokeModal/InvokeModal.types.ts Included optional dataTestId property in Props type.
src/containers/SnippetService/Configurations/ListPage/ListPage.tsx Added dataTestId to the add configuration button and invoke modal.
src/testId.ts Expanded testId object with detailed identifiers for snippetService configurations, buttons, and modals.

Poem

In code we trust, we pave the way,
With tests and routes in bright array.
Devices talk and snippets sing,
A symphony of code we bring.
From login screens to detail views,
Our software grows, with fewer blues.
🎵✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Outside diff range, codebase verification and nitpick comments (3)
http-gateway/web/playwright/tests/utils.ts (1)

3-13: Environment variables not set

The REACT_APP_TEST_LOGIN_USERNAME and REACT_APP_TEST_LOGIN_PASSWORD environment variables are not set. These variables are essential for the login function in http-gateway/web/playwright/tests/utils.ts to work correctly. Please ensure these environment variables are set to non-empty values.

  • http-gateway/web/playwright/tests/utils.ts: References to REACT_APP_TEST_LOGIN_USERNAME and REACT_APP_TEST_LOGIN_PASSWORD.
Analysis chain

LGTM! Ensure environment variables are set.

The login function is well-structured and appropriate for Playwright tests. Ensure that REACT_APP_TEST_LOGIN_USERNAME and REACT_APP_TEST_LOGIN_PASSWORD environment variables are correctly set.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the environment variables for login are set.

# Test: Check if the environment variables are set. Expect: Non-empty values.
echo "REACT_APP_TEST_LOGIN_USERNAME: ${REACT_APP_TEST_LOGIN_USERNAME}"
echo "REACT_APP_TEST_LOGIN_PASSWORD: ${REACT_APP_TEST_LOGIN_PASSWORD}"

Length of output: 145


Script:

#!/bin/bash
# Search for references to the environment variables in the codebase
rg 'REACT_APP_TEST_LOGIN_USERNAME'
rg 'REACT_APP_TEST_LOGIN_PASSWORD'

Length of output: 335

http-gateway/web/packages/mock-server/src/routes/snippet-service.js (1)

16-20: Replace console log with proper logging.

Using console.log for logging is not recommended for production code. Consider using a proper logging framework.

-  console.log('===== RESET CONFIGURATION API RESET')
+  // Use a logging framework like winston or bunyan
+  logger.info('===== RESET CONFIGURATION API RESET')
http-gateway/web/packages/mock-server/src/routes/devices.js (1)

Line range hint 10-14:
Replace console log with proper logging.

Using console.log for logging is not recommended for production code. Consider using a proper logging framework.

-  console.log('===== RESET DEVICE API RESET')
+  // Use a logging framework like winston or bunyan
+  logger.info('===== RESET DEVICE API RESET')
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 839b3d2 and 90448e1.

Files ignored due to path filters (44)
  • http-gateway/web/package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • http-gateway/web/packages/mock-server/package.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/devices/detail/9b95267d-fb80-56e4-a2af-001767c97299-signin-records.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/devices/list/list-deleted-state.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/devices/list/list.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/snippet-service/applied-configurations/detail/idFilter-79c2a88a-1244-4e8a-a526-420e6cd5d34a.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/snippet-service/applied-configurations/list/httpConfigurationIdFilter-48998f7d-2a70-46a4-8a68-745b69d55489.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/snippet-service/applied-configurations/list/list.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/snippet-service/conditions/detail/00fa41ad-b3bf-4f00-bfe1-c71c439e4cda.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/snippet-service/configurations/detail/1a53e16f-b533-4c26-9150-e2c30065ab27.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/snippet-service/configurations/detail/48998f7d-2a70-46a4-8a68-745b69d55489.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/snippet-service/configurations/list/listAdd.json is excluded by !**/*.json
  • http-gateway/web/packages/mock-server/src/data/snippet-service/configurations/list/listEmpty.json is excluded by !**/*.json
  • http-gateway/web/playwright/package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • http-gateway/web/playwright/package.json is excluded by !**/*.json
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-1-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-1-table-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-1-toggles-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-table-filter-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-table-update-modal-full-view-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-table-update-modal-open-action-button-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-table-update-modal-open-action-button-toggle-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-table-update-modal-open-action-button-toggle-open-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-table-update-modal-open-close-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-tree-open-update-modal-delete-icon-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-tree-open-update-modal-edit-icon-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-tree-open-update-modal-href-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-tree-open-update-modal-toggle-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-tree-open-update-modal-toggle-delete-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-view-switch-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-wot-resource-form-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-2-wot-resource-simple-form-update-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/device-detail-tab-3-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/devices-detail-delete-device-close-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/detail.spec.ts-snapshots/devices-detail-edit-name-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/devices/list.spec.ts-snapshots/devices-list-open-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/snippet-service/configurations/detail.spec.ts-snapshots/snippet-service-configurations-detail-delete-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/snippet-service/configurations/detail.spec.ts-snapshots/snippet-service-configurations-detail-tab-applied-configurations-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/snippet-service/configurations/detail.spec.ts-snapshots/snippet-service-configurations-detail-tab-conditions-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/snippet-service/configurations/list.spec.ts-snapshots/add-configuration-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/snippet-service/configurations/list.spec.ts-snapshots/add-configuration-reset-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/snippet-service/configurations/list.spec.ts-snapshots/list-invoke-modal-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • http-gateway/web/playwright/tests/snippet-service/configurations/list.spec.ts-snapshots/snippet-service-configurations-list-open-1-chromium-darwin.png is excluded by !**/*.png, !**/*.png
Files selected for processing (28)
  • http-gateway/web/packages/mock-server/src/index.js (3 hunks)
  • http-gateway/web/packages/mock-server/src/routes/devices.js (3 hunks)
  • http-gateway/web/packages/mock-server/src/routes/snippet-service.js (1 hunks)
  • http-gateway/web/packages/shared-ui (1 hunks)
  • http-gateway/web/playwright/global-setup.ts (2 hunks)
  • http-gateway/web/playwright/playwright.config.ts (2 hunks)
  • http-gateway/web/playwright/tests/devices/detail.spec.ts (20 hunks)
  • http-gateway/web/playwright/tests/devices/list.spec.ts (1 hunks)
  • http-gateway/web/playwright/tests/login.spec.ts (1 hunks)
  • http-gateway/web/playwright/tests/logout.spec.ts (1 hunks)
  • http-gateway/web/playwright/tests/snippet-service/configurations/detail.spec.ts (1 hunks)
  • http-gateway/web/playwright/tests/snippet-service/configurations/list.spec.ts (1 hunks)
  • http-gateway/web/playwright/tests/utils.ts (1 hunks)
  • http-gateway/web/src/containers/Common/DetailHeaderLayout/DetailHeaderLayout.tsx (1 hunks)
  • http-gateway/web/src/containers/Common/DetailHeaderLayout/DetailHeaderLayout.types.ts (1 hunks)
  • http-gateway/web/src/containers/Common/PageListTemplate/PageListTemplate.tsx (1 hunks)
  • http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/Tabs/Tab2/Tab2.tsx (1 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/AddPage/AddPage.tsx (2 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/DetailHeader.tsx (2 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/DetailPage.tsx (1 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/JsonConfigModal.tsx (5 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab1/Tab1.tsx (6 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab2/Tab2.tsx (3 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab3/Tab3.tsx (5 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/InvokeModal/InvokeModal.tsx (6 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/InvokeModal/InvokeModal.types.ts (1 hunks)
  • http-gateway/web/src/containers/SnippetService/Configurations/ListPage/ListPage.tsx (2 hunks)
  • http-gateway/web/src/testId.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • http-gateway/web/packages/shared-ui
Additional context used
GitHub Check: CodeQL
http-gateway/web/packages/mock-server/src/routes/devices.js

[warning] 162-162: Exception text reinterpreted as HTML
Exception text is reinterpreted as HTML without escaping meta-characters.

Additional comments not posted (102)
http-gateway/web/src/containers/SnippetService/Configurations/InvokeModal/InvokeModal.types.ts (2)

2-2: LGTM! Addition of dataTestId is appropriate.

The optional dataTestId property is a good addition for testing purposes.


5-5: Remove the duplicated show property.

The show property is duplicated in the type definition. Remove the duplicate to ensure type correctness.

-    handleInvoke: (name: string[], force: boolean) => void
-    show: boolean
+    handleInvoke: (name: string[], force: boolean) => void

Likely invalid or redundant comment.

http-gateway/web/src/containers/Common/DetailHeaderLayout/DetailHeaderLayout.types.ts (1)

26-26: New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.

Verification successful

New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.


New property deleteModal added to Props.

The addition of the deleteModal property looks good. Ensure that this new property is correctly used and tested in the codebase.



New property deleteModal added to Props.

The addition of the deleteModal property looks good. It is correctly used and tested in the codebase.

  • http-gateway/web/src/testId.ts
  • http-gateway/web/src/containers/Common/PageListTemplate/PageListTemplate.types.ts
  • http-gateway/web/src/containers/Common/DetailHeaderLayout/DetailHeaderLayout.types.ts
  • http-gateway/web/playwright/tests/snippet-service/configurations/detail.spec.ts
  • http-gateway/web/playwright/tests/devices/detail.spec.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg --type typescript 'deleteModal'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the new property `deleteModal` in the codebase.

# Test: Search for the usage of `deleteModal`. Expect: Occurrences in relevant files.
rg 'deleteModal' --glob '*.ts'

Length of output: 1311

http-gateway/web/playwright/tests/devices/list.spec.ts (3)

8-8: Set viewport size before interacting with elements.

Setting the viewport size before interacting with elements ensures consistent test results across different environments. This is a good practice.


11-11: Update screenshot expectations.

Disabling animations in screenshot expectations helps in achieving more accurate and consistent test results. This is a good practice.


16-16: Set viewport size before interacting with elements.

Setting the viewport size before interacting with elements ensures consistent test results across different environments. This is a good practice.

http-gateway/web/playwright/global-setup.ts (4)

2-2: Import login from ./tests/utils.

The import statement for login is correctly added. This allows for a more modular and reusable authentication process.


16-16: Replace page.goto with login(page).

Replacing the direct page.goto call with login(page) centralizes the authentication logic, making the code more maintainable and reusable.


18-19: Fetch version data from GitHub API.

Fetching version data from the GitHub API and storing it in local storage ensures that the application always has the latest version information. This is a good practice.


27-40: Update local storage with version data.

Updating local storage with the fetched version data ensures that the application state is consistent with the latest version information. This is a good practice.

http-gateway/web/packages/mock-server/src/index.js (5)

5-5: Add body-parser middleware.

Adding body-parser middleware for parsing urlencoded requests ensures that the server can handle form submissions correctly.


13-14: Introduce versionData for caching.

Introducing versionData for caching the GitHub API response helps in reducing the number of API calls and improves the performance of the mock server.


15-15: Use dotenv for environment configuration.

Using dotenv for environment configuration ensures that sensitive information, such as API tokens, can be managed securely.


24-24: Add body-parser middleware.

Adding body-parser middleware for parsing urlencoded requests ensures that the server can handle form submissions correctly.


58-71: Cache and reuse versionData.

Caching and reusing versionData if available helps in reducing the number of API calls and improves the performance of the mock server.

http-gateway/web/src/containers/Common/DetailHeaderLayout/DetailHeaderLayout.tsx (1)

48-48: LGTM! Verify the usage of dataTestId in tests.

The addition of dataTestId enhances the testability of the DeleteModal component.

Ensure that the dataTestId prop is correctly used in the Playwright tests.

http-gateway/web/playwright/playwright.config.ts (2)

19-19: LGTM! Verify the usage of toHaveScreenshot.

The addition of toHaveScreenshot with maxDiffPixels parameter enhances the screenshot comparison capabilities.

Ensure that the toHaveScreenshot method is correctly used in the Playwright tests.

Verification successful

Verified: The toHaveScreenshot method is used correctly in the Playwright tests.

The method is integrated and utilized extensively across multiple test files, confirming its proper usage.

  • http-gateway/web/playwright/tests/devices/list.spec.ts
  • http-gateway/web/playwright/tests/devices/detail.spec.ts
  • http-gateway/web/playwright/tests/snippet-service/configurations/list.spec.ts
  • http-gateway/web/playwright/tests/snippet-service/configurations/detail.spec.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `toHaveScreenshot` in the Playwright tests.

# Test: Search for `toHaveScreenshot` in the Playwright tests. Expect: Usage of `toHaveScreenshot` in the tests.
rg --type js --type ts --type tsx 'toHaveScreenshot'

Length of output: 80


Script:

#!/bin/bash
# Description: Verify the usage of `toHaveScreenshot` in the Playwright tests.

# Test: Search for `toHaveScreenshot` in the Playwright tests. Expect: Usage of `toHaveScreenshot` in the tests.
rg --type js --type ts 'toHaveScreenshot'

Length of output: 4834


39-42: LGTM! Verify the impact of updated viewport settings.

The updated viewport settings ensure consistent test execution across different screen sizes.

Ensure that the updated viewport settings do not negatively impact the existing tests.

http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/DetailHeader.tsx (2)

82-82: LGTM! Verify the usage of dataTestId in tests.

The addition of dataTestId enhances the testability of the delete modal component.

Ensure that the dataTestId attribute is correctly used in the Playwright tests.


38-38: LGTM! Verify the usage of dataTestId in tests.

The addition of dataTestId enhances the testability of the button component.

Ensure that the dataTestId attribute is correctly used in the Playwright tests.

http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab2/Tab2.tsx (2)

92-92: LGTM! Verify the usage of dataTestId in tests.

The addition of dataTestId enhances the testability of the <Table> component.

Ensure that the dataTestId attribute is correctly used in the Playwright tests.


66-66: LGTM! Verify the usage of dataTestId in tests.

The addition of dataTestId enhances the testability of the button component.

Ensure that the dataTestId attribute is correctly used in the Playwright tests.

http-gateway/web/packages/mock-server/src/routes/snippet-service.js (4)

53-61: LGTM!

The parseFilters function is correctly implemented.


90-94: LGTM!

The router.delete('/api/v1/configurations') function is correctly implemented.


112-115: LGTM!

The router.post('/api/v1/configurations/:configurationId') function is correctly implemented.


121-124: LGTM!

The router.put('/api/v1/configurations/:configurationId') function is correctly implemented.

http-gateway/web/packages/mock-server/src/routes/devices.js (14)

32-35: LGTM!

The router.get('/api/v1/devices') function is correctly implemented.


Line range hint 38-42:
LGTM!

The router.delete('/api/v1/devices') function is correctly implemented.


Line range hint 45-48:
LGTM!

The router.get('/api/v1/devices/:deviceId') function is correctly implemented.


Line range hint 51-54:
LGTM!

The router.get('/api/v1/devices/:deviceId/pending-commands') function is correctly implemented.


Line range hint 57-60:
LGTM!

The router.get('/api/v1/devices/:deviceId/resources') function is correctly implemented.


Line range hint 63-66:
LGTM!

The router.put('/api/v1/devices/:deviceId/metadata') function is correctly implemented.


Line range hint 69-72:
LGTM!

The router.put('/api/v1/devices/:deviceId/resources/oc/con') function is correctly implemented.


Line range hint 75-78:
LGTM!

The router.get('/api/v1/devices/:deviceId/resources/light/1') function is correctly implemented.


Line range hint 81-84:
LGTM!

The router.put('/api/v1/devices/:deviceId/resources/light/1') function is correctly implemented.


Line range hint 87-90:
LGTM!

The router.get('/api/v1/devices/:deviceId/resources/.well-known/wot') function is correctly implemented.


Line range hint 93-99:
LGTM!

The router.get('/api/v1/devices/:deviceId/resources/color') function is correctly implemented.


Line range hint 102-107:
LGTM!

The router.put('/api/v1/devices/:deviceId/resources/color') function is correctly implemented.


155-160: LGTM!

The router.get('/api/v1/resource-links') function is correctly implemented.


166-171: LGTM!

The router.get('/api/v1/signing/records') function is correctly implemented.

http-gateway/web/playwright/tests/snippet-service/configurations/list.spec.ts (5)

4-11: LGTM!

The function snippet-service-configurations-list-open is correctly implemented and verifies the page title and screenshot.


13-23: LGTM!

The function fillAddForm is correctly implemented and verifies the form and modal interactions.


26-47: LGTM!

The function add-configuration-reset is correctly implemented and verifies the reset functionality of the add configuration form.


49-61: LGTM!

The function add-configuration-save is correctly implemented and verifies the save functionality of the add configuration form.


63-108: LGTM!

The function list-invoke-modal is correctly implemented and verifies the invoke modal functionality.

http-gateway/web/src/containers/SnippetService/Configurations/ListPage/ListPage.tsx (2)

Line range hint 125-129: LGTM!

The dataTestId prop for the add configuration button is correctly implemented.


159-164: LGTM!

The dataTestId prop for the invoke modal is correctly implemented.

http-gateway/web/src/containers/SnippetService/Configurations/AddPage/AddPage.tsx (2)

Line range hint 141-148: LGTM!

The dataTestId prop for the primary button is correctly implemented.


152-157: LGTM!

The dataTestId prop for the secondary button is correctly implemented.

http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/JsonConfigModal.tsx (5)

1-1: LGTM!

The addition of useMemo to the import statement is correctly implemented.


19-19: LGTM!

The import of hasInvalidConfigurationResource from @/containers/SnippetService/utils is correctly implemented.


55-55: LGTM!

The modification to handleOnEditorChange to set jsonData to an empty string if json is falsy is correctly implemented.


94-100: LGTM!

The enhancement of the FormInput component with additional props like dataTestId is correctly implemented.


159-162: LGTM!

The introduction of the hasInvalidResource constant using useMemo to check for invalid resource configurations is correctly implemented.

http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab3/Tab3.tsx (5)

26-26: Import statement is correct.

The import statement for testId is correctly added.


48-48: data-test-id attribute is correctly added.

The data-test-id attribute in the anchor tag follows the naming convention and is correctly added.


98-98: dataTestId attribute is correctly added.

The dataTestId attribute in the Tag component follows the naming convention and is correctly added.


122-122: dataTestId attribute is correctly added.

The dataTestId attribute in the TableActionButton component follows the naming convention and is correctly added.


152-152: dataTestId attribute is correctly added.

The dataTestId attribute in the Table component follows the naming convention and is correctly added.

http-gateway/web/src/testId.ts (3)

97-105: addPage object is correctly added.

The addPage object with form-related identifiers follows the existing structure and naming conventions.


109-110: Identifiers in the list section are correctly added.

The addConfigurationButton and invokeModal identifiers follow the existing structure and naming conventions.


120-126: Identifiers in the detail section are correctly added.

The invokeButton, invokeModal, deleteModal, saveButton, resetButton, conditionsTable, and appliedConfigurationsTable identifiers follow the existing structure and naming conventions.

http-gateway/web/playwright/tests/snippet-service/configurations/detail.spec.ts (5)

1-12: Import statements and openConfigurationItem function are correct.

The import statements and openConfigurationItem function are correctly added and logically consistent.


14-26: snippet-service-configurations-detail-version test case is correct.

The test case correctly checks the version selector functionality using Playwright assertions.


28-53: snippet-service-configurations-detail-invoke test case is correct.

The test case correctly checks the invoke functionality using Playwright assertions.


55-75: snippet-service-configurations-detail-delete test case is correct.

The test case correctly checks the delete functionality using Playwright assertions.


77-163: Test cases are correct.

The snippet-service-configurations-detail-update-fields, snippet-service-configurations-detail-tab-conditions, and snippet-service-configurations-detail-tab-applied-configurations test cases correctly check the respective functionalities using Playwright assertions.

http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/Tabs/Tab1/Tab1.tsx (5)

28-28: Import statement is correct.

The import statement for testId is correctly added.


117-126: dataTestId attributes in TableActionButton are correctly added.

The dataTestId attributes in the TableActionButton component follow the naming convention and are correctly added.


153-158: dataTestId attribute in FormInput is correctly added.

The dataTestId attribute in the FormInput component follows the naming convention and is correctly added.


167-172: dataTestId attribute in Button is correctly added.

The dataTestId attribute in the Button component follows the naming convention and is correctly added.


Line range hint 182-201: dataTestId attributes in Table and JsonConfigModal are correctly added.

The dataTestId attributes in the Table and JsonConfigModal components follow the naming convention and are correctly added.

http-gateway/web/src/containers/SnippetService/Configurations/DetailPage/DetailPage.tsx (3)

254-261: LGTM! Ensure dataTestId is used consistently.

The addition of dataTestId prop improves testability. The props structure adjustment enhances readability.

Verify that dataTestId is used consistently across the codebase.


266-271: LGTM! Ensure dataTestId is used consistently.

The addition of dataTestId prop improves testability. The props structure adjustment enhances readability.

Verify that dataTestId is used consistently across the codebase.


243-248: LGTM! Ensure dataTestId is used consistently.

The addition of dataTestId prop improves testability. The props structure adjustment enhances readability.

Verify that dataTestId is used consistently across the codebase.

Verification successful

LGTM! Ensure dataTestId is used consistently.

The addition of dataTestId prop improves testability. The props structure adjustment enhances readability. The usage of dataTestId is consistent across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistent usage of `dataTestId` across the codebase.

# Test: Search for the usage of `dataTestId`. Expect: Consistent usage across the codebase.
rg --type js --type ts --type jsx --type tsx 'dataTestId'

Length of output: 85


Script:

#!/bin/bash
# Description: Verify the consistent usage of `dataTestId` across the codebase.

# Test: Search for the usage of `dataTestId`. Expect: Consistent usage across the codebase.
rg --type js --type ts --type tsx 'dataTestId'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the consistent usage of `dataTestId` across the codebase.

# Test: Search for the usage of `dataTestId`. Expect: Consistent usage across the codebase.
rg --type js --type ts 'dataTestId'

Length of output: 18064

http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/Tabs/Tab2/Tab2.tsx (1)

242-244: LGTM! The added logging statements are helpful for debugging.

The logging statements provide useful information before calling the updateDevicesResourceApi function.

http-gateway/web/playwright/tests/devices/detail.spec.ts (13)

5-8: LGTM! The additional steps in openDevice function improve test setup.

The added steps ensure that the device page is properly set up before interacting with elements.


18-18: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and active state of various elements.


31-31: LGTM! The updated test improves coverage.

The new expectations and interactions verify the state of toggle elements and their interactions.


57-57: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with modal elements.


72-72: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with the edit name modal.


98-98: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with the delete device modal.


137-137: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with the delete device modal.


137-137: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and active state of the resources tab.


152-152: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with the filter input and table rows.


163-163: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with the update modal.


188-188: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with the update modal in full view.


222-222: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with the update modal and editor.


329-329: LGTM! The updated test improves coverage.

The new expectations and interactions verify the visibility and interactions with the tree view and update modal.

http-gateway/web/src/containers/Common/PageListTemplate/PageListTemplate.tsx (3)

84-87: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component. The addition of the IconIntegrations icon enhances the user interface by providing a visual cue for the invoke action.


92-95: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component. The addition of the IconTrash icon enhances the user interface by providing a visual cue for the delete action.


98-101: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component. The addition of the IconArrowDetail icon enhances the user interface by providing a visual cue for the view action.

http-gateway/web/src/containers/SnippetService/Configurations/InvokeModal/InvokeModal.tsx (10)

18-18: Import truncate for truncating device names.

The import statement for truncate from @shared-ui/common/utils is correct and necessary for the new functionality.


21-21: Destructure dataTestId from props.

Destructuring dataTestId from the props object is necessary for adding test identifiers to various elements in the component.


32-35: Truncate device names for better display.

Using truncate to limit the length of device names ensures that the UI remains clean and readable, especially when dealing with long device names.


48-48: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component.


51-51: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component.


59-59: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component.


108-108: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component.


124-124: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component.


127-127: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component.


136-136: Add dataTestId for better testability.

Adding dataTestId properties improves the testability of the component.

// await page.locator('#password').fill(process.env.REACT_APP_TEST_LOGIN_PASSWORD || '')
//
// await page.getByRole('button', { name: 'Sign In' }).click()
// await login(page)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or re-enable the commented-out test step.

The test step for the login action is commented out. If this step is necessary, re-enable it. Otherwise, remove it.

- // await login(page)
+ await login(page)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// await login(page)
await login(page)

import { test, expect } from '@playwright/test'
import { test } from '@playwright/test'
// import { login } from './utils'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or re-enable the commented-out import.

The import statement for login is commented out. If login is not needed, remove the import. Otherwise, re-enable it.

- // import { login } from './utils'
+ import { login } from './utils'
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// import { login } from './utils'
import { login } from './utils'

Comment on lines +5 to +9
// await page.goto('http://localhost:3000/')
//
// await page.getByTestId(testId.app.logout).click()
//
// await expect(page).toHaveTitle(/Login | plgd.dev/)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or re-enable the commented-out test steps.

The test steps for the logout action are commented out. If these steps are necessary, re-enable them. Otherwise, remove them.

-    // await page.goto('http://localhost:3000/')
-    //
-    // await page.getByTestId(testId.app.logout).click()
-    //
-    // await expect(page).toHaveTitle(/Login | plgd.dev/)
+    await page.goto('http://localhost:3000/')
+
+    await page.getByTestId(testId.app.logout).click()
+
+    await expect(page).toHaveTitle(/Login | plgd.dev/)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// await page.goto('http://localhost:3000/')
//
// await page.getByTestId(testId.app.logout).click()
//
// await expect(page).toHaveTitle(/Login | plgd.dev/)
await page.goto('http://localhost:3000/')
await page.getByTestId(testId.app.logout).click()
await expect(page).toHaveTitle(/Login | plgd.dev/)

Comment on lines +100 to +104
router.post('/api/v1/configurations', (req, res) => {
try {
checkError(req, res)

configurationsAdd = this
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the syntax error.

The configurationsAdd flag is incorrectly set. It should be set to true.

-  configurationsAdd = this
+  configurationsAdd = true
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
router.post('/api/v1/configurations', (req, res) => {
try {
checkError(req, res)
configurationsAdd = this
router.post('/api/v1/configurations', (req, res) => {
try {
checkError(req, res)
configurationsAdd = true

Comment on lines +30 to +35

router.get('/api/v1/configurations/applied', (req, res) => {
try {
checkError(req, res)
const httpConfigurationIdFilter = get(req.query, 'httpConfigurationIdFilter', null)?.replace('/all', '')
const idFilter = get(req.query, 'idFilter', null)?.replace('/all', '')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor query parameter extraction for better readability.

The extraction of httpConfigurationIdFilter and idFilter can be refactored for better readability.

-  const httpConfigurationIdFilter = get(req.query, 'httpConfigurationIdFilter', null)?.replace('/all', '')
-  const idFilter = get(req.query, 'idFilter', null)?.replace('/all', '')
+  const extractFilter = (query, key) => get(query, key, null)?.replace('/all', '')
+  const httpConfigurationIdFilter = extractFilter(req.query, 'httpConfigurationIdFilter')
+  const idFilter = extractFilter(req.query, 'idFilter')
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
router.get('/api/v1/configurations/applied', (req, res) => {
try {
checkError(req, res)
const httpConfigurationIdFilter = get(req.query, 'httpConfigurationIdFilter', null)?.replace('/all', '')
const idFilter = get(req.query, 'idFilter', null)?.replace('/all', '')
const extractFilter = (query, key) => get(query, key, null)?.replace('/all', '')
const httpConfigurationIdFilter = extractFilter(req.query, 'httpConfigurationIdFilter')
const idFilter = extractFilter(req.query, 'idFilter')

Comment on lines +62 to +70

router.get('/api/v1/configurations', (req, res) => {
try {
checkError(req, res)
const filter = get(req.query, 'httpIdFilter', null)?.replace('/all', '')

let filter = parseFilters(req.query, 'httpIdFilter')
if (Array.isArray(filter)) {
filter = filter[0]
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor query parameter extraction for better readability.

The extraction of httpIdFilter can be refactored for better readability.

-  let filter = parseFilters(req.query, 'httpIdFilter')
-  if (Array.isArray(filter)) {
-      filter = filter[0]
-  }
+  const filter = Array.isArray(parseFilters(req.query, 'httpIdFilter')) 
+    ? parseFilters(req.query, 'httpIdFilter')[0] 
+    : parseFilters(req.query, 'httpIdFilter')
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
router.get('/api/v1/configurations', (req, res) => {
try {
checkError(req, res)
const filter = get(req.query, 'httpIdFilter', null)?.replace('/all', '')
let filter = parseFilters(req.query, 'httpIdFilter')
if (Array.isArray(filter)) {
filter = filter[0]
}
router.get('/api/v1/configurations', (req, res) => {
try {
checkError(req, res)
const filter = Array.isArray(parseFilters(req.query, 'httpIdFilter'))
? parseFilters(req.query, 'httpIdFilter')[0]
: parseFilters(req.query, 'httpIdFilter')

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 90448e1 and 296f824.

Files ignored due to path filters (1)
  • http-gateway/web/playwright/package.json is excluded by !**/*.json
Files selected for processing (1)
  • http-gateway/web/packages/mock-server/src/routes/snippet-service.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • http-gateway/web/packages/mock-server/src/routes/snippet-service.js

@PatrikMatiasko PatrikMatiasko merged commit f3fb39b into main Jul 23, 2024
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants