Hu-Fi / Mr.Market

Mr. Market is the exchange oracle of HuFi, and a CeFi crypto bot on Mixin Messenger
https://mr-market-one.vercel.app
GNU Affero General Public License v3.0
1 stars 6 forks source link

move to local backend for tests #55

Closed posix4e closed 7 months ago

posix4e commented 7 months ago

Type

enhancement, tests, documentation


Description


Changes walkthrough

Relevant files
Enhancement
5 files
playwright.config.ts
Enhance Playwright Test Configuration                                       

interface/playwright.config.ts
  • Increased default timeout for Playwright tests to 5000ms.
  • Added ignoreHTTPSErrors to Playwright webServer configuration.
  • +2/-0     
    constants.ts
    Load Constants from Environment Variables                               

    interface/src/lib/helpers/constants.ts
  • Changed constants to load from environment variables.
  • Updated AppName and AppURL to new values and made other constants
    dynamic.
  • +16/-16 
    trade.service.ts
    Simplify Order Cancellation Logging                                           

    server/src/modules/trade/trade.service.ts - Simplified order cancellation logging.
    +1/-2     
    playwright.yml
    Integrate PostgreSQL and Improve CI Workflow                         

    .github/workflows/playwright.yml
  • Added PostgreSQL service for GitHub Actions.
  • Updated Node.js version to 20.
  • Added steps to wait for the local server to become available before
    running tests.
  • +51/-11 
    tsconfig.json
    Update TypeScript Configuration                                                   

    interface/tsconfig.json - Included `.svelte-kit/ambient.d.ts` in TypeScript configuration.
    +1/-1     
    Tests
    4 files
    coin.test.ts
    Mock Environment Variables in Tests                                           

    interface/src/lib/helpers/hufi/coin.test.ts - Mocked environment variables for tests.
    +8/-2     
    grow.spec.ts
    Skip Slow Navigation Test in Grow Module                                 

    interface/tests/grow/grow.spec.ts - Skipped slow navigation test.
    +2/-1     
    home.spec.ts
    Skip Tests in Home Module                                                               

    interface/tests/home/home.spec.ts - Skipped several tests due to slowness and backend dependency.
    +17/-13 
    homeBar.svelte
    Add Test ID to News Button                                                             

    interface/src/lib/components/topBar/homeBar.svelte - Added `data-testid` attribute to the news button for testing.
    +1/-1     
    Documentation
    1 files
    .env.example
    Add Example Environment Variables                                               

    interface/.env.example - Added example environment variables.
    +9/-0     

    PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    vercel[bot] commented 7 months ago

    The latest updates on your projects. Learn more about Vercel for Git ↗︎

    Name Status Preview Comments Updated (UTC)
    mr-market ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2024 2:01am
    github-actions[bot] commented 7 months ago

    PR Description updated to latest commit (https://github.com/Hu-Fi/Mr.Market/commit/7b2a8e71f4aebbaef56d4a8ea080281ec0ad6bd0)

    github-actions[bot] commented 7 months ago

    PR Description updated to latest commit (https://github.com/Hu-Fi/Mr.Market/commit/7b2a8e71f4aebbaef56d4a8ea080281ec0ad6bd0)

    github-actions[bot] commented 7 months ago

    PR Review

    (Review updated until commit https://github.com/Hu-Fi/Mr.Market/commit/f257836b9042ddd4d094c78e946413f07c0b9b2b)

    ⏱️ Estimated effort to review [1-5] 3, because the PR includes a variety of changes across multiple files, including configuration updates, test modifications, and code enhancements. The changes involve different aspects such as backend service configuration, frontend logic, and testing strategies which require a careful review to ensure they work together seamlessly and do not introduce regressions.
    🧪 Relevant tests Yes
    🔍 Possible issues Possible Bug: Skipping tests in `grow` and `home` modules might hide potential issues in the future. Consider finding a way to optimize these tests instead of skipping them.
    Performance Concern: Increasing the default timeout for Playwright tests to 5000ms might indicate underlying performance issues in the application that should be addressed.
    🔒 Security concerns No
    Code feedback:
    relevant fileinterface/playwright.config.ts
    suggestion       Consider making the `timeout` and `ignoreHTTPSErrors` configurable through environment variables or configuration files. This will provide flexibility in different environments without changing the code. [important]
    relevant linetimeout: 5000,

    relevant fileinterface/src/lib/helpers/constants.ts
    suggestion       Ensure that the fallback values for environment variables (e.g., `PUBLIC_APP_URL`, `PUBLIC_SHOW_BAR`) are sensible defaults that do not expose the application to using incorrect configurations in production. [important]
    relevant lineexport const AppURL = env.PUBLIC_APP_URL || "https://mr-market-one.vercel.app"

    relevant fileserver/src/modules/trade/trade.service.ts
    suggestion       After canceling an order, consider verifying that the cancellation was successful before updating the trade status in the database. This adds an extra layer of reliability to the process. [medium]
    relevant lineawait this.exchange.cancelOrder(orderId, symbol);

    relevant file.github/workflows/playwright.yml
    suggestion       Add a step to verify the connection to the PostgreSQL service before proceeding with tests. This ensures that the database is ready and can prevent false negatives in CI runs. [medium]
    relevant lineoptions: >-


    ✨ Review tool usage guide:
    **Overview:** The `review` tool scans the PR code changes, and generates a PR review. The tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on any PR. When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L19) related to the review tool (`pr_reviewer` section), use the following template: ``` /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=... ``` With a [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template: ``` [pr_reviewer] some_config1=... some_config2=... ```
    Utilizing extra instructions
    The `review` tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project. Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize. Examples for extra instructions: ``` [pr_reviewer] # /review # extra_instructions=""" In the 'possible issues' section, emphasize the following: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? - Is the code logic efficient? ... """ ``` Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.
    How to enable\disable automation
    - When you first install PR-Agent app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the `review` tool is: ``` pr_commands = ["/review", ...] ``` meaning the `review` tool will run automatically on every PR, with the default configuration. Edit this field to enable/disable the tool, or to change the used configurations
    Auto-labels
    The `review` tool can auto-generate two specific types of labels for a PR: - a `possible security issue` label, that detects possible [security issues](https://github.com/Codium-ai/pr-agent/blob/tr/user_description/pr_agent/settings/pr_reviewer_prompts.toml#L136) (`enable_review_labels_security` flag) - a `Review effort [1-5]: x` label, where x is the estimated effort to review the PR (`enable_review_labels_effort` flag)
    Extra sub-tools
    The `review` tool provides a collection of possible feedbacks about a PR. It is recommended to review the [possible options](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md#enabledisable-features), and choose the ones relevant for your use case. Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example: `require_score_review`, `require_soc2_ticket`, and more.
    Auto-approve PRs
    By invoking: ``` /review auto_approve ``` The tool will automatically approve the PR, and add a comment with the approval. To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following: ``` [pr_reviewer] enable_auto_approval = true ``` (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository) You can also enable auto-approval only if the PR meets certain requirements, such as that the `estimated_review_effort` is equal or below a certain threshold, by adjusting the flag: ``` [pr_reviewer] maximal_review_effort = 5 ```
    More PR-Agent commands
    > To invoke the PR-Agent, add a comment using one of the following commands: > - **/review**: Request a review of your Pull Request. > - **/describe**: Update the PR title and description based on the contents of the PR. > - **/improve [--extended]**: Suggest code improvements. Extended mode provides a higher quality feedback. > - **/ask \**: Ask a question about the PR. > - **/update_changelog**: Update the changelog based on the PR's contents. > - **/add_docs** 💎: Generate docstring for new components introduced in the PR. > - **/generate_labels** 💎: Generate labels for the PR based on the PR's contents. > - **/analyze** 💎: Automatically analyzes the PR, and presents changes walkthrough for each component. >See the [tools guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To list the possible configuration parameters, add a **/config** comment.
    See the [review usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md) page for a comprehensive guide on using this tool.
    github-actions[bot] commented 7 months ago

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Enhancement
    Add error logging within the catch block for better error tracking. ___ **Consider adding error logging within the catch block to ensure that any issues encountered
    during the order cancellation process are properly logged. This will help in diagnosing
    issues in production.** [server/src/modules/trade/trade.service.ts [143]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-4432350be63f9e2463145381a3748ee74fcf5656391b0269244b96a3bd55bd3eR143-R143) ```diff } catch (error) { + this.logger.error(`Error cancelling order: ${orderId}`, error); ```
    Use wait-on for a more reliable way to wait for the server to start in CI. ___ **Instead of manually waiting for the server to start using a loop and curl, consider using
    a more robust solution like wait-on npm package. This can help reduce flakiness in CI runs
    and make the script more readable.** [.github/workflows/playwright.yml [48-68]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R48-R68) ```diff - name: Wait for localhost:3000 to become available run: | cd server yarn start & cd ../interface - echo "Waiting for localhost:3000 to become available..." - attempt=1 - max_attempts=3 - while [ $attempt -le $max_attempts ]; do - echo "Attempt $attempt of $max_attempts" - if $(curl --output /dev/null --silent --head --fail http://localhost:3000); then - echo "localhost:3000 is now available." - break - fi - attempt=$((attempt+1)) - sleep 5 - done - if [ $attempt -gt $max_attempts ]; then - echo "Failed to connect to localhost:3000 after $max_attempts attempts." - exit 1 - fi + npx wait-on http://localhost:3000 npx playwright test --project='chromium' ```
    Best practice
    Pin the PostgreSQL image to a specific version for consistent test environments. ___ **Consider pinning the PostgreSQL image to a specific version instead of using latest. Using
    a specific version ensures that your tests run consistently across different environments
    and over time.** [.github/workflows/playwright.yml [14]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R14-R14) ```diff -image: postgres:latest +image: postgres:12.3 ```
    Ensure Node.js version consistency between development and CI environments. ___ **Update the Node.js version to match the version used in your development environment to
    ensure consistency between development and CI environments. If your development
    environment uses Node.js version 18, consider using that version here as well.** [.github/workflows/playwright.yml [37]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R37-R37) ```diff -node-version: 20 +node-version: 18 ```
    Specify resource limits for the PostgreSQL service in CI to prevent resource contention. ___ **Consider specifying resource limits for the PostgreSQL service to avoid potential resource
    contention on the CI runner. This can help ensure that your CI pipeline runs more reliably
    by preventing the database from consuming too many resources.** [.github/workflows/playwright.yml [12-26]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R12-R26) ```diff services: postgres: image: postgres:latest env: POSTGRES_DB: postgres POSTGRES_PASSWORD: postgres POSTGRES_USER: postgres ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + resources: + limits: + cpus: '0.5' + memory: 500M ```

    ✨ Improve tool usage guide:
    **Overview:** The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on a PR. When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L69) related to the improve tool (`pr_code_suggestions` section), use the following template: ``` /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... ``` With a [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template: ``` [pr_code_suggestions] some_config1=... some_config2=... ```
    Enabling\disabling automation
    When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the improve tool is: ``` pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...] ``` meaning the `improve` tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.
    Utilizing extra instructions
    Extra instructions are very important for the `improve` tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project. Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on. Examples for extra instructions: ``` [pr_code_suggestions] # /improve # extra_instructions=""" Emphasize the following aspects: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? - Is the code logic efficient? ... """ ``` Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.
    A note on code suggestions quality
    - While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically. - Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base. - Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the [custom suggestions :gem:](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) tool - With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands
    > To invoke the PR-Agent, add a comment using one of the following commands: > - **/review**: Request a review of your Pull Request. > - **/describe**: Update the PR title and description based on the contents of the PR. > - **/improve [--extended]**: Suggest code improvements. Extended mode provides a higher quality feedback. > - **/ask \**: Ask a question about the PR. > - **/update_changelog**: Update the changelog based on the PR's contents. > - **/add_docs** 💎: Generate docstring for new components introduced in the PR. > - **/generate_labels** 💎: Generate labels for the PR based on the PR's contents. > - **/analyze** 💎: Automatically analyzes the PR, and presents changes walkthrough for each component. >See the [tools guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To list the possible configuration parameters, add a **/config** comment.
    See the [improve usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/IMPROVE.md) page for a more comprehensive guide on using this tool.
    github-actions[bot] commented 7 months ago

    Persistent review updated to latest commit https://github.com/Hu-Fi/Mr.Market/commit/7b2a8e71f4aebbaef56d4a8ea080281ec0ad6bd0

    github-actions[bot] commented 7 months ago

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Enhancement
    Add error logging in the catch block for order cancellation. ___ **Consider adding error logging in the catch block to ensure that any errors during the
    order cancellation process are properly logged for debugging purposes. This can be crucial
    for maintaining and troubleshooting the application.** [server/src/modules/trade/trade.service.ts [143]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-4432350be63f9e2463145381a3748ee74fcf5656391b0269244b96a3bd55bd3eR143-R143) ```diff } catch (error) { + console.error(`Error cancelling order ${orderId} for symbol ${symbol}:`, error); ```
    Use wait-on for a more reliable way to wait for localhost:3000. ___ **Instead of manually waiting for localhost:3000 to become available, consider using a more
    robust solution like wait-on package which can be used to wait for sockets, files, HTTP(S)
    resources, and more. This approach can improve the reliability of the startup check.** [.github/workflows/playwright.yml [48-68]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R48-R68) ```diff - name: Wait for localhost:3000 to become available + run: npx wait-on http://localhost:3000 && npx playwright test --project='chromium' ```
    Best practice
    Pin the PostgreSQL image to a specific version. ___ **It's recommended to pin the PostgreSQL image to a specific version instead of using
    latest. Using a specific version ensures that the environment is consistent and
    predictable, reducing the risk of unexpected changes when the latest tag is updated.** [.github/workflows/playwright.yml [14]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R14-R14) ```diff -image: postgres:latest +image: postgres:12.8 ```
    Performance
    Reduce the health check interval for PostgreSQL to speed up startup time. ___ **Consider reducing the health-interval from 10s to a lower value, such as 5s, to speed up
    the startup time of the PostgreSQL service without significantly impacting the reliability
    of the health check.** [.github/workflows/playwright.yml [23]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R23-R23) ```diff ---health-interval 10s +--health-interval 5s ```

    ✨ Improve tool usage guide:
    **Overview:** The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on a PR. When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L69) related to the improve tool (`pr_code_suggestions` section), use the following template: ``` /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... ``` With a [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template: ``` [pr_code_suggestions] some_config1=... some_config2=... ```
    Enabling\disabling automation
    When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the improve tool is: ``` pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...] ``` meaning the `improve` tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.
    Utilizing extra instructions
    Extra instructions are very important for the `improve` tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project. Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on. Examples for extra instructions: ``` [pr_code_suggestions] # /improve # extra_instructions=""" Emphasize the following aspects: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? - Is the code logic efficient? ... """ ``` Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.
    A note on code suggestions quality
    - While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically. - Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base. - Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the [custom suggestions :gem:](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) tool - With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands
    > To invoke the PR-Agent, add a comment using one of the following commands: > - **/review**: Request a review of your Pull Request. > - **/describe**: Update the PR title and description based on the contents of the PR. > - **/improve [--extended]**: Suggest code improvements. Extended mode provides a higher quality feedback. > - **/ask \**: Ask a question about the PR. > - **/update_changelog**: Update the changelog based on the PR's contents. > - **/add_docs** 💎: Generate docstring for new components introduced in the PR. > - **/generate_labels** 💎: Generate labels for the PR based on the PR's contents. > - **/analyze** 💎: Automatically analyzes the PR, and presents changes walkthrough for each component. >See the [tools guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To list the possible configuration parameters, add a **/config** comment.
    See the [improve usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/IMPROVE.md) page for a more comprehensive guide on using this tool.
    github-actions[bot] commented 7 months ago

    PR Description updated to latest commit (https://github.com/Hu-Fi/Mr.Market/commit/f257836b9042ddd4d094c78e946413f07c0b9b2b)

    github-actions[bot] commented 7 months ago

    Persistent review updated to latest commit https://github.com/Hu-Fi/Mr.Market/commit/f257836b9042ddd4d094c78e946413f07c0b9b2b

    github-actions[bot] commented 7 months ago

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Security
    Suggest not ignoring HTTPS errors in tests to avoid masking security issues. ___ **Consider setting ignoreHTTPSErrors to false or removing it unless you have a specific
    reason to bypass HTTPS errors during testing. Ignoring HTTPS errors in tests can mask
    potential security issues that would affect users in a production environment.** [interface/playwright.config.ts [85]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-9d8633a9f644ada974751ed5e893342637115e403ee17ba32841c21d23c23164R85-R85) ```diff -ignoreHTTPSErrors: true, +ignoreHTTPSErrors: false, ```
    Enhancement
    Ensure boolean environment variables are correctly evaluated as booleans. ___ **For boolean environment variables like SHOW_BAR, explicitly check for the string 'true' to
    ensure the variable behaves as expected. Environment variables are read as strings, which
    can lead to unexpected truthy values.** [interface/src/lib/helpers/constants.ts [7]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-1d9500711f0f58654b9e0e95aa0e7fdc798a0b74f1c2310b09e52123e52d6bf2R7-R7) ```diff -export const SHOW_BAR = env.PUBLIC_SHOW_BAR || true +export const SHOW_BAR = env.PUBLIC_SHOW_BAR === 'true' || true ```
    Use wait-for-it.sh or a similar tool for more reliable service availability checks. ___ **Instead of using a while loop with a sleep command to wait for a service to become
    available, consider using a more robust tool like wait-for-it.sh or Dockerize's wait-for.
    These tools are designed to wait for a service to become available and are more reliable
    and configurable.** [.github/workflows/playwright.yml [56-64]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R56-R64) ```diff -while [ $attempt -le $max_attempts ]; do - echo "Attempt $attempt of $max_attempts" - if $(curl --output /dev/null --silent --head --fail http://localhost:3000); then - echo "localhost:3000 is now available." - break - fi - attempt=$((attempt+1)) - sleep 5 -done +./wait-for-it.sh localhost:3000 --timeout=15 -- echo "localhost:3000 is now available." ```
    Best practice
    Provide mock values for environment variables in tests for predictability. ___ **Instead of mocking the entire $env/dynamic/public module with an empty object, consider
    providing mock values for the environment variables used within your tests. This approach
    ensures your tests have more predictable behavior and closely mimic the production
    environment.** [interface/src/lib/helpers/hufi/coin.test.ts [6-10]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-c4b1b5ad4260f0ce5038c8533d8b409591a42749d3beb2a057c7d9c9eed6774cR6-R10) ```diff vi.mock('$env/dynamic/public', () => { return { - env: {} + env: { + PUBLIC_APP_URL: "https://mock-url.com", + PUBLIC_SHOW_BAR: "true", + // Add other environment variables as needed + } }; }); ```
    Use .waitForNavigation for more explicit navigation waiting in tests. ___ **Instead of using .waitForURL with a wildcard pattern, consider using .waitForNavigation
    with the expected URL or path. This method is more explicit and can improve the
    readability and reliability of your tests.** [interface/tests/home/home.spec.ts [23]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-b7ae67230e7930804f902d66271c8fc02dd2b5ace6c3be4ca54927cd52dc629fR23-R23) ```diff -await page.waitForURL('**/wallet'); +await page.waitForNavigation({ url: 'http://127.0.0.1:5173/wallet' }); ```
    Add logging for successful order cancellations for better monitoring. ___ **After canceling an order, it's a good practice to log the action for debugging and
    monitoring purposes. Consider adding a log statement to indicate the successful
    cancellation of an order.** [server/src/modules/trade/trade.service.ts [142]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-4432350be63f9e2463145381a3748ee74fcf5656391b0269244b96a3bd55bd3eR142-R142) ```diff +this.logger.log(`Order cancelled: ${orderId}`); await this.tradeRepository.updateTradeStatus(orderId, 'cancelled'); ```
    Pin the PostgreSQL image to a specific version to ensure consistent test environments. ___ **Consider pinning the PostgreSQL image to a specific version instead of using latest. Using
    a specific version ensures that your tests run consistently across different environments
    and times. This can help avoid unexpected breaks if a new version introduces breaking
    changes or behaves differently.** [.github/workflows/playwright.yml [14]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R14-R14) ```diff -image: postgres:latest +image: postgres:13 ```
    Use yarn install --frozen-lockfile for consistent dependency installation in CI/CD pipelines. ___ **It's recommended to use npm ci instead of yarn for installing dependencies in CI/CD
    pipelines when possible. npm ci will respect the package-lock.json file and install
    exactly what is specified there, ensuring consistency across installations. If your
    project uses Yarn, consider committing the yarn.lock file and using yarn install
    --frozen-lockfile for a similar effect.** [.github/workflows/playwright.yml [41]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7afcd2d8f7b49bda74843f209eefb7b2da45f7e7803bf2e4bd636699b76aa2d3R41-R41) ```diff -run: yarn +run: yarn install --frozen-lockfile ```
    Provide clear placeholder values for sensitive fields in the .env.example file. ___ **Ensure that sensitive default values are not set in the .env.example file. It's good
    practice to leave sensitive fields empty or provide placeholder values that clearly
    indicate that the user needs to fill them in with their own specific values.** [interface/.env.example [1-9]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-9fdde59ec2367f806aa977eff22f49e6354f4d191ec19836d19497775efd1384R1-R9) ```diff -PUBLIC_APP_URL='' -PUBLIC_SHOW_BAR='' -PUBLIC_BOT_ID='' -PUBLIC_OAUTH_SCOPE='' -PUBLIC_MIXIN_MESSENGER_INSTALL='' -PUBLIC_MIXIN_API_BASE_URL='' -PUBLIC_HUFI_SOCKET_URL='' -PUBLIC_HUFI_BACKEND_URL='' -PUBLIC_HUMAN_PROTOCOL_GROUP_URL='' +PUBLIC_APP_URL='' +PUBLIC_SHOW_BAR='' +PUBLIC_BOT_ID='' +PUBLIC_OAUTH_SCOPE='' +PUBLIC_MIXIN_MESSENGER_INSTALL='' +PUBLIC_MIXIN_API_BASE_URL='' +PUBLIC_HUFI_SOCKET_URL='' +PUBLIC_HUFI_BACKEND_URL='' +PUBLIC_HUMAN_PROTOCOL_GROUP_URL='' ```
    Ensure consistent use of data-testid attributes across components and establish a naming convention. ___ **Adding a data-testid attribute is useful for testing, but ensure that it's used
    consistently across all testable components. If this is the start of adopting such
    attributes, consider establishing a naming convention and documenting it for your team to
    ensure consistency and clarity in your test code.** [interface/src/lib/components/topBar/homeBar.svelte [55]](https://github.com/Hu-Fi/Mr.Market/pull/55/files#diff-7836eb6f3244c0b291af48c7c2da5967f00ce1da9b2e799bb46b5c5695fab2e0R55-R55) ```diff -

    ✨ Improve tool usage guide:
    **Overview:** The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on a PR. When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L69) related to the improve tool (`pr_code_suggestions` section), use the following template: ``` /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... ``` With a [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template: ``` [pr_code_suggestions] some_config1=... some_config2=... ```
    Enabling\disabling automation
    When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the improve tool is: ``` pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...] ``` meaning the `improve` tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.
    Utilizing extra instructions
    Extra instructions are very important for the `improve` tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project. Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on. Examples for extra instructions: ``` [pr_code_suggestions] # /improve # extra_instructions=""" Emphasize the following aspects: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? - Is the code logic efficient? ... """ ``` Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.
    A note on code suggestions quality
    - While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically. - Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base. - Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the [custom suggestions :gem:](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) tool - With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands
    > To invoke the PR-Agent, add a comment using one of the following commands: > - **/review**: Request a review of your Pull Request. > - **/describe**: Update the PR title and description based on the contents of the PR. > - **/improve [--extended]**: Suggest code improvements. Extended mode provides a higher quality feedback. > - **/ask \**: Ask a question about the PR. > - **/update_changelog**: Update the changelog based on the PR's contents. > - **/add_docs** 💎: Generate docstring for new components introduced in the PR. > - **/generate_labels** 💎: Generate labels for the PR based on the PR's contents. > - **/analyze** 💎: Automatically analyzes the PR, and presents changes walkthrough for each component. >See the [tools guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To list the possible configuration parameters, add a **/config** comment.
    See the [improve usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/IMPROVE.md) page for a more comprehensive guide on using this tool.