Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): Improve web e2e tests and move them to their directory #16842

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

svanaeinars
Copy link
Member

@svanaeinars svanaeinars commented Nov 13, 2024

Summary by CodeRabbit

  • New Features

    • Introduced end-to-end testing capabilities for the application, including tests for the homepage and search functionality.
    • Added a new Docker Compose configuration for Elasticsearch service setup.
  • Documentation

    • Updated the README.md to include a new section on E2E Testing with a "Quick Start" guide.
  • Bug Fixes

    • Removed deprecated proxy configuration file to streamline API routing.
  • Configuration Changes

    • Added a new proxy configuration that dynamically sets the API URL based on environment variables.

@svanaeinars svanaeinars requested review from a team as code owners November 13, 2024 11:16
Copy link
Contributor

coderabbitai bot commented Nov 13, 2024

Walkthrough

The pull request introduces a new Playwright configuration file and updates the project configuration for the web application. It adds end-to-end tests for various functionalities, including the homepage and search features, and introduces a Docker Compose configuration for Elasticsearch. Additionally, a new proxy configuration is implemented, replacing an old JSON file with a JavaScript module. The README file is updated to include instructions for running end-to-end tests.

Changes

File Change Summary
apps/web/playwright.config.ts New Playwright configuration file created, exporting playwrightConfig.
apps/web/project.json Added new targets: dev-services (Docker command) and e2e (Playwright executor).
apps/web/README.md New "E2E Testing" section added with "Quick Start" and "More Resources" subsections.
apps/web/e2e/homepage.spec.ts Added end-to-end tests for the homepage, validating visibility and navigation.
apps/web/e2e/search.spec.ts Introduced tests for search functionality, including result verification and navigation checks.
apps/web/e2e/sites-of-institutions.spec.ts New tests for various institutions' websites, dynamically created from an array of organizations.
apps/web/proxy.config.json Deleted proxy configuration file.
apps/web/proxy.config.ts New proxy configuration object created, exporting proxyConfig.
apps/web/server.ts Updated import statement to load proxyConfig from a JavaScript module instead of JSON.
apps/web/docker-compose.yml New Docker Compose file created for Elasticsearch service and initialization service.

Possibly related PRs

Suggested labels

automerge, deploy-feature

Suggested reviewers

  • AndesKrrrrrrrrrrr
  • robertaandersen

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 13, 2024

Datadog Report

Branch report: feat/move-and-improve-e2e-tests-web
Commit report: 5f6902f
Test service: web

✅ 0 Failed, 84 Passed, 0 Skipped, 24.9s Total Time
🔻 Test Sessions change in coverage: 1 decreased (-0.03%)

🔻 Code Coverage Decreases vs Default Branch (1)

Copy link
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: 11

🧹 Outside diff range and nitpick comments (8)
apps/web/playwright.config.ts (1)

5-9: Consider adding additional Playwright configuration options

The configuration could benefit from explicit settings for:

  • Test timeouts
  • Retry attempts for flaky tests
  • Screenshot/video capture on failure
  • Browser configurations

These settings can improve test reliability and debugging capabilities.

Example additions:

 const webConfig = createPlaywrightConfig({
   webServerUrl: 'http://localhost:4200',
   command: 'yarn dev-init web && source .env.secret && yarn dev web',
   cwd: '../../',
+  timeout: 30000,
+  retries: 2,
+  screenshot: 'only-on-failure',
+  video: 'retain-on-failure',
 })
apps/web/e2e/utils/addons.ts (1)

25-39: Improve the toBeApplication matcher implementation

The matcher could benefit from some enhancements:

Consider applying these improvements:

-  async toBeApplication(received: string | Page, applicationType = '\\w+') {
+  async toBeApplication(
+    received: string | Page,
+    applicationType = '[a-zA-Z0-9-]+',
+  ) {
     const url: string = typeof received == 'string' ? received : received.url()
     const protocol = 'https?://'
     const host = '[^/]+'
-    const applicationId = '(/(\\w|-)*)?'
+    const applicationId = '(/[a-zA-Z0-9-]+)?'
     const applicationRegExp = new RegExp(
       `^${protocol}${host}/umsoknir/${applicationType}${applicationId}$`,
     )
     const pass = applicationRegExp.test(url)
-    const message = () =>
-      `Current page is ${pass ? '' : '*not* '}an application
-       Pattern ${applicationRegExp}
-       URL is  ${url}`
+    const message = () => [
+      `Current page is ${pass ? '' : 'not '}an application`,
+      `Expected pattern: ${applicationRegExp}`,
+      `Actual URL: ${url}`,
+    ].join('\n')
     return { message, pass }
   },

Changes explained:

  1. More specific regex patterns for better validation
  2. Improved error message formatting
  3. Better type constraints for applicationType and applicationId
apps/web/e2e/smoke/search.spec.ts (2)

1-9: Consider adding explicit type imports for better type safety.

While the current imports work, explicitly importing types would improve type safety and maintainability.

import {
+ type BrowserContext,
- BrowserContext,
  expect,
  session,
  test,
  urls,
} from '@island.is/testing/e2e'

55-57: Document the reason for skipping the English search test.

The skipped test lacks implementation and documentation. Either:

  1. Remove it if it's not needed
  2. Add a TODO comment explaining why it's skipped and when it will be implemented
- test.skip('should search in Enlish', async () => {
+ // TODO: Implement English search test after the English search API is ready (ETA: Q1 2025)
+ test.skip('should search in English', async () => {
    return
  })
apps/web/e2e/smoke/sites-of-institutions.spec.ts (1)

15-21: Consider using a more descriptive type name

The type name Orgs could be more descriptive. Consider renaming it to OrganizationConfig or InstitutionTestConfig to better reflect its purpose and contents.

-type Orgs = {
+type OrganizationConfig = {
   organisationName: string
   organisationHome?: string
   enabled?: boolean
   target?: { role: GetByRoleParameters[0]; options?: GetByRoleParameters[1] }
 }
-const orgs: Orgs[] = [
+const orgs: OrganizationConfig[] = [
apps/web/e2e/smoke/homepage.spec.ts (3)

13-21: Consider improving test configuration management

The test setup could be enhanced in the following ways:

  • Move hardcoded values (homepage.json, 0103019) to configuration constants
  • Add error handling for context creation
  • Consider using environment variables for sensitive data like phone numbers
+ // Import configuration from a central location
+ import { TEST_CONFIG } from '../config'

  test.beforeAll(async ({ browser }) => {
+   try {
      context = await session({
        browser: browser,
-       storageState: 'homepage.json',
+       storageState: TEST_CONFIG.storageFiles.homepage,
        homeUrl: `${urls.islandisBaseUrl}/`,
-       phoneNumber: '0103019',
+       phoneNumber: TEST_CONFIG.testPhoneNumber,
        idsLoginOn: false,
      })
+   } catch (error) {
+     console.error('Failed to create browser context:', error)
+     throw error
+   }
  })

25-34: Enhance test robustness with better error handling

Consider adding:

  • Custom timeout configurations for slow-loading elements
  • Screenshot capture on test failure
  • Custom error messages for better debugging
  test('has expected sections @lang:is', async () => {
    const page = await context.newPage()
    await page.goto('/')
+   try {
      await expect(
        page.locator('text=Öll opinber þjónusta á einum stað'),
-     ).toBeVisible()
+     ).toBeVisible({ timeout: 10000, message: 'Main heading not visible' })
      await expect(page.locator('data-testid=home-banner')).toBeVisible()
      await expect(page.locator('data-testid=home-heading')).toBeVisible()
      await expect(page.locator('data-testid=home-news')).toBeVisible()
+   } catch (error) {
+     await page.screenshot({ path: `test-failures/homepage-sections-${Date.now()}.png` })
+     throw error
+   }
  })

103-111: Enhance language toggle test coverage

The current test only verifies the heading change. Consider:

  • Verifying multiple elements' translations
  • Testing language preference persistence
  • Checking meta tags for language changes
  test('should change welcome message on language toggle @lang:is', async () => {
    const page = await context.newPage()
    await page.goto('/')
+   const elementsToCheck = [
+     { selector: 'h1[data-testid="home-heading"]', is: 'Velkomin', en: 'Welcome' },
+     { selector: '[data-testid="home-banner"]', is: 'Þjónusta', en: 'Services' }
+   ]
-   const homeHeading = page.locator('h1[data-testid="home-heading"]')
-   const icelandicHeading = await homeHeading.textContent()
+   // Verify initial Icelandic content
+   for (const element of elementsToCheck) {
+     await expect(page.locator(element.selector)).toContainText(element.is)
+   }
    await page.locator('button[data-testid="language-toggler"]:visible').click()
-   await expect(homeHeading).not.toHaveText(icelandicHeading!)
+   // Verify English content
+   for (const element of elementsToCheck) {
+     await expect(page.locator(element.selector)).toContainText(element.en)
+   }
    await expect(page).toHaveURL('/en')
+   // Verify language meta tag
+   await expect(page.locator('html')).toHaveAttribute('lang', 'en')
+   // Verify language persistence
+   await page.reload()
+   await expect(page).toHaveURL('/en')
  })
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a35f443 and 0f0c704.

📒 Files selected for processing (6)
  • apps/web/e2e/smoke/homepage.spec.ts (1 hunks)
  • apps/web/e2e/smoke/search.spec.ts (1 hunks)
  • apps/web/e2e/smoke/sites-of-institutions.spec.ts (1 hunks)
  • apps/web/e2e/utils/addons.ts (1 hunks)
  • apps/web/playwright.config.ts (1 hunks)
  • apps/web/project.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
apps/web/e2e/smoke/homepage.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/e2e/smoke/search.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/e2e/smoke/sites-of-institutions.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/e2e/utils/addons.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/playwright.config.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/project.json (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (8)
apps/web/playwright.config.ts (3)

1-3: LGTM! Imports are well-structured

The imports are clean and follow best practices, with a clear separation between external package and local utilities.


11-11: LGTM! Export is correctly defined

The default export is appropriate for a configuration file.


6-7: Verify environment variable handling

The direct sourcing of .env.secret in the command might expose sensitive information in logs or error messages.

Let's check the environment handling setup:

✅ Verification successful

Environment variable handling is secure

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if .env.secret is properly gitignored
grep ".env.secret" .gitignore

# Check for any potential secret leaks in error messages
rg -g "*.{log,txt}" ".env.secret"

Length of output: 89


Script:

#!/bin/bash
# Search for any console.log statements that might print environment variables in TypeScript files
rg 'console\.log\(.*process\.env' --type ts

# Search for any instances of 'source .env.secret' in shell scripts to ensure it's used securely
rg 'source\s+\.env\.secret' --type sh

Length of output: 85

apps/web/e2e/utils/addons.ts (2)

1-3: LGTM: Clean imports and proper TypeScript usage

The import statement is clean and the overall structure follows TypeScript best practices.


1-40: Verify matcher usage and uniqueness

Let's ensure these matchers are being used and aren't duplicating existing functionality.

✅ Verification successful

Matcher usage and uniqueness verified

All custom matchers are in use and no duplicates found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for usage of these matchers
echo "Checking usage of matchers..."
rg "toHaveCountGreaterThan|toBeApplication" apps/web/e2e/

# Check for potential duplicate matchers
echo "Checking for similar matchers..."
rg "expect\.extend\(\{" apps/web/e2e/

Length of output: 808

apps/web/e2e/smoke/sites-of-institutions.spec.ts (2)

1-14: LGTM! Well-structured imports and type definitions

The imports are well-organized, and the utility types enhance type safety for role-based testing.


22-44: Verify coverage of all institutions

Let's ensure that all institutions in the codebase are covered by these tests.

✅ Verification successful

The test coverage appears to be appropriate and verified

The test file is focused on testing a specific subset of organizations that are likely part of a particular feature or functionality. While there are additional organizations found in the codebase, they are used in different contexts and routes. The test's organization list appears to be intentionally curated for its specific purpose rather than attempting to be comprehensive.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find potential institutions that aren't covered by the tests

# Search for institution names in the codebase
echo "Searching for potential institution references in the codebase..."
rg -i "institution|stofnun" --type ts --type tsx -g "!*.spec.ts" -g "!*.test.ts" -l

# Search for routes that might indicate institution pages
echo "Searching for potential institution routes..."
rg -i "'/s/[^']+'" --type ts --type tsx -g "!*.spec.ts" -g "!*.test.ts"

Length of output: 466


Script:

#!/bin/bash
# Description: Find potential institutions that aren't covered by the tests

# Search for institution names in the codebase, including .ts and .tsx files
echo "Searching for potential institution references in the codebase..."
rg -i "institution|stofnun" -g "*.ts" -g "*.tsx" -g "!*.spec.ts" -g "!*.test.ts" -l

# Search for routes that might indicate institution pages
echo "Searching for potential institution routes..."
rg -i "/s/[^']+" -g "*.ts" -g "*.tsx" -g "!*.spec.ts" -g "!*.test.ts"

Length of output: 196138


Script:

#!/bin/bash
# Search for institution-specific routes and components
echo "Searching for institution routes and components..."
rg -g "*.ts" -g "*.tsx" "'/s/[^']+'" --no-filename | sort -u

# Search for organization slugs/names in components
echo "Searching for organization names/slugs..."
rg -g "*.ts" -g "*.tsx" "organisationName:|organizationSlug:|organization:" --no-filename | sort -u

Length of output: 6541

apps/web/project.json (1)

142-146: LGTM! Configuration follows Nx best practices.

The new e2e target is correctly configured using the official Nx Playwright executor.

Let's verify the existence of the referenced configuration file:

✅ Verification successful

LGTM! Configuration follows Nx best practices.

The new e2e target is correctly configured using the official Nx Playwright executor.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the Playwright configuration file exists
# Expected: The configuration file should exist at apps/web/playwright.config.ts

if [ -f "apps/web/playwright.config.ts" ]; then
    echo "✓ Playwright configuration file exists"
else
    echo "✗ Missing Playwright configuration file"
    echo "Please ensure apps/web/playwright.config.ts is created"
fi

Length of output: 129

apps/web/playwright.config.ts Outdated Show resolved Hide resolved
apps/web/e2e/utils/addons.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/search.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/search.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/search.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/sites-of-institutions.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/homepage.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/homepage.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/homepage.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/homepage.spec.ts Outdated Show resolved Hide resolved
@svanaeinars svanaeinars changed the title feat: Improve web e2e tests and move them to their directory feat(web): Improve web e2e tests and move them to their directory Nov 13, 2024
@svanaeinars svanaeinars requested a review from a team as a code owner November 14, 2024 23:12
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 173 lines in your changes missing coverage. Please review.

Project coverage is 35.58%. Comparing base (bd78723) to head (9cf35bf).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
apps/web/e2e/homepage.spec.ts 0.00% 126 Missing ⚠️
apps/web/e2e/search.spec.ts 0.00% 28 Missing ⚠️
apps/web/e2e/sites-of-institutions.spec.ts 0.00% 19 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16842      +/-   ##
==========================================
- Coverage   35.62%   35.58%   -0.04%     
==========================================
  Files        6914     6917       +3     
  Lines      146001   146145     +144     
  Branches    41451    41451              
==========================================
- Hits        52011    52005       -6     
- Misses      93990    94140     +150     
Flag Coverage Δ
web 1.74% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
apps/web/server.ts 0.00% <ø> (ø)
apps/web/e2e/sites-of-institutions.spec.ts 0.00% <0.00%> (ø)
apps/web/e2e/search.spec.ts 0.00% <0.00%> (ø)
apps/web/e2e/homepage.spec.ts 0.00% <0.00%> (ø)

... and 11 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd78723...9cf35bf. Read the comment docs.

---- 🚨 Try these New Features:

Copy link
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: 2

🧹 Outside diff range and nitpick comments (3)
apps/web/README.md (1)

93-100: Enhance e2e testing documentation with additional details

While the basic command is documented, consider expanding this section to include:

  • Prerequisites for running e2e tests (e.g., required browsers, dependencies)
  • Test directory structure and organization
  • Available test suites and their purposes
  • Instructions for debugging tests
  • CI/CD integration details

Here's a suggested expansion:

 ### Starting e2e tests locally
 
-You can start the e2e tests by running:
+Before running the tests, ensure you have the following prerequisites:
+- Chrome browser installed (version 90+)
+- Development server running (`yarn dev web`)
+
+The e2e tests are located in the `apps/web/e2e` directory and are organized by feature:
+- `home/` - Homepage tests
+- `search/` - Search functionality tests
+- `institutions/` - Institution pages tests
+
+To run all e2e tests:
 
 ```bash
 yarn e2e web

+To run specific test suites:
+bash +yarn e2e web --grep="homepage" # Run homepage tests only +
+
+For debugging:
+bash +yarn e2e web --debug # Runs tests in debug mode +
+
+The tests are automatically run in CI for all PRs targeting the main branch.


</blockquote></details>
<details>
<summary>apps/web/e2e/smoke/homepage.spec.ts (2)</summary><blockquote>

`15-23`: **Add error handling for session initialization**

The session setup could fail silently if the storage state file is missing or invalid.

```diff
 test.beforeAll(async ({ browser }) => {
+  try {
     context = await session({
       browser: browser,
       storageState: 'homepage.json',
       homeUrl: `${urls.islandisBaseUrl}/`,
       phoneNumber: '0103019',
       idsLoginOn: false,
     })
+  } catch (error) {
+    console.error('Failed to initialize session:', error)
+    throw error
+  }
 })

29-37: Enhance homepage section tests with accessibility checks

Consider adding accessibility checks for critical homepage elements.

 test('has expected sections @lang:is', async () => {
   const page = await createPageAndNavigate(context, '/')
+  // Check main landmark
+  await expect(page.getByRole('main')).toBeVisible()
+  // Check navigation landmark
+  await expect(page.getByRole('navigation')).toBeVisible()
   await expect(
     page.locator('text=Öll opinber þjónusta á einum stað'),
   ).toBeVisible()
   await expect(page.locator('data-testid=home-banner')).toBeVisible()
   await expect(page.locator('data-testid=home-heading')).toBeVisible()
   await expect(page.locator('data-testid=home-news')).toBeVisible()
+  // Check heading hierarchy
+  await expect(page.getByRole('heading', { level: 1 })).toBeVisible()
 })
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0f0c704 and 05e489f.

📒 Files selected for processing (6)
  • apps/web/README.md (1 hunks)
  • apps/web/e2e/smoke/homepage.spec.ts (1 hunks)
  • apps/web/e2e/smoke/search.spec.ts (1 hunks)
  • apps/web/e2e/smoke/sites-of-institutions.spec.ts (1 hunks)
  • apps/web/jest.config.ts (1 hunks)
  • apps/web/playwright.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/web/e2e/smoke/search.spec.ts
  • apps/web/e2e/smoke/sites-of-institutions.spec.ts
  • apps/web/playwright.config.ts
🧰 Additional context used
📓 Path-based instructions (3)
apps/web/README.md (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/e2e/smoke/homepage.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/jest.config.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (4)
apps/web/jest.config.ts (2)

16-16: LGTM! Good separation of test types

The addition of testPathIgnorePatterns correctly excludes e2e tests from Jest runs, which is appropriate since these tests are now managed by Playwright. This separation follows testing best practices.


16-16: Verify test pattern exclusion is working correctly

Let's verify that the pattern correctly excludes e2e tests while still picking up unit tests.

✅ Verification successful

The results show that the e2e test pattern exclusion is working correctly. We can see:

  1. The e2e directory contains test files that should be excluded:

    • apps/web/e2e/smoke/homepage.spec.ts
    • apps/web/e2e/smoke/search.spec.ts
    • apps/web/e2e/smoke/sites-of-institutions.spec.ts
  2. Regular test files outside e2e directory are present and will be included:

    • apps/web/components/Charts/v2/utils/color.spec.ts
    • apps/web/components/Organization/Slice/TableSlice/TableSlice.spec.ts
    • apps/web/hooks/useLinkResolver/useLinkResolver.spec.ts
    • apps/web/hooks/useNamespace.spec.ts
    • apps/web/screens/Category/Category/utils.spec.ts
    • apps/web/screens/ServiceWeb/utils/getSlugPart.spec.ts

Test pattern exclusion is correctly configured

The testPathIgnorePatterns setting in jest.config.ts properly excludes e2e tests while keeping unit tests discoverable.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Jest test pattern configuration

# Check if there are any test files in the e2e directory
echo "Checking for e2e test files:"
fd -e ts -e tsx . apps/web/e2e

# Check for test files outside e2e directory that should be included
echo -e "\nChecking for other test files that should be included:"
fd -e test.ts -e test.tsx -e spec.ts -e spec.tsx . apps/web --exclude apps/web/e2e

# List all Jest config files to ensure consistent configuration
echo -e "\nChecking for other Jest configs that might need similar updates:"
fd jest.config . apps/web

Length of output: 28856

apps/web/e2e/smoke/homepage.spec.ts (2)

206-224: Improve burger menu test structure and assertions

The previous comment about improving the burger menu test structure and removing commented code is still valid.


39-77: 🛠️ Refactor suggestion

Consolidate duplicate life event tests

The IS and EN versions of the life event tests are identical except for the URL. Consider parameterizing the test.

The previous comment about memory leaks and concurrent page handling is still valid.

-test(`should have life event @lang:is`, async () => {
+test.describe('life events', () => {
+  const languages = [
+    { lang: 'is', path: '/' },
+    { lang: 'en', path: '/en' }
+  ]
+  
+  for (const { lang, path } of languages) {
+    test(`should have life event @lang:${lang}`, async () => {
       test.slow()
-      const page = await createPageAndNavigate(context, '/')
+      const page = await createPageAndNavigate(context, path)
       // ... rest of the test
     })
+  }
+})

apps/web/e2e/smoke/homepage.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/smoke/homepage.spec.ts Outdated Show resolved Hide resolved
Copy link
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

🧹 Outside diff range and nitpick comments (1)
libs/testing/e2e/src/index.ts (1)

12-13: LGTM! Good separation of value and type exports.

The explicit separation of value exports (test, expect) from type exports (Page, Locator, BrowserContext) is a good practice that:

  • Improves TypeScript type checking and IDE support
  • Enhances tree-shaking by clearly identifying what gets removed during compilation
  • Maintains clear boundaries between runtime and type-level entities

This change aligns well with TypeScript best practices and module design principles. Consider applying similar type/value separation patterns to other shared testing utilities in this library for consistency.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 05e489f and af54dcc.

📒 Files selected for processing (5)
  • apps/web/e2e/smoke/homepage.spec.ts (1 hunks)
  • apps/web/e2e/smoke/search.spec.ts (1 hunks)
  • apps/web/e2e/smoke/sites-of-institutions.spec.ts (1 hunks)
  • apps/web/playwright.config.ts (1 hunks)
  • libs/testing/e2e/src/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/web/e2e/smoke/homepage.spec.ts
  • apps/web/e2e/smoke/search.spec.ts
  • apps/web/e2e/smoke/sites-of-institutions.spec.ts
  • apps/web/playwright.config.ts
🧰 Additional context used
📓 Path-based instructions (1)
libs/testing/e2e/src/index.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."

Copy link
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

🧹 Outside diff range and nitpick comments (3)
apps/web/README.md (3)

93-110: Add prerequisites to the Quick Start guide.

While the installation and test execution commands are clear, consider adding:

  • Required Node.js version
  • Environment setup requirements (e.g., environment variables, if any)
  • Development server requirements (whether it needs to be running)

111-120: Enhance the folder structure documentation.

Consider adding:

  • Example test file names and patterns
  • Naming conventions for test files
  • Brief examples of what constitutes a smoke test vs. acceptance test

122-128: Expand the mocking documentation section.

Consider adding:

  • Guidelines for when to use mocks vs. real APIs
  • Instructions for maintaining and updating mocks
  • Examples of common mocking scenarios
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1226759 and c3f0dbf.

📒 Files selected for processing (2)
  • apps/web/README.md (1 hunks)
  • apps/web/playwright.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/playwright.config.ts
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/README.md (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (1)
apps/web/README.md (1)

124-124: Verify documentation links.

Let's ensure the referenced documentation files exist and are accessible.

Also applies to: 128-128

✅ Verification successful

Documentation links are valid and contain relevant content

The verification confirms that:

  • The referenced file libs/testing/e2e/README.md exists
  • The file contains Mockoon-related documentation as mentioned in the link
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the referenced documentation files exist

# Check if the E2E Testing Library README exists
if [ -f "libs/testing/e2e/README.md" ]; then
    echo "✓ E2E Testing Library README exists"
else
    echo "✗ E2E Testing Library README is missing"
fi

# Check if it contains Mockoon usage information
if [ -f "libs/testing/e2e/README.md" ]; then
    if grep -q "Mockoon" "libs/testing/e2e/README.md"; then
        echo "✓ Mockoon documentation found"
    else
        echo "✗ Mockoon documentation section missing"
    fi
fi

Length of output: 274

@svanaeinars svanaeinars requested a review from a team as a code owner November 18, 2024 12:25
Copy link
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: 1

🧹 Outside diff range and nitpick comments (2)
.github/workflows/pullrequest.yml (2)

146-157: Consider adding error handling for chunk generation

The script handles empty chunks correctly, but consider adding explicit error handling for the generate-chunks.sh script execution.

 run: |
   set -euo pipefail
-  CHUNKS="$(./scripts/ci/generate-chunks.sh e2e-ci)"
+  if ! CHUNKS="$(./scripts/ci/generate-chunks.sh e2e-ci)"; then
+    echo "::error::Failed to generate e2e-ci chunks"
+    exit 1
+  fi
   if [[ "$CHUNKS" != "[]" ]]; then
     echo "CHUNKS={\"projects\":$CHUNKS}" >> "$GITHUB_OUTPUT"
   fi

463-474: Ensure consistent failure handling in success checks

The success job correctly includes the new e2e-ci job, but the failure handling differs between jobs:

  • Some use != "failure"
  • Others use == "success"

Consider standardizing the failure handling approach.

-      - name: Check prepare success
-        run: '[[ ${{ needs.prepare.result }} == "success" ]] || exit 1'
+      - name: Check prepare success
+        run: '[[ ${{ needs.prepare.result }} != "failure" ]] || exit 1'
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c3f0dbf and 3e2cbf3.

📒 Files selected for processing (2)
  • .github/workflows/pullrequest.yml (6 hunks)
  • apps/web/server.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/web/server.ts
🧰 Additional context used
🪛 actionlint
.github/workflows/pullrequest.yml

273-273: label "ec2-runners" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

🔇 Additional comments (3)
.github/workflows/pullrequest.yml (3)

37-41: LGTM: Output variables properly defined

The new output variables for e2e-ci chunks and build IDs are correctly defined in the prepare job, maintaining consistency with existing patterns.


273-273: Document custom runner setup

The workflow uses a custom runner label "ec2-runners" which isn't a standard GitHub Actions runner. Consider documenting the custom runner setup in the repository's documentation.

#!/bin/bash
# Check if runner setup is documented
rg -l "ec2-runners" -g "*.md"
🧰 Tools
🪛 actionlint

273-273: label "ec2-runners" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)


Line range hint 230-247: Verify environment configuration for e2e-ci job

The job configuration looks good, but there are a few considerations:

  1. The Cypress-specific environment variables suggest this job might be using Cypress, while the PR objective mentions Playwright
  2. The runner label "ec2-runners" is not a standard GitHub Actions runner label
🧰 Tools
🪛 actionlint

234-234: label "ec2-runners" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

.github/workflows/pullrequest.yml Outdated Show resolved Hide resolved
Copy link
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: 8

🧹 Outside diff range and nitpick comments (12)
apps/web/e2e/search.spec.ts (4)

11-24: Consider extracting hardcoded values to environment variables.

The session configuration contains hardcoded values like phoneNumber and storageState that should be configurable:

- phoneNumber: '0103019',
- storageState: 'homepage.json',
+ phoneNumber: process.env.TEST_PHONE_NUMBER,
+ storageState: process.env.TEST_STORAGE_STATE,

11-11: Document the purpose of the '@fast' tag.

The test suite uses a '@fast' tag, but its significance and usage in the test runner configuration isn't clear.


42-52: Extract common test setup into helper functions.

The page navigation and search input logic is duplicated across tests. Consider extracting these into reusable helper functions.

async function performSearch(context: BrowserContext, searchPhrase: string) {
  const page = await context.newPage()
  await page.goto('/', { waitUntil: 'networkidle' })
  await page
    .getByRole('textbox', { name: 'Leitaðu á Ísland.is' })
    .fill(searchPhrase)
  await page.keyboard.press('Enter')
  return page
}

Also, consider using a more systematic approach for the test string, such as a repeated pattern or Unicode characters.


54-56: Document why the English search test is skipped.

Add a TODO comment explaining why this test is skipped and what needs to be implemented.

- test.skip('should search in English', async () => {
+ test.skip('should search in English', async () => {
+  // TODO: Implement once English search API is available in test environment
+  // Issue: #XXXXX
   return
apps/web/e2e/sites-of-institutions.spec.ts (1)

11-13: Consider making utility types more reusable

The GetByRole and GetByRoleParameters types are tightly coupled to this file. Consider moving them to a shared types file for reuse across other e2e tests.

+// TODO: Move to @island.is/testing/e2e/types
 type GetByRole = Pick<Page, 'getByRole'>['getByRole']
 type GetByRoleParameters = Parameters<GetByRole>
apps/web/README.md (4)

95-109: Enhance Quick Start section with additional setup details.

Consider adding the following important details to the Quick Start guide:

  • Prerequisites (Node.js version, etc.)
  • Development server requirements (if tests need a running server)
  • Configuration options (browser selection, headless mode, etc.)
  • Troubleshooting common issues

111-123: Expand Test Organization section with best practices.

The test organization section would benefit from additional information:

  • Test file naming conventions
  • Page Object Model usage (if applicable)
  • Test data management
  • Test isolation practices
  • Recommended patterns for handling authentication, state, and cleanup

125-127: Enhance Mocking section with quick-start examples.

Consider adding:

  • Basic example of a mock configuration
  • Common mocking scenarios (authentication, API responses)
  • Instructions for running tests with/without mocks
  • Environment configuration for mocks

129-131: Expand More Resources section with additional references.

Consider adding links to:

  • Playwright official documentation
  • NextJS testing guides
  • CI/CD integration documentation
  • Test reporting and analytics tools
  • Visual regression testing setup (if applicable)
apps/web/e2e/homepage.spec.ts (3)

79-101: Refactor to reduce code duplication

The tests for navigating to featured links in Icelandic and English are nearly identical. Consider refactoring these tests to reduce duplication by parameterizing the language code.

Example refactor:

const testFeaturedLinks = async (lang: string) => {
  const page = await createPageAndNavigate(context, `/${lang}`)
  const featuredLinks = page.locator('[data-testid="featured-link"]')
  await expect(featuredLinks.count()).resolves.toBeGreaterThan(3)
  const featuredLinksHandles = await featuredLinks.elementHandles()
  const featuresLinksUrls = await Promise.all(
    featuredLinksHandles.map((item) => item.getAttribute('href')),
  )
  const featuredPage = await context.newPage()
  for (const url of featuresLinksUrls) {
    if (url) {
      const result = await featuredPage.goto(url)
      await expect(
        featuredPage.getByRole('link', { name: 'island.is logo' }),
      ).toBeVisible()
      if (result) {
        expect(result.status()).toBe(200)
      }
    }
  }
  await featuredPage.close()
}

test(`should navigate to featured link @lang:is`, async () => {
  test.slow()
  await testFeaturedLinks('')
})

test(`should navigate to featured link @lang:en`, async () => {
  test.slow()
  await testFeaturedLinks('en')
})

Also applies to: 103-125


172-181: Verify content updates after language toggle

After toggling the language, it's good practice to verify that specific content changes as expected. Consider adding assertions to check that key texts have updated to the new language.


202-203: Remove commented-out code

There's commented-out code that should be removed to keep the codebase clean and maintainable.

Apply this diff:

-// Heading is "visible" behind menu
-// await expect(page.getByTestId('home-heading')).not.toBeVisible()
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0d9addf and 03cdcb7.

📒 Files selected for processing (5)
  • apps/web/README.md (1 hunks)
  • apps/web/e2e/homepage.spec.ts (1 hunks)
  • apps/web/e2e/search.spec.ts (1 hunks)
  • apps/web/e2e/sites-of-institutions.spec.ts (1 hunks)
  • apps/web/playwright.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/playwright.config.ts
🧰 Additional context used
📓 Path-based instructions (4)
apps/web/README.md (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/e2e/homepage.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/e2e/search.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/e2e/sites-of-institutions.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (4)
apps/web/e2e/search.spec.ts (1)

1-10: LGTM! Well-structured imports and configuration.

The imports are properly typed and the baseURL configuration follows Playwright best practices.

apps/web/e2e/sites-of-institutions.spec.ts (2)

14-19: LGTM! Well-structured type definition

The Orgs type is well-designed with optional properties that provide flexibility for different test scenarios.


46-52: LGTM! Good session management

The session setup with idsLoginOn: false is well-configured and properly scoped.

apps/web/README.md (1)

127-127: Verify documentation links.

Let's ensure the referenced documentation is accessible and up-to-date.

Also applies to: 131-131

✅ Verification successful

Documentation link is valid and accessible

The referenced Mockoon Usage Guide link (../../libs/testing/e2e/README.md) is valid and accessible. The verification confirms:

  • The target file exists at libs/testing/e2e/README.md
  • The relative path is correctly structured for the web README's location
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the referenced documentation files exist and are accessible

# Check if the E2E Testing Library README exists
if [ -f "libs/testing/e2e/README.md" ]; then
    echo "E2E Testing Library README exists"
else
    echo "E2E Testing Library README not found"
fi

# Check for broken relative links in the README
rg -l "\[.*\]\((?!http).*\)" "apps/web/README.md"

Length of output: 398


Script:

#!/bin/bash
# Let's try a different approach to verify the links

# First, check if the target README exists
if [ -f "libs/testing/e2e/README.md" ]; then
    echo "=== E2E Testing Library README exists ==="
    echo
fi

# Use fd to find all README files for context
echo "=== All README files in the repository ==="
fd -t f "README.md"
echo

# Use simpler grep pattern to find relative links in web README
echo "=== Relative links in apps/web/README.md ==="
grep -o "\[.*\](.*)" apps/web/README.md | grep -v "^http"

Length of output: 21524

apps/web/e2e/search.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/sites-of-institutions.spec.ts Show resolved Hide resolved
apps/web/e2e/sites-of-institutions.spec.ts Show resolved Hide resolved
apps/web/e2e/homepage.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/homepage.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/homepage.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/homepage.spec.ts Outdated Show resolved Hide resolved
apps/web/e2e/homepage.spec.ts Outdated Show resolved Hide resolved
Copy link
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: 1

🧹 Outside diff range and nitpick comments (2)
apps/web/README.md (2)

95-109: Consider adding prerequisite information to Quick Start.

The Quick Start instructions are clear but could be more comprehensive by including:

  • Required Node.js version
  • Any necessary environment variables
  • How to verify successful installation

111-123: Enhance test organization documentation.

While the tagging system is well explained, consider adding:

  • Commands to run specific tagged tests (e.g., how to run only @fast or @slow tests)
  • Guidelines for when to use each tag
  • More realistic test examples that demonstrate actual page interactions
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 03cdcb7 and b946139.

📒 Files selected for processing (2)
  • apps/web/README.md (1 hunks)
  • apps/web/playwright.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/playwright.config.ts
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/README.md (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (1)
apps/web/README.md (1)

93-128: Well-structured E2E testing documentation.

The new E2E testing section is well-integrated with the existing documentation, maintaining consistent formatting and providing a logical flow of information.

apps/web/README.md Outdated Show resolved Hide resolved
Copy link
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: 1

🧹 Outside diff range and nitpick comments (2)
apps/web/e2e/search.spec.ts (2)

11-24: Consider extracting test configuration to a separate file.

The test setup contains hardcoded values that could be moved to a configuration file for better maintainability:

  • Phone number: '0103019'
  • Storage state: 'homepage.json'
+ // test.config.ts
+ export const TEST_CONFIG = {
+   phoneNumber: '0103019',
+   storageState: 'homepage.json',
+ }

  test.beforeAll(async ({ browser }) => {
    context = await session({
      browser: browser,
-     storageState: 'homepage.json',
+     storageState: TEST_CONFIG.storageState,
      homeUrl: `${urls.islandisBaseUrl}/`,
-     phoneNumber: '0103019',
+     phoneNumber: TEST_CONFIG.phoneNumber,
      idsLoginOn: false,
    })
  })

54-56: Document the reason for skipping the test.

Add a TODO comment explaining why the test is skipped and what needs to be implemented:

- test.skip('should search in English', async () => {
+ test.skip('should search in English', async () => {
+   // TODO: Implement English search test after language switcher is added
+   // Issue #XXXX: Add language switcher to search functionality
    return
  })
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b946139 and 50b5a4d.

📒 Files selected for processing (2)
  • apps/web/e2e/homepage.spec.ts (1 hunks)
  • apps/web/e2e/search.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/e2e/homepage.spec.ts
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/e2e/search.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (2)
apps/web/e2e/search.spec.ts (2)

1-10: LGTM! Well-structured imports and configuration.

The imports are properly organized, and the base URL configuration follows Playwright best practices.


26-40: Previous review comments are still applicable.

The test still contains issues mentioned in the previous review:

  1. The magic number 9 in the assertion should be explained or made configurable
  2. Navigation timeouts should be handled explicitly

apps/web/e2e/search.spec.ts Show resolved Hide resolved
@svanaeinars svanaeinars requested a review from a team as a code owner November 21, 2024 11:03
Copy link
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: 2

🧹 Outside diff range and nitpick comments (8)
apps/web/proxy.config.ts (3)

1-6: Add TypeScript type definitions for proxy configuration

The configuration object would benefit from explicit TypeScript types to ensure type safety and better IDE support.

Consider adding types:

+import { ProxyConfig } from '@nrwl/devkit'
+
-const proxyConfig = {
+const proxyConfig: ProxyConfig = {
   '/api': {
     target: process.env.GRAPHQL_API_URL ?? 'http://localhost:4444',
     secure: false,
   },
 }

4-4: Review security implications of disabled SSL verification

Setting secure: false disables SSL certificate validation, which could pose security risks in production environments.

Consider:

  1. Using environment-specific configuration to enable secure mode in production
  2. Adding a comment explaining why SSL verification is disabled
  3. Implementing proper SSL certificate handling for development environments

1-8: Consider adding additional proxy configuration options

The current configuration is minimal. Consider adding common proxy options that might be useful:

 const proxyConfig = {
   '/api': {
     target: process.env.GRAPHQL_API_URL ?? 'http://localhost:4444',
     secure: false,
+    changeOrigin: true,
+    logLevel: 'debug',
+    pathRewrite: { '^/api': '' },
   },
 }

This would:

  • Enable proper host header rewriting with changeOrigin
  • Add debug logging for easier troubleshooting
  • Allow path rewriting if needed
apps/web/server.ts (1)

Line range hint 3-11: Consider adding TypeScript type safety for proxy configuration

To align with the coding guidelines for TypeScript safety, consider adding type definitions for the proxy configuration.

// Add to proxy.config.ts
interface ProxyConfig {
  [path: string]: {
    target: string;
    secure?: boolean;
    changeOrigin?: boolean;
  };
}

const proxyConfig: ProxyConfig = {
  // ... your existing configuration
};

export default proxyConfig;
charts/services/web/values.dev.yaml (1)

26-26: Consider using HTTPS for internal API communication

While using http://web-api is functional for internal Kubernetes service communication, consider using HTTPS to ensure secure communication between services, especially if sensitive data is being transmitted.

apps/web/infra/web.ts (1)

Line range hint 1-85: Consider reviewing the following architectural aspects:

  1. The basic auth configuration is only applied to staging. Consider if prod might benefit from additional security layers.
  2. As the application grows, monitor if the current resource limits (1000m CPU, 768Mi memory) remain sufficient.
  3. The 20-second initial delay for readiness might be optimized based on actual startup times.
charts/islandis/values.dev.yaml (2)

Line range hint 3395-3400: Validate HPA configuration

The HPA configuration allows scaling up to 50 pods which is a significant increase from the minimum of 2. Ensure this is intentional and that the cluster has sufficient resources to handle this scale.

Consider:

  1. Setting a more conservative maximum initially and increase based on actual load
  2. Implementing pod disruption budgets to ensure service availability
  3. Reviewing cluster capacity to ensure it can handle 50 pods of this service

Line range hint 3415-3417: Review resource limits and requests

The memory limits (768Mi) and requests (384Mi) have a 2:1 ratio which is good. However, the CPU limits (1000m) to requests (300m) ratio is greater than 3:1, which might cause CPU throttling under load.

Consider adjusting the CPU limits to be closer to a 2:1 or 3:1 ratio with requests, for example:

  resources:
    limits:
-     cpu: '1000m'
+     cpu: '750m'
      memory: '768Mi'
    requests:
      cpu: '300m'
      memory: '384Mi'
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a35543c and 3e5405b.

📒 Files selected for processing (10)
  • apps/web/infra/web.ts (1 hunks)
  • apps/web/proxy.config.json (0 hunks)
  • apps/web/proxy.config.ts (1 hunks)
  • apps/web/server.ts (1 hunks)
  • charts/islandis/values.dev.yaml (1 hunks)
  • charts/islandis/values.prod.yaml (1 hunks)
  • charts/islandis/values.staging.yaml (1 hunks)
  • charts/services/web/values.dev.yaml (1 hunks)
  • charts/services/web/values.prod.yaml (1 hunks)
  • charts/services/web/values.staging.yaml (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/proxy.config.json
🧰 Additional context used
📓 Path-based instructions (3)
apps/web/infra/web.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/proxy.config.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/server.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (11)
apps/web/proxy.config.ts (1)

3-3: Consider adding environment variable validation

The fallback to localhost is good, but there's no validation for the GRAPHQL_API_URL format when provided.

Let's check if this environment variable is properly documented and used consistently:

apps/web/server.ts (1)

3-3: Verify the new proxy configuration implementation

The change from a static JSON to a dynamic configuration file looks good, but we should verify the implementation of the new proxy configuration.

✅ Verification successful

The proxy configuration implementation is valid and follows the established pattern

The proxy configuration is correctly implemented with:

  • A valid proxy configuration object structure
  • Proper fallback to localhost when GRAPHQL_API_URL is not set
  • Consistent usage across multiple applications in the monorepo
  • Correct integration with the bootstrap configuration in server.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new proxy configuration implementation
# Expected: The new proxy.config should export a valid proxy configuration object

# Check the new proxy configuration implementation
cat apps/web/proxy.config.ts

# Verify environment variable usage
rg -l "GRAPHQL_API_URL" .env*

Length of output: 243


Script:

#!/bin/bash
# Check for any other proxy configurations in the codebase
rg -A 5 -B 5 "target.*GRAPHQL_API_URL"

# Check for any other files importing proxy.config
rg -l "import.*proxy\.config"

# Check server.ts implementation to see how proxy config is used
cat apps/web/server.ts

Length of output: 991

charts/services/web/values.dev.yaml (1)

26-26: LGTM: Environment variable update aligns with the broader API integration changes

The replacement of API_URL with GRAPHQL_API_URL is consistent with similar changes across other configuration files.

apps/web/infra/web.ts (1)

10-10: LGTM! The environment variable rename improves clarity.

The change from API_URL to GRAPHQL_API_URL better describes the purpose of this environment variable.

Let's verify that this change has been consistently applied across the codebase:

charts/services/web/values.staging.yaml (2)

27-27: Verify GraphQL API endpoint configuration across environments

The addition of GRAPHQL_API_URL replacing API_URL suggests an architectural shift to GraphQL. Ensure this change is consistently applied across all environments and that dependent services are updated accordingly.

✅ Verification successful

GraphQL API configuration is consistently applied across environments

The verification shows that GRAPHQL_API_URL is consistently configured across all environments (dev, staging, prod) in the following services:

  • web service (charts/services/web/values.*.yaml)
  • application-system-api (charts/services/application-system-api/values.*.yaml)
  • islandis (charts/islandis/values.*.yaml)

All services use the same endpoint configuration (http://web-api), indicating a coordinated architectural approach. No legacy API_URL references were found in these services, confirming a clean transition to GraphQL.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check GraphQL API URL configuration across different environment files
echo "Checking GraphQL API URL configuration across environments..."
fd -t f "values.*\.yaml" -x grep -l "GRAPHQL_API_URL"

# Check for any remaining references to the old API_URL
echo "Checking for remaining API_URL references..."
rg "API_URL" --type yaml

Length of output: 23869


Line range hint 1-6: ⚠️ This is an automatically generated file

The file header indicates that manual edits should be avoided. Instead, use yarn charts to generate the configuration.

✅ Verification successful

⚠️ Manual edits to this file will be overwritten

The warning is correct. The file is automatically generated by the yarn charts command, which runs the script at infra/src/cli/generate-chart-values.ts. Any manual changes to values.staging.yaml will be lost when charts are regenerated. Instead:

  • Update the chart generation configuration in the infra/src directory
  • Run yarn charts to regenerate the values files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there's a charts generation script
fd -t f "package.json" -x jq -r '.scripts | select(.charts != null) | .charts'

Length of output: 218


Script:

#!/bin/bash
# Check for chart generation related files and scripts
fd -t f "generate-chart|chart" -e ts -e js

Length of output: 742


Script:

#!/bin/bash
# Look for yarn workspace configurations
fd -t f "package.json" -x grep -l "workspaces"

Length of output: 90


Script:

#!/bin/bash
# Check the content of infra directory for chart generation
fd . "infra" -t d

Length of output: 756


Script:

#!/bin/bash
# Check the content of the chart generation script
cat infra/src/cli/generate-chart-values.ts

Length of output: 3324


Script:

#!/bin/bash
# Look for chart value templates or configuration
fd . "infra/src" -e yaml -e ts -x grep -l "values.staging"

Length of output: 56

charts/services/web/values.prod.yaml (3)

Line range hint 1-116: Production configuration looks solid

The overall configuration maintains good production practices:

  • Appropriate resource limits and requests
  • Secure context settings
  • Well-configured horizontal pod autoscaling
  • Proper secrets management

26-26: Verify API endpoint configuration across environments

The change from API_URL to GRAPHQL_API_URL is consistent with the migration mentioned in the summary. However, we should verify this configuration across all environments to ensure consistency.

✅ Verification successful

GRAPHQL_API_URL configuration is consistent across environments

The verification shows that the GRAPHQL_API_URL configuration is properly set and consistent across all environments (dev, staging, prod) for the web service:

  • Dev: http://web-api
  • Staging: http://web-api
  • Prod: http://web-api

The old API_URL configuration is not present in the web service values files, indicating a clean migration to the new variable name.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency of GRAPHQL_API_URL across different environment value files
# and ensure API_URL is completely removed

# Check for GRAPHQL_API_URL configuration across environments
echo "Checking GRAPHQL_API_URL configuration:"
rg "GRAPHQL_API_URL:" "charts/"

# Verify that old API_URL is completely removed
echo -e "\nChecking for any remaining API_URL configurations:"
rg "API_URL:" "charts/"

Length of output: 23814


Line range hint 42-44: Verify health check endpoints implementation

The configuration shows separate paths for liveness (/liveness) and readiness (/readiness) probes. Let's ensure these endpoints are properly implemented in the web service.

Also applies to: 46-48

✅ Verification successful

Let me analyze the findings from the shell script results:

  1. The health check endpoints are properly implemented in the infrastructure libraries:

    • libs/infra-next-server/src/lib/health.ts implements both /liveness and /readiness endpoints
    • libs/infra-express-server/src/lib/infra-express-server.ts implements the /liveness endpoint
  2. The web service configuration in apps/web/infra/web.ts shows:

    .liveness('/liveness')
    .readiness({ path: '/readiness', initialDelaySeconds: 20 })
  3. The endpoints are blacklisted from tracing in libs/infra-tracing/src/lib/datadog-tracer.ts:

    blacklist: ['/liveness', '/readiness', '/metrics']

Let me generate the final response:

Health check endpoints are properly implemented

The liveness and readiness probe endpoints are correctly implemented in the infrastructure libraries and properly configured in the web service. The endpoints are also appropriately excluded from tracing to prevent unnecessary overhead.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of health check endpoints in the web service

# Search for health check endpoint implementations
echo "Searching for health check implementations:"
rg -A 5 "('/liveness'|'/readiness')" --type ts --type js

# Look for any health check related tests
echo -e "\nSearching for health check tests:"
rg -A 5 "describe.*('health|liveness|readiness')" --type ts --type js

Length of output: 22439

charts/islandis/values.prod.yaml (1)

3256-3256: ⚠️ Potential issue

Fix the YAML indentation for the empty line

The empty line breaks the YAML structure between environment variables. This could cause deployment failures.

Apply this diff to fix the indentation:

    ENVIRONMENT: 'prod'
-
    GRAPHQL_API_URL: 'http://web-api'

Likely invalid or redundant comment.

charts/islandis/values.dev.yaml (1)

Line range hint 3391-3394: Review readiness probe configuration

The readiness probe has a high initialDelaySeconds (20) compared to the liveness probe (3). While this can be intentional to allow for application startup, verify if this delay is necessary as it affects pod availability during deployments.

✅ Verification successful

Looking at the values file, I can see that the readiness probe configuration for the application-system-api service has an initialDelaySeconds of 20, which is indeed higher than the liveness probe's 3 seconds. However, this is a deliberate and appropriate configuration because:

  1. The application-system-api service has a database migration initialization container that needs to run before the service can be ready
  2. The service has complex dependencies and initialization requirements, including database connections, Redis connections, and various external service configurations

The higher readiness probe delay is appropriate for this service

The readiness probe delay of 20 seconds is justified for the application-system-api service due to its initialization requirements. This ensures that the service is fully ready to handle traffic before being added to the service endpoints. The liveness probe's lower delay of 3 seconds is also appropriate as it checks basic service health after initialization.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the application startup logs to verify if 20s delay is needed
kubectl logs -n islandis -l app=web --tail=50 | grep -i "start"

Length of output: 161


Script:

#!/bin/bash
# Let's check the values files for any startup-related configurations or documentation
fd "values.*ya?ml" charts/islandis/ --type f --exec cat {}

Length of output: 124064

charts/islandis/values.staging.yaml Outdated Show resolved Hide resolved
charts/islandis/values.dev.yaml Outdated Show resolved Hide resolved
Copy link
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: 3

🧹 Outside diff range and nitpick comments (4)
apps/web/docker-compose.yml (2)

16-26: Enhance init service reliability and version

The initialization service could be improved for better reliability:

  1. The wait loop should include a timeout to prevent infinite waiting
  2. The curl image version (7.85.0) could be updated to the latest stable version
  3. The health check could verify cluster health status

Consider these improvements:

 init-elasticsearch:
-  image: docker.io/curlimages/curl:7.85.0
+  image: docker.io/curlimages/curl:8.5.0
   depends_on:
     elasticsearch:
       condition: service_healthy
   entrypoint: >
     sh -c "
+    TIMEOUT=300
+    ELAPSED=0
     until curl -s http://elasticsearch:9200; do
       echo 'Waiting for Elasticsearch...';
+      ELAPSED=$((ELAPSED+5))
+      if [ "$ELAPSED" -ge "$TIMEOUT" ]; then
+        echo 'Timeout waiting for Elasticsearch'
+        exit 1
+      fi
       sleep 5;
     done;

1-66: Consider environment-specific configurations and monitoring

For a production-ready setup, consider:

  1. Implementing separate configurations for different environments (dev, staging, prod)
  2. Adding monitoring capabilities (e.g., Elasticsearch Exporter for Prometheus)
  3. Implementing backup strategies
  4. Setting up proper logging configuration

Would you like assistance in implementing any of these architectural improvements?

apps/web/project.json (2)

128-135: Consider enhancing the Docker Compose configuration

The dev-services target runs Docker Compose without ensuring service health or proper startup order. Consider adding health checks and dependency management.

 "dev-services": {
   "executor": "nx:run-commands",
   "options": {
-    "command": "docker compose up -d",
+    "command": "docker compose up -d && docker compose run --rm wait-for-it",
     "cwd": "apps/web"
   },
   "configurations": {}
 },

Also, consider adding a complementary down command to clean up services:

+"dev-services-down": {
+  "executor": "nx:run-commands",
+  "options": {
+    "command": "docker compose down",
+    "cwd": "apps/web"
+  }
+},

150-154: Add environment-specific configurations for e2e tests

The e2e target could benefit from different configurations for development, staging, and production environments.

 "e2e": {
   "executor": "@nx/playwright:playwright",
   "options": {
     "config": "{projectRoot}/playwright.config.ts"
-  }
+  },
+  "configurations": {
+    "development": {
+      "config": "{projectRoot}/playwright.config.dev.ts"
+    },
+    "staging": {
+      "config": "{projectRoot}/playwright.config.staging.ts"
+    },
+    "production": {
+      "config": "{projectRoot}/playwright.config.prod.ts"
+    }
+  }
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3e5405b and 9cf35bf.

📒 Files selected for processing (4)
  • apps/web/docker-compose.yml (1 hunks)
  • apps/web/playwright.config.ts (1 hunks)
  • apps/web/project.json (2 hunks)
  • apps/web/proxy.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/playwright.config.ts
  • apps/web/proxy.config.ts
🧰 Additional context used
📓 Path-based instructions (2)
apps/web/docker-compose.yml (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/project.json (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."

Comment on lines +27 to +66
curl -X PUT 'http://elasticsearch:9200/island-is-kstnl' -H 'Content-Type: application/json' -d'
{
\"settings\": {
\"number_of_shards\": 1,
\"number_of_replicas\": 1
},
\"mappings\": {
\"properties\": {
\"title\": {
\"type\": \"text\",
\"fields\": {
\"sort\": {
\"type\": \"keyword\"
}
}
},
\"dateUpdated\": {
\"type\": \"date\"
},
\"dateCreated\": {
\"type\": \"date\"
},
\"releaseDate\": {
\"type\": \"date\"
},
\"tags\": {
\"type\": \"nested\",
\"properties\": {
\"key\": {
\"type\": \"keyword\"
},
\"type\": {
\"type\": \"keyword\"
}
}
}
}
}
}';
"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve Elasticsearch index configuration and mappings

The current index configuration could be enhanced:

  1. Consider using a more structured index naming pattern (e.g., including environment/version)
  2. Single replica with single shard might not be optimal for scaling
  3. Missing analyzer configuration for the title field
  4. Consider adding field validations and additional mapping properties

Consider these improvements:

-      curl -X PUT 'http://elasticsearch:9200/island-is-kstnl' -H 'Content-Type: application/json' -d'
+      curl -X PUT 'http://elasticsearch:9200/web-content-v1' -H 'Content-Type: application/json' -d'
       {
         \"settings\": {
           \"number_of_shards\": 1,
-          \"number_of_replicas\": 1
+          \"number_of_replicas\": 0,
+          \"analysis\": {
+            \"analyzer\": {
+              \"custom_analyzer\": {
+                \"type\": \"custom\",
+                \"tokenizer\": \"standard\",
+                \"filter\": [
+                  \"lowercase\",
+                  \"asciifolding\"
+                ]
+              }
+            }
+          }
         },
         \"mappings\": {
           \"properties\": {
             \"title\": {
               \"type\": \"text\",
+              \"analyzer\": \"custom_analyzer\",
               \"fields\": {
                 \"sort\": {
                   \"type\": \"keyword\"
-                }
+                },
+                \"suggest\": {
+                  \"type\": \"completion\"
+                }
               }
             },

Also, consider adding validation rules for date fields and additional mapping properties for better search functionality.

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +1 to +15
version: '3'
services:
elasticsearch:
image: docker.io/elasticsearch:8.8.0
ports:
- 9200:9200
- 9300:9300
environment:
- discovery.type=single-node
- xpack.security.enabled=false
healthcheck:
test: ['CMD-SHELL', 'curl -f http://localhost:9200 || exit 1']
interval: 10s
retries: 10

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security and configuration improvements needed for Elasticsearch service

Several important considerations for the Elasticsearch configuration:

  1. Security is completely disabled which is risky even for development
  2. No memory limits are defined which could lead to resource exhaustion
  3. No persistent volume is configured, data will be lost on container restart
  4. Version is pinned to 8.8.0 without allowing patch updates

Consider applying these improvements:

 elasticsearch:
   image: docker.io/elasticsearch:8.8.0
+  volumes:
+    - elasticsearch-data:/usr/share/elasticsearch/data
   ports:
     - 9200:9200
     - 9300:9300
+  deploy:
+    resources:
+      limits:
+        memory: 2g
   environment:
     - discovery.type=single-node
-    - xpack.security.enabled=false
+    - xpack.security.enabled=true
+    - ELASTIC_PASSWORD=changeme
+    - bootstrap.memory_lock=true
+    - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
   healthcheck:
     test: ['CMD-SHELL', 'curl -f http://localhost:9200 || exit 1']
     interval: 10s
     retries: 10

+volumes:
+  elasticsearch-data:
📝 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
version: '3'
services:
elasticsearch:
image: docker.io/elasticsearch:8.8.0
ports:
- 9200:9200
- 9300:9300
environment:
- discovery.type=single-node
- xpack.security.enabled=false
healthcheck:
test: ['CMD-SHELL', 'curl -f http://localhost:9200 || exit 1']
interval: 10s
retries: 10
version: '3'
services:
elasticsearch:
image: docker.io/elasticsearch:8.8.0
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
ports:
- 9200:9200
- 9300:9300
deploy:
resources:
limits:
memory: 2g
environment:
- discovery.type=single-node
- xpack.security.enabled=true
- ELASTIC_PASSWORD=changeme
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
healthcheck:
test: ['CMD-SHELL', 'curl -f http://localhost:9200 || exit 1']
interval: 10s
retries: 10
volumes:
elasticsearch-data:

Comment on lines +150 to +154
"e2e": {
"executor": "@nx/playwright:playwright",
"options": {
"config": "{projectRoot}/playwright.config.ts"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Configure target dependencies for e2e tests

The e2e target should explicitly depend on required services to ensure proper test execution.

 "e2e": {
   "executor": "@nx/playwright:playwright",
   "options": {
     "config": "{projectRoot}/playwright.config.ts"
-  }
+  },
+  "dependsOn": [
+    "dev-services"
+  ]
 }
📝 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
"e2e": {
"executor": "@nx/playwright:playwright",
"options": {
"config": "{projectRoot}/playwright.config.ts"
}
"e2e": {
"executor": "@nx/playwright:playwright",
"options": {
"config": "{projectRoot}/playwright.config.ts"
},
"dependsOn": [
"dev-services"
]
}

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