Repository: DevOpsDynamite/DynaSearch
Pull request #140: Dev
Author: login: Aleksandergreg
Created: 2025-04-16T05:38:26Z | Merged: 2025-04-18T11:44:37Z

# Description

Added loggin for search, and made so that this gets saved in a Docker volume.  Added the log files to gitignore, so these doesn't get shared to the public. Critical business information hihi
**Related Issue:**  
If applicable, please reference the issue number that this pull request fixes:  
Fixes #124 #137 

# Type of Change

Please check the type(s) of changes your code introduces:

- [ ] **Bug fix:** Non-breaking change which fixes an issue.
- [x] **New feature:** Non-breaking change which adds functionality.
- [ ] **Breaking change:** Fix or feature that would cause existing functionality to change.
- [ ] **Documentation update:** Changes to documentation only.




# Checklist

Before creating this pull request, please ensure that your code meets the following requirements:

- [x] My code follows the style guidelines of this project.
- [x] I have performed a self-review of my own code.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have made corresponding changes to the documentation.
- [x] My changes generate no new warnings.
- [ ] Any dependent changes have been merged and published in downstream modules.



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced end-to-end (E2E) testing using Playwright, including test configuration, scripts, and workflows.
  - Added comprehensive Playwright tests for search, registration, login, about, and weather features.
  - Added a new SQL schema setup script for test databases.

- **Bug Fixes**
  - Ensured proper creation and permissions for the log directory in the Sinatra app container.

- **Chores**
  - Updated CI workflows to separate Ruby tests, Ruby linting, and Dockerfile linting.
  - Updated ignore patterns and added `.gitignore` for test artifacts.
  - Improved Docker Compose configuration with a dedicated log volume.

- **Refactor**
  - Renamed helper methods for consistency.
  - Updated session secret assignment logic for clarity.

- **Revert**
  - Removed route handlers for standard HTML pages from the Sinatra app.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Linked issue #124: Let them search - Week 2
## User Story 1: Log User Search Queries

**As a** development team member,
**I want** to log the search queries entered by users into a simple, accessible format (like a file or a basic database table),
**so that** we can analyze what users are searching for and make informed decisions about which external content sources to prioritize for scraping.

---

## Acceptance Criteria

- [x] When a user performs a search, the raw query string is recorded.
- [x] The logging mechanism is implemented using a lightweight approach suitable for Sinatra (e.g., Ruby's built-in `Logger`, writing to a file, or using `Rack::CommonLogger` if appropriate, avoiding heavy frameworks like ELK).
- [x] Log entries include at least the search query and a timestamp.
- [x] The logs are stored in a persistent way (e.g., a dedicated log file or a simple SQLite database table).
- [x] The logging implementation does not significantly impact search performance.
- [x] The team can easily access and review the logged search queries.

---

## Tasks

- [x] Research lightweight logging options available in Ruby/Sinatra (e.g., standard `Logger` class, `Rack::CommonLogger` middleware, simple file I/O, SQLite).
- [ ] Decide on the logging method and format (e.g., plain text file, CSV, JSON lines, SQLite table).
- [x] Configure the chosen logging mechanism within the Sinatra application.
- [x] Modify the search endpoint/handler to capture and log the user's query string before or after executing the search.
- [x] Ensure timestamps are included with each logged query.
- [x] Set up the log destination (e.g., create the log file with appropriate permissions, or create the SQLite database and table).
- [x] Test the search functionality to confirm queries are being logged correctly.
- [ ] Document the logging setup, including how to access the logs.

---

### INVEST Principle
_I: Independent, N: Negotiable, V: Valuable, E: Estimable, S: Small, T: Testable_

- **Independent:** Yes, implementing logging is a distinct task, although its value is realized in subsequent analysis and scraping decisions.
- **Negotiable:** Yes, the specific logging *method* (file vs. DB), log *format*, and log *location* are negotiable.
- **Valuable:** Yes, provides crucial data to understand user behavior and fulfill the primary motivation of the exercise.
- **Estimable:** Yes, the effort to implement basic logging in Sinatra is generally well-understood and estimable.
- **Small:** Yes, focuses solely on implementing the logging mechanism, keeping the scope constrained.
- **Testable:** Yes, can be tested by performing searches and verifying the log output.

---

### Additional Context / Notes (Optional)

- This story directly addresses the "Use logging to get insight" requirement.
- Per the exercise guidelines, avoid over-engineering. Sinatra can use Ruby's standard `Logger` easily, often configured in `config.ru` or the main application file. `request.logger.info "Search query: #{params[:query]}"` is a common pattern if using Rack's logger facilities. A simple `File.open('search.log', 'a') { |f| f.puts "#{Time.now} - #{params[:query]}" }` could also suffice initially.
- This provides the foundation for User Story 2.
Linked issue comments: user: login: Aleksandergreg
created_at: 2025-04-16T13:18:26Z
body: Just need to document this, and it's done. I have shared the commands to acces the logs for you in Discord for now :-) 
author_association: MEMBER
user: login: Aleksandergreg
created_at: 2025-04-16T13:19:16Z
body: Have also chosen to leave it stored in text for now. Could be a fun thing to monitor if our application gets slower when transfered to JSON instead. 
author_association: MEMBER

Diff:
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 1652624..c54182d 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -5,12 +5,13 @@ on:
     branches:
       - main
       - dev
-  workflow_dispatch:  # Allows manual triggering from GitHub UI
+  workflow_dispatch:
 
 jobs:
+  # Job 1: Run Ruby Tests
   test:
+    name: Ruby Tests
     runs-on: ubuntu-latest
-
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
@@ -18,50 +19,71 @@ jobs:
       - name: Set up Ruby
         uses: ruby/setup-ruby@v1
         with:
-          ruby-version: 3.4.2  
-          bundler-cache: true
+          ruby-version: 3.4.2
+          bundler-cache: true # Cache based on Gemfile.lock in root or specify working-directory
+
+      - name: Install system dependencies (for testing)
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y sqlite3 libsqlite3-dev # Needed for test DB
 
-      - name: Install dependencies
-        working-directory: sinatra  # Ensure we're inside the sinatra folder
+      - name: Install Ruby dependencies
+        working-directory: sinatra
         run: bundle install
 
       - name: Setup test database
-        working-directory: sinatra  # Ensure DB setup runs in the correct directory
+        working-directory: sinatra
         run: |
-          touch test/test_whoknows.db  # Ensure test DB file exists
-          sqlite3 test/test_whoknows.db < schema.sql  # Load schema
+          touch test/test_whoknows.db
+          sqlite3 test/test_whoknows.db < schema.sql
 
       - name: Run Minitest
-        working-directory: sinatra  # Run tests from the correct directory
+        working-directory: sinatra
         env:
-          RACK_ENV: test  # Ensure the app runs in test mode
+          RACK_ENV: test
         run: bundle exec ruby -Itest test/app_test.rb
 
+  # Job 2: Lint Ruby Code
+  lint-ruby:
+    name: RuboCop Linting
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
+
+      - name: Set up Ruby
+        uses: ruby/setup-ruby@v1
+        with:
+          ruby-version: 3.4.2
+          bundler-cache: true
+        # working-directory: ./sinatra # Add if Gemfile.lock is in ./sinatra
+
+      - name: Install Ruby dependencies (for RuboCop)
+        working-directory: sinatra
+        run: bundle install
+
       - name: Auto-correct RuboCop issues
         working-directory: sinatra
-        run: bundle exec rubocop -A || true  # Ensure CI doesn't fail on auto-fixes
+        run: bundle exec rubocop -A || true
 
-      - name: Run RuboCop (Code Linter)
+      - name: Run RuboCop
         working-directory: sinatra
-        run: bundle exec rubocop || true  # Allow non-critical failures
-      
-      - name: Install Hadolint
-        run: |
-          wget -O hadolint "https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64"
-          chmod +x hadolint
-          sudo mv hadolint /usr/local/bin/hadolint
+        run: bundle exec rubocop || true
 
-      # Verify Hadolint installation
-      - name: Verify Hadolint installation
-        run: |
-          hadolint --version
+  # Job 3: Lint Dockerfiles
+  lint-docker:
+    name: Dockerfile Linting
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
 
-      # Lint Dockerfile.dev
-      - name: Lint Dockerfile.dev
-        run: |
-          hadolint sinatra/Dockerfile.dev
+      - name: Lint Dockerfile.dev with Hadolint
+        uses: hadolint/hadolint-action@v3.1.0
+        with:
+          dockerfile: sinatra/Dockerfile.dev
 
-      # Lint Dockerfile.prod
-      - name: Lint Dockerfile.prod
-        run: |
-          hadolint sinatra/Dockerfile.prod
+      - name: Lint Dockerfile.prod with Hadolint
+        uses: hadolint/hadolint-action@v3.1.0
+        with:
+          dockerfile: sinatra/Dockerfile.prod
diff --git a/.github/workflows/continuous_delivery.yml b/.github/workflows/continuous_delivery.yml
index 4a5410e..7045556 100644
--- a/.github/workflows/continuous_delivery.yml
+++ b/.github/workflows/continuous_delivery.yml
@@ -1,7 +1,8 @@
 name: Continuous Delivery
 on:
   push:
-    branches: [ "main", "dev", "feature/refactor" ] # Added dev branch
+
+    branches: [ "main", "dev" ] # Added dev branch
 jobs:
   build-and-push:
     runs-on: ubuntu-latest
@@ -17,7 +18,7 @@ jobs:
       
       - name: Log in to GHCR
         uses: docker/login-action@v3
-        with:
+        with: 
           registry: ghcr.io
           username: ${{ secrets.GHCR_USERNAME }}
           password: ${{ secrets.GHCR_TOKEN }}
diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml
new file mode 100644
index 0000000..8de49c6
--- /dev/null
+++ b/.github/workflows/playwright.yml
@@ -0,0 +1,86 @@
+name: Playwright End-to-End Tests
+
+on:
+  push:
+    branches: [ dev, main ]
+  pull_request:
+    branches: [ dev, main ]
+  workflow_dispatch:
+
+
+# permissions:
+#   contents: write  # Needed for deploying to GitHub Pages
+
+jobs:
+  e2e:
+    runs-on: ubuntu-latest
+    timeout-minutes: 30
+
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v4
+
+    - name: Install SQLite3
+      run: sudo apt-get update && sudo apt-get install -y sqlite3 libsqlite3-dev
+
+    - name: Prepare test database
+      working-directory: sinatra
+      run: |
+        sqlite3 test/test_whoknows.db < schema_test.sql
+        sqlite3 test/test_whoknows.db < fts5.sql
+        sqlite3 test/test_whoknows.db "INSERT INTO pages_fts(rowid,content,language) SELECT rowid,content,language FROM pages;"
+
+    - name: Install Ruby & gems
+      uses: ruby/setup-ruby@v1
+      with:
+        ruby-version: 3.4
+        bundler-cache: true 
+        working-directory: sinatra
+
+    # - name: Start Sinatra app
+    #   working-directory: sinatra
+    #   run: bundle exec rackup -p 4568 &
+
+    # - name: Wait for Sinatra to be ready
+    #   run: |
+    #     echo "Waiting for Sinatra on port 4568..."
+    #     for i in {1..30}; do
+    #       if curl -s http://localhost:4568/health >/dev/null; then
+    #         echo "Sinatra is up!"
+    #         break
+    #       fi
+    #       sleep 1
+    #     done
+
+    - name: Setup Node.js
+      uses: actions/setup-node@v4
+      with:
+        node-version: lts/*
+
+    - name: Install Playwright dependencies
+      working-directory: sinatra/tests
+      run: |
+        npm ci
+        npx playwright install --with-deps
+
+    - name: Run Playwright tests
+      working-directory: sinatra/tests
+      env:
+        WEATHERBIT_API_KEY: ${{ secrets.WEATHERBIT_API_KEY }}
+      run: npx playwright test --reporter=html
+
+    - name: Upload Playwright report
+      uses: actions/upload-artifact@v4
+      if: always()
+      with:
+        name: playwright-report
+        path: sinatra/tests/playwright-report
+        retention-days: 7
+
+    # - name: Deploy report to GitHub Pages
+    #   if: always()
+    #   uses: peaceiris/actions-gh-pages@v3
+    #   with:
+    #     # # github_token: ${{ secrets.GITHUB_TOKEN }}
+    #     # publish_dir: sinatra/tests/playwright-report
+    #     # publish_branch: gh-pages
diff --git a/.gitignore b/.gitignore
index c5891ec..3c20ce4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,6 +55,7 @@ cover/
 *.pot
 
 # Django stuff:
+*.log.*
 *.log
 *.log.*
 local_settings.py
diff --git a/sinatra/app.rb b/sinatra/app.rb
index 7d546bb..795c865 100644
--- a/sinatra/app.rb
+++ b/sinatra/app.rb
@@ -22,7 +22,8 @@
 set :bind, '0.0.0.0'
 set :port, 4568
 enable :sessions
-set :session_secret, ENV.fetch('SESSION_SECRET', "default_secret_for_dev_#{SecureRandom.hex(32)}") # Added default for safety
+default_secret = "default_secret_for_dev_#{SecureRandom.hex(32)}"
+set :session_secret, ENV.fetch('SESSION_SECRET', default_secret) # Added default for safety
 set :root, File.dirname(__FILE__)
 set :views, File.join(settings.root, 'views')
 
@@ -67,7 +68,8 @@
 
   log_file_path = File.join(log_dir, 'development.log')
   # Use Ruby's standard Logger class
-  file_logger = Logger.new(log_file_path, 'daily') # 'daily' rotates logs daily, you can also use 'weekly' or just the path
+  # 'daily' rotates logs daily, you can also use 'weekly' or just the path
+  file_logger = Logger.new(log_file_path, 'daily') 
   file_logger.level = Logger::INFO # Set the logging level (DEBUG, INFO, WARN, ERROR, FATAL)
 
   # Tell Sinatra to use this logger instance. This often handles request logging too.
diff --git a/sinatra/benchmark_search.rb b/sinatra/benchmark_search.rb
index 800e906..72d167e 100644
--- a/sinatra/benchmark_search.rb
+++ b/sinatra/benchmark_search.rb
@@ -43,7 +43,9 @@
   fts5_time = Benchmark.measure do
     # Important: Use the exact FTS5 query structure you have now
     db.execute(
-      'SELECT p.title FROM pages p JOIN pages_fts f ON p.rowid = f.rowid WHERE f.pages_fts MATCH ? AND p.language = ? ORDER BY f.rank DESC',
+     'SELECT p.title FROM pages p JOIN pages_fts f ON p.rowid = f.rowid ' \
+     'WHERE f.pages_fts MATCH ? AND p.language = ? ' \
+     'ORDER BY f.rank DESC',
       [q, language]
     )
     # Note: We select only 'title' here just to reduce data transfer overhead during benchmark,
diff --git a/sinatra/docker-compose.prod.yml b/sinatra/docker-compose.prod.yml
index cde710b..1cab9ed 100644
--- a/sinatra/docker-compose.prod.yml
+++ b/sinatra/docker-compose.prod.yml
@@ -5,6 +5,7 @@ services:
       - .env
     volumes:
       - sinatra_data:/app/data
+      - sinatra_logs:/app/log
     restart: unless-stopped
 
   nginx:
@@ -33,3 +34,4 @@ volumes:
   sinatra_data:
   certbot_certs:
   certbot_www:
+  sinatra_logs:
diff --git a/sinatra/docker-entrypoint.sh b/sinatra/docker-entrypoint.sh
index 5ac6fc1..21d6148 100644
--- a/sinatra/docker-entrypoint.sh
+++ b/sinatra/docker-entrypoint.sh
@@ -6,6 +6,8 @@ set -e
 # Ensure the data directory AND ITS CONTENTS are writable by the non-root user.
 # Use -R for recursive ownership change.
 chown -R appuser:appuser /app/data
+mkdir -p /app/log
+chown -R appuser:appuser /app/log
 
 # Drop privileges to run the CMD as appuser.
 exec gosu appuser "$@"
\ No newline at end of file
diff --git a/sinatra/helpers/application_helpers.rb b/sinatra/helpers/application_helpers.rb
index 446808a..6a6dde4 100644
--- a/sinatra/helpers/application_helpers.rb
+++ b/sinatra/helpers/application_helpers.rb
@@ -75,7 +75,7 @@ def fetch_forecast
   end
 
   # Retrieves forecast data, using cache if valid, otherwise fetches fresh data.
-  def get_cached_forecast
+  def cached_forecast
     cache = settings.forecast_cache
     expiration = settings.forecast_cache_expiration
 
diff --git a/sinatra/routes/api.rb b/sinatra/routes/api.rb
index 3ef17b3..7a2070a 100644
--- a/sinatra/routes/api.rb
+++ b/sinatra/routes/api.rb
@@ -42,7 +42,7 @@
     content_type :json # Indicate JSON response
   
     # Get forecast data (potentially cached)
-    forecast_data = get_cached_forecast
+    forecast_data = cached_forecast
   
     # Check if the forecast data contains an error from the helper
     if forecast_data.key?('error')
diff --git a/sinatra/routes/pages.rb b/sinatra/routes/pages.rb
index e733611..a6f564b 100644
--- a/sinatra/routes/pages.rb
+++ b/sinatra/routes/pages.rb
@@ -50,7 +50,7 @@
   # GET /weather - Weather forecast page
   get '/weather' do
     # Fetch cached or fresh forecast data using helper
-    @forecast_data = get_cached_forecast
+    @forecast_data = cached_forecast
     # Render the weather view
     erb :weather
   end
diff --git a/sinatra/schema_test.sql b/sinatra/schema_test.sql
new file mode 100644
index 0000000..491dda7
--- /dev/null
+++ b/sinatra/schema_test.sql
@@ -0,0 +1,23 @@
+DROP TABLE IF EXISTS users;
+
+CREATE TABLE IF NOT EXISTS users (
+  id INTEGER PRIMARY KEY AUTOINCREMENT,
+  username TEXT NOT NULL UNIQUE,
+  email TEXT NOT NULL UNIQUE,
+  password TEXT NOT NULL
+);
+
+-- Create a default user, The password is 'password' (MD5 hashed)
+INSERT INTO users (username, email, password) 
+    VALUES ('test', 'keamonk1@stud.kea.dk', '123');
+
+
+CREATE TABLE IF NOT EXISTS pages (
+    title TEXT PRIMARY KEY UNIQUE,
+    url TEXT NOT NULL UNIQUE,
+    language TEXT NOT NULL CHECK(language IN ('en', 'da')) DEFAULT 'en', -- How you define ENUM type in SQLite
+    last_updated TIMESTAMP,
+    content TEXT NOT NULL
+);
+INSERT INTO pages (title, url, language, content)
+VALUES ('JavaScript Page','www','en','This page contains information about JavaScript.');
diff --git a/sinatra/tests/.gitignore b/sinatra/tests/.gitignore
new file mode 100644
index 0000000..fc5299a
--- /dev/null
+++ b/sinatra/tests/.gitignore
@@ -0,0 +1,5 @@
+node_modules/
+/test-results/
+/playwright-report/
+/blob-report/
+/playwright/.cache/
\ No newline at end of file
diff --git a/sinatra/tests/e2e/about.spec.js b/sinatra/tests/e2e/about.spec.js
new file mode 100644
index 0000000..7f9e0fd
--- /dev/null
+++ b/sinatra/tests/e2e/about.spec.js
@@ -0,0 +1,8 @@
+const { test, expect } = require('@playwright/test');
+
+test('about page shows mission', async ({ page }) => {
+  await page.goto('/about');
+  await expect(page).toHaveTitle('DynaSearch 🧨');
+  await expect(page.getByRole('heading', { name: 'Our mission' })).toBeVisible();
+  await expect(page.locator('p')).toContainText("We intend to build the world's best search engine!");
+});
\ No newline at end of file
diff --git a/sinatra/tests/e2e/login.spec.js b/sinatra/tests/e2e/login.spec.js
new file mode 100644
index 0000000..f8e3335
--- /dev/null
+++ b/sinatra/tests/e2e/login.spec.js
@@ -0,0 +1,33 @@
+const { test, expect } = require('@playwright/test');
+
+// Navigate to the login page before each test
+test.describe('Login Page', () => {
+  test.beforeEach(async ({ page }) => {
+    await page.goto('/login');
+  });
+
+  test('renders login form', async ({ page }) => {
+    await expect(page.getByRole('heading', { name: /log in/i })).toBeVisible();
+    await expect(page.locator('input[name="username"]')).toBeVisible();
+    await expect(page.locator('input[name="password"]')).toBeVisible();
+    await expect(page.getByRole('button', { name: /log in/i })).toBeVisible();
+  });
+
+  test('shows error on invalid credentials', async ({ page }) => {
+    await page.fill('input[name="username"]', 'wronguser');
+    await page.fill('input[name="password"]', 'badpass');
+    await page.click('input[type="submit"]');
+    await expect(page.locator('.error')).toContainText(/error/i);
+  });
+
+  // Requires seeded user: username 'test', password '123'
+  test.skip('allows successful login', async ({ page }) => {
+    await page.fill('input[name="username"]', 'test');
+    await page.fill('input[name="password"]', '123');
+    await page.click('input[type="submit"]');
+
+    // Verify redirect to home
+    expect(page.url()).toBe('/');
+    await expect(page.getByText('You were successfully logged in.')).toBeVisible();
+  });
+});
diff --git a/sinatra/tests/e2e/register.spec.js b/sinatra/tests/e2e/register.spec.js
new file mode 100644
index 0000000..5d57dac
--- /dev/null
+++ b/sinatra/tests/e2e/register.spec.js
@@ -0,0 +1,43 @@
+const { test, expect } = require('@playwright/test');
+
+test.describe('Registration Page', () => {
+    test.beforeEach(async ({ page }) => {
+        await page.goto('/register');
+      });
+
+  test('renders registration form correctly', async ({ page }) => {
+    // Check heading/form title
+    await expect(page.getByRole('heading', { name: /sign up/i })).toBeVisible();
+    // Check all inputs are there
+    await expect(page.locator('input[name="username"]')).toBeVisible();
+    await expect(page.locator('input[name="email"]')).toBeVisible();
+    await expect(page.locator('input[name="password"]')).toBeVisible();
+    await expect(page.locator('input[name="password2"]')).toBeVisible();
+    // Check submit button shows up
+    await expect(page.locator('input[type="submit"][value="Sign Up"]')).toBeVisible();
+  });
+
+  test('shows error when passwords do not match', async ({ page }) => {
+    await page.fill('input[name="username"]', 'newuser');
+    await page.fill('input[name="email"]', 'new@user.com');
+    await page.fill('input[name="password"]', 'password1');
+    await page.fill('input[name="password2"]', 'password2');
+    await page.click('input[type="submit"]');
+    // Should show password mismatch error
+    const errorLocator = page.locator('.error');
+    await expect(errorLocator).toBeVisible();
+    await expect(errorLocator).toContainText('The two passwords do not match');
+  });
+
+  test('allows successful registration', async ({ page }) => {
+    const unique = Date.now();
+    await page.fill('input[name="username"]', `user${unique}`);
+    await page.fill('input[name="email"]', `user${unique}@example.com`);
+    await page.fill('input[name="password"]', 'safepass');
+    await page.fill('input[name="password2"]', 'safepass');
+    await page.click('input[type="submit"]');
+    // Should redirect to home with success message
+    await expect(page).toHaveURL('/');
+    await expect(page.getByText('You were successfully registered and are now logged in.')).toBeVisible();
+  });
+});
diff --git a/sinatra/tests/e2e/search.spec.js b/sinatra/tests/e2e/search.spec.js
new file mode 100644
index 0000000..344c4b1
--- /dev/null
+++ b/sinatra/tests/e2e/search.spec.js
@@ -0,0 +1,46 @@
+const { test, expect } = require('@playwright/test');
+
+// Navigate to the home page before each test
+test.beforeEach(async ({ page }) => {
+  await page.goto('/');
+});
+
+const SEARCH_TERMS = {
+  valid: 'JavaScript',
+  invalid: 'unlikely_term_xyz'
+};
+
+
+test.describe('Search Functionality', () => {
+  test('should return results for a valid search term', async ({ page }) => {
+    // Search for a valid term
+    const input = page.getByPlaceholder('Search...');
+    await input.fill(SEARCH_TERMS.valid);
+    await input.press('Enter');
+
+    // Check the URL has the query param
+    const currentUrl = page.url();
+    expect(currentUrl).toContain(`?q=${SEARCH_TERMS.valid}`);
+
+    // Expect at least one result title containing the term
+    const titles = await page.locator('.search-result-title').allTextContents();
+    expect(titles.length).toBeGreaterThan(0);
+    expect(
+      titles.some(t => t.toLowerCase().includes(SEARCH_TERMS.valid.toLowerCase()))
+    ).toBeTruthy();
+  });
+
+  test('should show no results for an unlikely search term', async ({ page }) => {
+    // Search for a nonsense term
+    const input = page.getByPlaceholder('Search...');
+    await input.fill(SEARCH_TERMS.invalid);
+    await input.press('Enter');
+
+    // Check the URL updates with the search term
+    expect(page.url()).toContain(`?q=${SEARCH_TERMS.invalid}`);
+
+    // Check the URL updates with the search term
+    await expect(page.locator('.search-result-title')).toHaveCount(0);
+    await expect(page.locator('#results')).toBeEmpty();
+  });
+});
\ No newline at end of file
diff --git a/sinatra/tests/e2e/weather.spec.js b/sinatra/tests/e2e/weather.spec.js
new file mode 100644
index 0000000..c6d0710
--- /dev/null
+++ b/sinatra/tests/e2e/weather.spec.js
@@ -0,0 +1,42 @@
+const { test, expect } = require('@playwright/test');
+
+test.describe('Weather Endpoint', () => {
+  test('JSON API returns valid forecast or error', async ({ request }) => {
+    const response = await request.get('/api/weather');
+    // API should respond with either 200 (OK) or 503 (Service Unavailable)
+    const status = response.status();
+    expect([200, 503]).toContain(status);
+
+    const body = await response.json();
+    if (response.ok()) {
+      // Expect city name + forecast data
+      expect(body).toHaveProperty('city_name');
+      expect(body).toHaveProperty('data');
+      expect(Array.isArray(body.data)).toBe(true);
+      expect(body.data.length).toBeGreaterThan(0);
+    } else {
+      // Error response should include status: 'error' and a message
+      expect(body).toHaveProperty('status', 'error');
+      expect(body).toHaveProperty('message');
+      expect(typeof body.message).toBe('string');
+    }
+  });
+
+  test('UI weather page renders forecast or error', async ({ page }) => {
+    await page.goto('/weather');
+
+    // Heading should start with '7-Day Weather Forecast for'
+    await expect(
+      page.getByRole('heading', { name: /^7-Day Weather Forecast for/ })
+    ).toBeVisible();
+
+    // Check if error message is shown
+    if (await page.locator('p:has-text("Error:")').count() > 0) {
+      await expect(page.locator('p')).toContainText('Error:');
+    } else {
+      // Otherwise, assert there is at least one forecast item
+      const itemCount = await page.locator('ul li').count();
+      expect(itemCount).toBeGreaterThan(0); 
+    }
+  });
+});
diff --git a/sinatra/tests/package-lock.json b/sinatra/tests/package-lock.json
new file mode 100644
index 0000000..b0a5e54
--- /dev/null
+++ b/sinatra/tests/package-lock.json
@@ -0,0 +1,97 @@
+{
+    "name": "e2e",
+    "version": "1.0.0",
+    "lockfileVersion": 3,
+    "requires": true,
+    "packages": {
+        "": {
+            "name": "e2e",
+            "version": "1.0.0",
+            "license": "ISC",
+            "devDependencies": {
+                "@playwright/test": "^1.45.3",
+                "@types/node": "^20.14.11"
+            }
+        },
+        "node_modules/@playwright/test": {
+            "version": "1.51.1",
+            "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.51.1.tgz",
+            "integrity": "sha512-nM+kEaTSAoVlXmMPH10017vn3FSiFqr/bh4fKg9vmAdMfd9SDqRZNvPSiAHADc/itWak+qPvMPZQOPwCBW7k7Q==",
+            "dev": true,
+            "license": "Apache-2.0",
+            "dependencies": {
+                "playwright": "1.51.1"
+            },
+            "bin": {
+                "playwright": "cli.js"
+            },
+            "engines": {
+                "node": ">=18"
+            }
+        },
+        "node_modules/@types/node": {
+            "version": "20.17.30",
+            "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz",
+            "integrity": "sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==",
+            "dev": true,
+            "license": "MIT",
+            "dependencies": {
+                "undici-types": "~6.19.2"
+            }
+        },
+        "node_modules/fsevents": {
+            "version": "2.3.2",
+            "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
+            "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
+            "dev": true,
+            "hasInstallScript": true,
+            "license": "MIT",
+            "optional": true,
+            "os": [
+                "darwin"
+            ],
+            "engines": {
+                "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+            }
+        },
+        "node_modules/playwright": {
+            "version": "1.51.1",
+            "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.51.1.tgz",
+            "integrity": "sha512-kkx+MB2KQRkyxjYPc3a0wLZZoDczmppyGJIvQ43l+aZihkaVvmu/21kiyaHeHjiFxjxNNFnUncKmcGIyOojsaw==",
+            "dev": true,
+            "license": "Apache-2.0",
+            "dependencies": {
+                "playwright-core": "1.51.1"
+            },
+            "bin": {
+                "playwright": "cli.js"
+            },
+            "engines": {
+                "node": ">=18"
+            },
+            "optionalDependencies": {
+                "fsevents": "2.3.2"
+            }
+        },
+        "node_modules/playwright-core": {
+            "version": "1.51.1",
+            "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.51.1.tgz",
+            "integrity": "sha512-/crRMj8+j/Nq5s8QcvegseuyeZPxpQCZb6HNk3Sos3BlZyAknRjoyJPFWkpNn8v0+P3WiwqFF8P+zQo4eqiNuw==",
+            "dev": true,
+            "license": "Apache-2.0",
+            "bin": {
+                "playwright-core": "cli.js"
+            },
+            "engines": {
+                "node": ">=18"
+            }
+        },
+        "node_modules/undici-types": {
+            "version": "6.19.8",
+            "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
+            "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
+            "dev": true,
+            "license": "MIT"
+        }
+    }
+}
diff --git a/sinatra/tests/package.json b/sinatra/tests/package.json
new file mode 100644
index 0000000..d037fe5
--- /dev/null
+++ b/sinatra/tests/package.json
@@ -0,0 +1,16 @@
+{
+    "name": "e2e",
+    "version": "1.0.0",
+    "main": "index.js",
+"scripts": {
+    "test": "playwright test"
+},
+    "keywords": [],
+    "author": "",
+    "license": "ISC",
+    "description": "",
+    "devDependencies": {
+      "@playwright/test": "^1.45.3",
+      "@types/node": "^20.14.11"
+    }
+  }
\ No newline at end of file
diff --git a/sinatra/tests/playwright.config.js b/sinatra/tests/playwright.config.js
new file mode 100644
index 0000000..c74be95
--- /dev/null
+++ b/sinatra/tests/playwright.config.js
@@ -0,0 +1,39 @@
+// @ts-check
+const { defineConfig, devices } = require('@playwright/test');
+
+module.exports = defineConfig({
+  testDir: './e2e',           
+  fullyParallel: true,
+  forbidOnly: !!process.env.CI,
+  retries: process.env.CI ? 2 : 0,
+  workers: process.env.CI ? 1 : undefined,
+  reporter: 'html',
+  use: {
+    baseURL: 'http://127.0.0.1:4568',  
+    trace: 'on-first-retry',
+  }, 
+
+  webServer: {
+    command: 'DATABASE_PATH=./test/test_whoknows.db bundle exec rackup -p 4568',
+    url: 'http://127.0.0.1:4568',
+    cwd: '../',
+    reuseExistingServer: !process.env.CI,
+  },
+
+   /* Configure projects for major browsers */
+   projects: [
+    {
+      name: 'chromium',
+      use: { ...devices['Desktop Chrome'] },
+    },
+
+    {
+      name: 'firefox',
+      use: { ...devices['Desktop Firefox'] },
+    },
+
+    {
+      name: 'webkit',
+      use: { ...devices['Desktop Safari'] },
+    },]
+});


Reviews:
user: login: coderabbitai[bot]
body: **Actionable comments posted: 0**

<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>

<details>
<summary>.gitignore (1)</summary><blockquote>

`58-58`: **Remove duplicate ignore pattern for log files.**

The `*.log.*` pattern is already present at line 60. Keeping only one instance is sufficient and keeps the `.gitignore` file clean.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between de9dfaa77d475b69db78d3b0b19d10692fe83f72 and f056200c2855279cc73d322447d2e003da43c942.

</details>

<details>
<summary>📒 Files selected for processing (4)</summary>

* `.github/workflows/continuous_delivery.yml` (1 hunks)
* `.gitignore` (1 hunks)
* `sinatra/docker-compose.prod.yml` (2 hunks)
* `sinatra/docker-entrypoint.sh` (1 hunks)

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>sinatra/docker-entrypoint.sh (1)</summary>

`9-10`: **Log directory initialization and permissions are handled correctly.**

The script now ensures `/app/log` exists and is owned by `appuser`, which is necessary for persistent logging in Docker.

</details>
<details>
<summary>sinatra/docker-compose.prod.yml (1)</summary>

`8-8`: **Persistent log volume is correctly configured.**

Mounting `sinatra_logs` at `/app/log` and defining the volume ensures logs are persisted as intended.



Also applies to: 37-37

</details>
<details>
<summary>.github/workflows/continuous_delivery.yml (1)</summary>

`5-5`: **Workflow trigger branch list updated appropriately.**

The workflow will now only trigger on pushes to "main" and "dev", which matches the intended branch policy.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-16T05:40:42Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 0**

<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>

<details>
<summary>.github/workflows/continuous_delivery.yml (1)</summary><blockquote>

`21-21`: **Remove trailing spaces for YAML cleanliness.**

There is a trailing space at line 21. While this does not break the workflow, it's best practice to remove unnecessary whitespace to avoid potential YAML parsing issues in stricter environments.

```diff
-        with: 
+        with:
```

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 YAMLlint (1.35.1)</summary>

[error] 21-21: trailing spaces

(trailing-spaces)

</details>

</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between f056200c2855279cc73d322447d2e003da43c942 and 16c22ef9e7a1ca4841b8fb67ff607fc8f5be318b.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `.github/workflows/ci.yaml` (1 hunks)
* `.github/workflows/continuous_delivery.yml` (2 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🪛 YAMLlint (1.35.1)</summary>

<details>
<summary>.github/workflows/continuous_delivery.yml</summary>

[error] 21-21: trailing spaces

(trailing-spaces)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>.github/workflows/continuous_delivery.yml (1)</summary>

`5-5`: **Branch trigger update is correct.**

Limiting the workflow to "main" and "dev" is clear and aligns with standard CD practices.

</details>
<details>
<summary>.github/workflows/ci.yaml (2)</summary>

`8-8`: **Addition of workflow_dispatch is a good practice.**

Allows manual triggering of CI, which is helpful for maintainers.

---

`11-90`: **CI workflow modularization and improvements are well executed.**

Splitting jobs for tests, Ruby linting, and Dockerfile linting increases clarity and maintainability. Use of official actions and explicit dependency installation is robust.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-16T15:19:59Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 0**

<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>

<details>
<summary>sinatra/helpers/application_helpers.rb (1)</summary><blockquote>

`78-105`: **Method renaming follows Ruby conventions** 

Renaming from `get_cached_forecast` to `cached_forecast` aligns with Ruby's idiomatic style, where methods that return values typically don't use a `get_` prefix. The implementation logic remains unchanged.



The RuboCop static analysis identified this method as having high ABC complexity (Assignment Branch Condition size). Consider refactoring this method into smaller, more focused methods for better maintainability.

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 RuboCop (1.73)</summary>

[convention] 78-105: Assignment Branch Condition size for cached_forecast is too high. [<5, 24, 6> 25.24/23]

(Metrics/AbcSize)

---

[convention] 89-99: Do not use `unless` with `else`. Rewrite these with the positive case first.

(Style/UnlessElse)

</details>

</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 16c22ef9e7a1ca4841b8fb67ff607fc8f5be318b and fde8af34abc5d4c8237fdffe7009e2f45d2f3c91.

</details>

<details>
<summary>📒 Files selected for processing (5)</summary>

* `sinatra/app.rb` (2 hunks)
* `sinatra/benchmark_search.rb` (1 hunks)
* `sinatra/helpers/application_helpers.rb` (1 hunks)
* `sinatra/routes/api.rb` (1 hunks)
* `sinatra/routes/pages.rb` (1 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (1)</summary>

* sinatra/benchmark_search.rb

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (2)</summary>

<details>
<summary>sinatra/routes/api.rb (1)</summary><blockquote>

<details>
<summary>sinatra/helpers/application_helpers.rb (1)</summary>

* `cached_forecast` (78-105)

</details>

</blockquote></details>
<details>
<summary>sinatra/routes/pages.rb (1)</summary><blockquote>

<details>
<summary>sinatra/helpers/application_helpers.rb (1)</summary>

* `cached_forecast` (78-105)

</details>

</blockquote></details>

</details><details>
<summary>🪛 RuboCop (1.73)</summary>

<details>
<summary>sinatra/helpers/application_helpers.rb</summary>

[convention] 78-105: Assignment Branch Condition size for cached_forecast is too high. [<5, 24, 6> 25.24/23]

(Metrics/AbcSize)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (4)</summary><blockquote>

<details>
<summary>sinatra/app.rb (2)</summary>

`25-26`: **Improved session secret generation code**

Breaking out the default secret generation to a separate variable improves readability while maintaining the same security level with SecureRandom.hex(32).

---

`71-72`: **Improved comment placement**

Moving the comment about log rotation directly above the logger initialization line creates a clearer connection between the documentation and the code it describes.

</details>
<details>
<summary>sinatra/routes/api.rb (1)</summary>

`45-45`: **Updated method call to match renamed helper**

The change from `get_cached_forecast` to `cached_forecast` maintains consistency with the renamed helper method in application_helpers.rb.

</details>
<details>
<summary>sinatra/routes/pages.rb (1)</summary>

`53-53`: **Updated method call to match renamed helper**

The change from `get_cached_forecast` to `cached_forecast` maintains consistency with the renamed helper method in application_helpers.rb.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-17T08:08:06Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 1**

<details>
<summary>🧹 Nitpick comments (11)</summary><blockquote>

<details>
<summary>sinatra/tests/e2e/login.spec.js (2)</summary><blockquote>

`16-21`: **Consider using consistent selector approaches.**

While the test logic works well, there's an inconsistency in selector usage. The form rendering test uses role-based selectors, but this test uses direct CSS selectors.

For consistency, consider using role-based selectors here as well:

```diff
- await page.fill('input[name="username"]', 'wronguser');
- await page.fill('input[name="password"]', 'badpass');
- await page.click('input[type="submit"]');
+ await page.getByRole('textbox', { name: /username/i }).fill('wronguser');
+ await page.getByRole('textbox', { name: /password/i }).fill('badpass');
+ await page.getByRole('button', { name: /log in/i }).click();
```

---

`23-32`: **Use toHaveURL instead of direct URL comparison.**

The skipped test correctly handles the test case that requires seeded data. However, the URL verification could be improved.

```diff
- expect(page.url()).toBe('/');
+ await expect(page).toHaveURL('/');
```

Using `toHaveURL()` is preferred as it's an async assertion that waits for the condition to be met, which is more reliable in end-to-end tests.

</blockquote></details>
<details>
<summary>sinatra/tests/e2e/register.spec.js (1)</summary><blockquote>

`3-6`: **Fix indentation inconsistency.**

The indentation in the beforeEach block uses 8 spaces while the rest of the file uses 2 spaces.

```diff
 test.describe('Registration Page', () => {
-    test.beforeEach(async ({ page }) => {
-        await page.goto('/register');
-      });
+  test.beforeEach(async ({ page }) => {
+    await page.goto('/register');
+  });
```

</blockquote></details>
<details>
<summary>sinatra/tests/e2e/search.spec.js (1)</summary><blockquote>

`33-45`: **Fix duplicate comment on line 42.**

There's a duplicate comment that should be updated to reflect the actual check being performed.

```diff
 // Check the URL updates with the search term
 expect(page.url()).toContain(`?q=${SEARCH_TERMS.invalid}`);

-// Check the URL updates with the search term
+// Check that no search results are found
 await expect(page.locator('.search-result-title')).toHaveCount(0);
 await expect(page.locator('#results')).toBeEmpty();
```

</blockquote></details>
<details>
<summary>sinatra/tests/e2e/weather.spec.js (2)</summary><blockquote>

`8-8`: **Consider expanding error status code checking**

The test only accounts for HTTP status codes 200 and 503, but there might be other valid error codes like 400, 404, or 429 (rate limiting) that could be returned by the weather API.

```diff
- expect([200, 503]).toContain(status);
+ expect([200, 400, 404, 429, 503]).toContain(status);
```

---

`39-39`: **Remove trailing whitespace**

There's an unnecessary trailing space after the semicolon.

```diff
- expect(itemCount).toBeGreaterThan(0); 
+ expect(itemCount).toBeGreaterThan(0);
```

</blockquote></details>
<details>
<summary>sinatra/tests/playwright.config.js (2)</summary><blockquote>

`17-17`: **Consider making the database path configurable via environment variable**

The database path is hardcoded in the command. For improved flexibility, consider reading it from an environment variable with a default fallback.

```diff
- command: 'DATABASE_PATH=./test/test_whoknows.db bundle exec rackup -p 4568',
+ command: 'DATABASE_PATH=${TEST_DB_PATH:-./test/test_whoknows.db} bundle exec rackup -p 4568',
```

---

`38-38`: **Fix formatting in projects array closing**

There's a formatting issue with the closing bracket of the projects array.

```diff
- },]
+ }
+ ]
```

</blockquote></details>
<details>
<summary>.github/workflows/playwright.yml (3)</summary><blockquote>

`29-31`: **Consider using a dedicated SQL file for FTS table population**

Line 31 contains a direct SQLite command to populate the full-text search table. For better maintainability, consider moving this to a dedicated SQL file like you did with `schema_test.sql` and `fts5.sql`.

```diff
- sqlite3 test/test_whoknows.db "INSERT INTO pages_fts(rowid,content,language) SELECT rowid,content,language FROM pages;"
+ sqlite3 test/test_whoknows.db < fts_populate.sql
```

And create a new file `sinatra/fts_populate.sql` with:
```sql
INSERT INTO pages_fts(rowid,content,language) SELECT rowid,content,language FROM pages;
```

---

`40-53`: **Decide on server startup strategy**

There are commented-out sections for starting the Sinatra app and waiting for it to be ready. Since the Playwright config already handles starting the server, either remove these comments or document why they're kept.

If these are no longer needed, consider removing them to keep the workflow file clean. If they're kept for reference, add a comment explaining why.

---

`80-86`: **Decide on report deployment strategy**

The GitHub Pages deployment section is commented out. If this is a planned feature, add a TODO comment with the next steps needed to implement it. If it's not planned, consider removing these comments.

If you intend to implement this feature later, consider adding a TODO comment:
```yaml
# TODO: Implement GitHub Pages deployment for Playwright reports once permissions are configured
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between fde8af34abc5d4c8237fdffe7009e2f45d2f3c91 and dc87e22d634e8544064202d55cc1e7f4b1454959.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `sinatra/tests/package-lock.json` is excluded by `!**/package-lock.json`

</details>

<details>
<summary>📒 Files selected for processing (10)</summary>

* `.github/workflows/playwright.yml` (1 hunks)
* `sinatra/schema_test.sql` (1 hunks)
* `sinatra/tests/.gitignore` (1 hunks)
* `sinatra/tests/e2e/about.spec.js` (1 hunks)
* `sinatra/tests/e2e/login.spec.js` (1 hunks)
* `sinatra/tests/e2e/register.spec.js` (1 hunks)
* `sinatra/tests/e2e/search.spec.js` (1 hunks)
* `sinatra/tests/e2e/weather.spec.js` (1 hunks)
* `sinatra/tests/package.json` (1 hunks)
* `sinatra/tests/playwright.config.js` (1 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (3)</summary>

* sinatra/tests/.gitignore
* sinatra/tests/package.json
* sinatra/schema_test.sql

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (2)</summary>

* GitHub Check: e2e
* GitHub Check: e2e

</details>

<details>
<summary>🔇 Additional comments (10)</summary><blockquote>

<details>
<summary>sinatra/tests/e2e/about.spec.js (1)</summary>

`1-8`: **LGTM! Well-structured test for the about page.**

This test effectively validates the critical elements of the about page: title, mission heading, and descriptive text. The selectors used are appropriate and follow Playwright best practices.

</details>
<details>
<summary>sinatra/tests/e2e/login.spec.js (1)</summary>

`4-14`: **LGTM! Well-structured test setup and form rendering test.**

Good organization with test.beforeEach for the login page navigation. The form rendering test uses appropriate role-based selectors to verify all form elements.

</details>
<details>
<summary>sinatra/tests/e2e/register.spec.js (3)</summary>

`8-18`: **LGTM! Well-structured registration form test.**

The form rendering test appropriately checks for all required elements with clear sections for the heading, inputs, and submit button.

---

`20-30`: **LGTM! Good validation test for password mismatch.**

This test effectively validates the password mismatch error case with appropriate error message verification.

---

`32-42`: **LGTM! Strong approach to testing successful registration.**

Using `Date.now()` to generate unique usernames is a good practice to avoid test data conflicts. The redirect and success message verification provide good end-to-end validation.

</details>
<details>
<summary>sinatra/tests/e2e/search.spec.js (2)</summary>

`8-11`: **LGTM! Good use of constants for search terms.**

Defining search terms as constants improves readability and maintainability.

---

`15-31`: **LGTM! Comprehensive test for valid search results.**

The test covers all the critical aspects of searching with a valid term: URL parameters, result count, and content verification.

</details>
<details>
<summary>sinatra/tests/e2e/weather.spec.js (1)</summary>

`1-42`: **Well-structured test suite with comprehensive error handling**

The test suite effectively covers both the API and UI aspects of the weather feature, handling both success and error scenarios appropriately. This is excellent test coverage.

</details>
<details>
<summary>sinatra/tests/playwright.config.js (1)</summary>

`1-39`: **Well-configured Playwright setup with cross-browser testing**

The configuration properly sets up parallel test execution, CI-specific settings, and multiple browser targets. Good job including all three major browser engines.

</details>
<details>
<summary>.github/workflows/playwright.yml (1)</summary>

`1-87`: **Well-structured GitHub Actions workflow for E2E testing**

The workflow correctly sets up all necessary dependencies and configurations for running the Playwright tests, including database preparation and artifact uploading.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-18T09:24:15Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 2**

<details>
<summary>♻️ Duplicate comments (1)</summary><blockquote>

<details>
<summary>.github/workflows/playwright.yml (1)</summary><blockquote>

`11-13`: **Decision needed: GitHub Pages deployment**

The permissions section for GitHub Pages deployment is commented out. Either implement the feature or remove these comments.


This was mentioned in a previous review. Please decide whether to:
1. Fully implement the GitHub Pages reporting feature (uncomment this section and lines 80-86)
2. Remove all commented GitHub Pages related code for clarity

</blockquote></details>

</blockquote></details>

<details>
<summary>🧹 Nitpick comments (9)</summary><blockquote>

<details>
<summary>.github/workflows/continuous_delivery.yml (1)</summary><blockquote>

`21-21`: **Remove trailing whitespace.**

There's trailing whitespace after "with:" which should be removed to maintain clean YAML formatting.

```diff
-        with: 
+        with:
```

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 YAMLlint (1.35.1)</summary>

[error] 21-21: trailing spaces

(trailing-spaces)

</details>

</details>

</blockquote></details>
<details>
<summary>sinatra/helpers/application_helpers.rb (1)</summary><blockquote>

`78-105`: **Consider breaking down the method for improved maintainability.**

The method has a high complexity score (ABC size of 25.24/23). Consider refactoring into smaller helper methods for better maintainability and testability.

For example:
```diff
 # Retrieves forecast data, using cache if valid, otherwise fetches fresh data.
 def cached_forecast
   cache = settings.forecast_cache
   expiration = settings.forecast_cache_expiration

   # Check cache validity using UTC time for comparison
   # Use Time.now.utc for consistent time zone handling
   if cache.nil? || expiration < Time.now.utc
-    logger.info "Weather forecast cache miss or expired. Fetching new data."
-    new_forecast = fetch_forecast
-
-    # Update cache only if the fetch was successful (no 'error' key)
-    unless new_forecast.key?('error')
-      settings.forecast_cache = new_forecast
-      # Use Time.now.utc when setting the new expiration time
-      settings.forecast_cache_expiration = Time.now.utc + 3600 # 1 hour cache
-      logger.info "Weather forecast cache updated."
-      return new_forecast # Return the newly fetched data
-    else
-      # Log failure but return the error hash from fetch_forecast
-      logger.warn "Failed to fetch new forecast data. Returning error."
-      return new_forecast
-    end
+    fetch_and_update_cache
   else
     # Cache hit, return cached data
     logger.debug "Weather forecast cache hit."
     return cache
   end
 end
+
+ # Helper method to fetch and update the forecast cache
+ def fetch_and_update_cache
+   logger.info "Weather forecast cache miss or expired. Fetching new data."
+   new_forecast = fetch_forecast
+
+   # Update cache only if the fetch was successful (no 'error' key)
+   unless new_forecast.key?('error')
+     update_forecast_cache(new_forecast)
+   else
+     # Log failure but return the error hash from fetch_forecast
+     logger.warn "Failed to fetch new forecast data. Returning error."
+   end
+   new_forecast
+ end
+
+ # Helper method to update the forecast cache
+ def update_forecast_cache(forecast)
+   settings.forecast_cache = forecast
+   # Use Time.now.utc when setting the new expiration time
+   settings.forecast_cache_expiration = Time.now.utc + 3600 # 1 hour cache
+   logger.info "Weather forecast cache updated."
+ end
```

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 RuboCop (1.73)</summary>

[convention] 78-105: Assignment Branch Condition size for cached_forecast is too high. [<5, 24, 6> 25.24/23]

(Metrics/AbcSize)

---

[convention] 89-99: Do not use `unless` with `else`. Rewrite these with the positive case first.

(Style/UnlessElse)

</details>

</details>

</blockquote></details>
<details>
<summary>sinatra/schema_test.sql (1)</summary><blockquote>

`15-21`: **Consider adding search indexes to the pages table.**

Since this project is focused on search functionality (DynaSearch), consider adding full-text search indexes to the pages table to improve search performance.

For SQLite, you could add:

```sql
-- Add FTS5 virtual table for searching pages
CREATE VIRTUAL TABLE IF NOT EXISTS pages_fts USING fts5(
  title, 
  content, 
  content='pages', 
  tokenize='porter unicode61'
);

-- Create triggers to keep FTS table in sync
CREATE TRIGGER IF NOT EXISTS pages_ai AFTER INSERT ON pages BEGIN
  INSERT INTO pages_fts(rowid, title, content) VALUES (new.rowid, new.title, new.content);
END;
```

</blockquote></details>
<details>
<summary>sinatra/tests/e2e/search.spec.js (1)</summary><blockquote>

`33-45`: **Duplicate comment on lines 39-42**

Line 42 repeats the same comment as line 39, but the actions in lines 43-44 are actually checking for no results.

```diff
     // Check the URL updates with the search term
     expect(page.url()).toContain(`?q=${SEARCH_TERMS.invalid}`);
 
-    // Check the URL updates with the search term
+    // Verify no results are displayed
     await expect(page.locator('.search-result-title')).toHaveCount(0);
     await expect(page.locator('#results')).toBeEmpty();
```

</blockquote></details>
<details>
<summary>sinatra/tests/playwright.config.js (1)</summary><blockquote>

`16-21`: **Web server configuration uses hardcoded paths**

The database path and port are hardcoded in the command. Consider using environment variables for these values to make the configuration more flexible.

```diff
   webServer: {
-    command: 'DATABASE_PATH=./test/test_whoknows.db bundle exec rackup -p 4568',
+    command: `DATABASE_PATH=${process.env.TEST_DB_PATH || './test/test_whoknows.db'} bundle exec rackup -p ${process.env.TEST_PORT || 4568}`,
     url: 'http://127.0.0.1:4568',
     cwd: '../',
     reuseExistingServer: !process.env.CI,
   },
```

</blockquote></details>
<details>
<summary>sinatra/tests/e2e/weather.spec.js (1)</summary><blockquote>

`25-41`: **Well-implemented UI test with conditional assertions**

The UI test properly handles both success and error states of the weather page by:
1. Verifying the heading is always visible
2. Conditionally testing either the error message or forecast items

This makes the test resilient to different API states without requiring mocks.


```diff
-      expect(itemCount).toBeGreaterThan(0); 
+      expect(itemCount).toBeGreaterThan(0);
```

</blockquote></details>
<details>
<summary>.github/workflows/playwright.yml (3)</summary><blockquote>

`33-39`: **Remove trailing whitespace**

There's a trailing space after `bundler-cache: true` on line 37.


```diff
-        bundler-cache: true 
+        bundler-cache: true
```

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 YAMLlint (1.35.1)</summary>

[error] 37-37: trailing spaces

(trailing-spaces)

</details>

</details>

---

`40-54`: **Decide on Sinatra app startup approach**

These commented steps for starting the Sinatra app suggest you've chosen a different approach (likely in the Playwright config). Consider removing these comments if they're no longer needed to keep the workflow file clean.

---

`80-86`: **Clean up GitHub Pages deployment comments**

The commented GitHub Pages deployment configuration contains doubly-commented lines (`# #`), indicating indecision or confusion. Either:

1. Implement this feature completely (remove comments and configure correctly)
2. Remove these lines entirely to keep the workflow file clean

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 13994409ab03421d064f137fd7f414b9cad6f8ba and 7f5aa57902f49bec3e8615abb130dd0c888f8106.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `sinatra/tests/package-lock.json` is excluded by `!**/package-lock.json`

</details>

<details>
<summary>📒 Files selected for processing (20)</summary>

* `.github/workflows/ci.yaml` (1 hunks)
* `.github/workflows/continuous_delivery.yml` (2 hunks)
* `.github/workflows/playwright.yml` (1 hunks)
* `.gitignore` (1 hunks)
* `sinatra/app.rb` (2 hunks)
* `sinatra/benchmark_search.rb` (1 hunks)
* `sinatra/docker-compose.prod.yml` (2 hunks)
* `sinatra/docker-entrypoint.sh` (1 hunks)
* `sinatra/helpers/application_helpers.rb` (1 hunks)
* `sinatra/routes/api.rb` (1 hunks)
* `sinatra/routes/pages.rb` (1 hunks)
* `sinatra/schema_test.sql` (1 hunks)
* `sinatra/tests/.gitignore` (1 hunks)
* `sinatra/tests/e2e/about.spec.js` (1 hunks)
* `sinatra/tests/e2e/login.spec.js` (1 hunks)
* `sinatra/tests/e2e/register.spec.js` (1 hunks)
* `sinatra/tests/e2e/search.spec.js` (1 hunks)
* `sinatra/tests/e2e/weather.spec.js` (1 hunks)
* `sinatra/tests/package.json` (1 hunks)
* `sinatra/tests/playwright.config.js` (1 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (5)</summary>

* sinatra/benchmark_search.rb
* sinatra/routes/api.rb
* sinatra/tests/.gitignore
* sinatra/tests/package.json
* sinatra/routes/pages.rb

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (5)</summary>

* sinatra/docker-entrypoint.sh
* .gitignore
* sinatra/app.rb
* sinatra/docker-compose.prod.yml
* .github/workflows/ci.yaml

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (3)</summary>

<details>
<summary>sinatra/tests/playwright.config.js (5)</summary><blockquote>

<details>
<summary>sinatra/tests/e2e/login.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/about.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/search.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/register.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/weather.spec.js (1)</summary>

* `require` (1-1)

</details>

</blockquote></details>
<details>
<summary>sinatra/tests/e2e/search.spec.js (5)</summary><blockquote>

<details>
<summary>sinatra/tests/e2e/login.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/about.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/register.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/playwright.config.js (1)</summary>

* `require` (2-2)

</details>
<details>
<summary>sinatra/tests/e2e/weather.spec.js (1)</summary>

* `require` (1-1)

</details>

</blockquote></details>
<details>
<summary>sinatra/tests/e2e/weather.spec.js (5)</summary><blockquote>

<details>
<summary>sinatra/tests/e2e/login.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/about.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/search.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/e2e/register.spec.js (1)</summary>

* `require` (1-1)

</details>
<details>
<summary>sinatra/tests/playwright.config.js (1)</summary>

* `require` (2-2)

</details>

</blockquote></details>

</details><details>
<summary>🪛 YAMLlint (1.35.1)</summary>

<details>
<summary>.github/workflows/playwright.yml</summary>

[error] 37-37: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>.github/workflows/continuous_delivery.yml</summary>

[error] 21-21: trailing spaces

(trailing-spaces)

</details>

</details>
<details>
<summary>🪛 RuboCop (1.73)</summary>

<details>
<summary>sinatra/helpers/application_helpers.rb</summary>

[convention] 78-105: Assignment Branch Condition size for cached_forecast is too high. [<5, 24, 6> 25.24/23]

(Metrics/AbcSize)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (1)</summary>

* GitHub Check: e2e

</details>

<details>
<summary>🔇 Additional comments (18)</summary><blockquote>

<details>
<summary>.github/workflows/continuous_delivery.yml (1)</summary>

`4-5`: **Appropriate update to the workflow trigger branches.**

Switching from "feature/refactor" to "dev" for the continuous delivery workflow is a good change that aligns with standard Git workflow practices.

</details>
<details>
<summary>sinatra/helpers/application_helpers.rb (1)</summary>

`78-78`: **Good method naming improvement.**

Renaming from `get_cached_forecast` to `cached_forecast` follows Ruby conventions by removing the redundant "get_" prefix while maintaining clarity.

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 RuboCop (1.73)</summary>

[convention] 78-105: Assignment Branch Condition size for cached_forecast is too high. [<5, 24, 6> 25.24/23]

(Metrics/AbcSize)

</details>

</details>

</details>
<details>
<summary>sinatra/tests/e2e/about.spec.js (1)</summary>

`3-8`: **Well-structured Playwright test.**

This test effectively checks the critical elements of the about page. Good use of Playwright's role-based selectors and appropriate assertions.

</details>
<details>
<summary>sinatra/tests/e2e/login.spec.js (3)</summary>

`1-8`: **Well-structured test setup with clear navigation**

The test organization with a `beforeEach` hook that navigates to the login page before each test is a good practice that reduces code duplication and ensures consistent test preconditions.

---

`9-14`: **Good use of role-based and attribute selectors**

Using a combination of role-based selectors (getByRole) and attribute selectors (locator) follows Playwright best practices and makes tests more resilient to UI implementation changes.

---

`16-21`: **Valid error case testing**

Testing the error scenario with invalid credentials is important for verifying proper user feedback. The test correctly checks for the presence of an error message.

</details>
<details>
<summary>sinatra/tests/e2e/search.spec.js (2)</summary>

`1-11`: **Good use of constants for test data**

Defining search terms as constants at the top of the file improves maintainability and makes it clear what values are being tested.

---

`14-31`: **Well-structured positive test case**

The test properly validates multiple aspects of the search functionality, including URL updates and result content verification. The use of case-insensitive comparison in line 29 is a good practice.

</details>
<details>
<summary>sinatra/tests/playwright.config.js (2)</summary>

`1-14`: **Well-configured Playwright settings with CI awareness**

The configuration effectively handles different environments (CI vs local) with appropriate settings for retries, parallel execution, and reporting. This ensures tests run reliably in both scenarios.

---

`23-39`: **Good cross-browser test coverage**

Testing across multiple browsers (Chromium, Firefox, WebKit) ensures the application works consistently for different users. The use of Playwright's device configurations simplifies this setup.

</details>
<details>
<summary>sinatra/tests/e2e/register.spec.js (3)</summary>

`1-18`: **Comprehensive form validation test**

The test thoroughly checks all form elements, which helps ensure the UI renders correctly. The combination of role-based and attribute selectors follows Playwright best practices.

---

`20-30`: **Good validation of error handling**

Testing the password mismatch scenario is important for verifying error handling. The test properly checks both the visibility and content of the error message.

---

`32-42`: **Excellent use of unique data for registration test**

Using timestamp-based unique values for username and email prevents test data collisions and potential test failures due to duplicate registrations. This is a best practice for registration tests.

</details>
<details>
<summary>sinatra/tests/e2e/weather.spec.js (2)</summary>

`1-3`: **Good implementation of Playwright test structure!**

The test suite is well-structured with proper imports and test organization, matching the pattern used in other test files.

---

`4-23`: **Well-designed API test with thorough error handling**

This test effectively validates both success and error paths:
- Properly checks for both 200 and 503 status codes
- For success: Verifies expected properties and data structure
- For errors: Confirms proper error format with status and message

The conditional testing logic ensures robust validation regardless of the API state.

</details>
<details>
<summary>.github/workflows/playwright.yml (3)</summary>

`1-9`: **Well-configured workflow triggers**

The workflow is properly set up to run on:
- Pushes to dev/main branches
- Pull requests to dev/main branches
- Manual workflow dispatch

This ensures comprehensive test coverage at appropriate points in the development cycle.

---

`26-32`: **Well-structured database preparation**

The test database setup is comprehensive:
1. Applies schema from SQL files
2. Sets up full-text search
3. Populates the virtual table

This ensures tests run against a properly configured database environment.

---

`66-71`: **Good security practice with API key**

Properly passing the WeatherBit API key as an environment variable from GitHub secrets follows security best practices. This ensures the key isn't exposed in logs or code.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-18T10:36:35Z
user: login: theaskou
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-18T11:44:23Z

Review comments:
diff_hunk: @@ -0,0 +1,86 @@
+name: Playwright End-to-End Tests
+
+on:
+  push:
+    branches: [ dev, main ]
+  pull_request:
+    branches: [ dev, main ]
+  workflow_dispatch:
+
+
+# permissions:
+#   contents: write  # Needed for deploying to GitHub Pages
path: .github/workflows/playwright.yml
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Decide on GitHub Pages deployment strategy**

The permissions section is commented out. If you plan to deploy reports to GitHub Pages in the future, consider either removing these comments or implementing the feature properly.

---

🌐 Web query:

```web
How to deploy Playwright reports to GitHub Pages?
```

💡 Result:

## How to Deploy Playwright Reports to GitHub Pages

Deploying Playwright HTML reports to GitHub Pages is a practical way to make your browser test results easily accessible to your team or stakeholders. Below is a step-by-step guide to automate this process using GitHub Actions.

---

**1. Enable GitHub Pages on Your Repository**

- Create a `gh-pages` branch (you can do this manually or let an action manage it)[2][5].
- In the repository settings, enable GitHub Pages and select the `gh-pages` branch as the source[2][5].

---

**2. Use the Playwright HTML Reporter**

- Ensure you are using Playwright version 1.17.0 or newer, as the HTML reporter generates a static site[5][6].
- In your test command, specify the HTML reporter:

  ```bash
  npx playwright test --reporter=html
  ```

  This creates a `playwright-report` directory containing static HTML files[5][6].

---

**3. Set Up a GitHub Actions Workflow**

Add or update a GitHub Actions workflow `.github/workflows/playwright.yml` to:

- Install dependencies and browsers
- Run Playwright tests and generate the report
- Deploy the `playwright-report` folder to GitHub Pages using the popular [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) GitHub Action[1][5].

**Example workflow snippet:**

```yaml
name: Playwright Tests and Publish Report

on:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18
      - name: Install dependencies
        run: npm ci
      - name: Install Playwright browsers
        run: npx playwright install --with-deps
      - name: Run Playwright tests
        run: npx playwright test --reporter=html
      - name: Deploy report to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./playwright-report
```
This workflow:
- Runs the tests and generates `playwright-report`
- Publishes `playwright-report` to the `gh-pages` branch, updating your GitHub Pages site[1][5]

---

**4. Accessing Your Report**

After the workflow runs, your report will be accessible at:

```
https://<username>.github.io/<repository>/
```

You can further organize reports by build number, branch, or run ID by customizing the `publish_dir` or artifacts paths[1][2].

---

## Additional Tips

- You can use GitHub Actions to display the report URL in the job summary for convenient sharing[1][2].
- For merging reports from different shards or jobs, use `npx playwright merge-reports` before publishing[1].
- The HTML report supports filters and trace viewing directly in the browser[6].

---

## Summary Table

| Step                               | Command/Action                                                   |
|-------------------------------------|------------------------------------------------------------------|
| Enable GitHub Pages                 | Set source branch to `gh-pages`                                  |
| Generate Playwright HTML report     | `npx playwright test --reporter=html`                            |
| Deploy with GitHub Actions          | Use `peaceiris/actions-gh-pages` to publish `playwright-report`  |
| Access report                       | `https://<username>.github.io/<repo>/`                           |

---

This approach ensures that your Playwright test reports are always available as a static site, making test results transparent and easily distributable[1][2][5][6][7].

Citations:

- 1: https://blog.martioli.com/publish-your-playwright-reports-to-github-pages/
- 2: https://ysfaran.github.io/blog/2022/09/02/playwright-gh-action-gh-pages/
- 3: https://www.youtube.com/watch?v=F_nUVHBhrow
- 4: https://playwright.dev/docs/ci-intro
- 5: https://marcusfelling.com/blog/2021/publishing-playwright-test-results-to-github-pages/
- 6: https://www.restack.io/p/playwright-report-github-pages-answer
- 7: https://www.workwithloop.com/blog/playwright-github-pages
- 8: https://josdem.io/techtalk/ux/playwright_reports_deployment/

---



</details>

**Enable GitHub Pages deployment in your Playwright workflow**

To push the generated HTML report to GitHub Pages you’ll need to:

• Un‑comment and configure permissions at the top of .github/workflows/playwright.yml  
• Install and use a “deploy to gh‑pages” action (e.g. peaceiris/actions-gh-pages) after `npx playwright test --reporter=html`

Suggested changes:

```diff
 name: Playwright Tests and Publish Report
+permissions:
+  contents: write   # allow pushing to gh-pages

 on:
   push:
     branches: [main]

 jobs:
   test:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v3
@@
       - name: Run Playwright tests
         run: npx playwright test --reporter=html
+      - name: Deploy report to GitHub Pages
+        uses: peaceiris/actions-gh-pages@v3
+        with:
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          publish_dir: ./playwright-report
```

• If you’re not ready to publish reports yet, remove the stale comments entirely.  
• Otherwise add the full deployment job as shown above so your reports land on the `gh-pages` branch and appear at https://<username>.github.io/<repo>/.

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-18T09:24:14Z
author_association: NONE
diff_hunk: @@ -0,0 +1,23 @@
+DROP TABLE IF EXISTS users;
+
+CREATE TABLE IF NOT EXISTS users (
+  id INTEGER PRIMARY KEY AUTOINCREMENT,
+  username TEXT NOT NULL UNIQUE,
+  email TEXT NOT NULL UNIQUE,
+  password TEXT NOT NULL
+);
+
+-- Create a default user, The password is 'password' (MD5 hashed)
+INSERT INTO users (username, email, password) 
+    VALUES ('test', 'keamonk1@stud.kea.dk', '123');
path: sinatra/schema_test.sql
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Fix password handling in test user.**

There are issues with the test user's password:
1. The comment states the password is MD5 hashed, but '123' appears to be plaintext
2. MD5 is insecure for password storage even if it were used

While this may be acceptable for testing, ensure production code uses secure password hashing (like bcrypt, which I see is used in the application helpers).

```diff
-- Create a default user, The password is 'password' (MD5 hashed)
+-- Create a default user with a plaintext password (for testing only)
 INSERT INTO users (username, email, password) 
     VALUES ('test', 'keamonk1@stud.kea.dk', '123');
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **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.

`````suggestion
-- Create a default user with a plaintext password (for testing only)
INSERT INTO users (username, email, password) 
    VALUES ('test', 'keamonk1@stud.kea.dk', '123');
`````

</details>

<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-18T10:36:34Z
author_association: NONE
diff_hunk: @@ -0,0 +1,33 @@
+const { test, expect } = require('@playwright/test');
+
+// Navigate to the login page before each test
+test.describe('Login Page', () => {
+  test.beforeEach(async ({ page }) => {
+    await page.goto('/login');
+  });
+
+  test('renders login form', async ({ page }) => {
+    await expect(page.getByRole('heading', { name: /log in/i })).toBeVisible();
+    await expect(page.locator('input[name="username"]')).toBeVisible();
+    await expect(page.locator('input[name="password"]')).toBeVisible();
+    await expect(page.getByRole('button', { name: /log in/i })).toBeVisible();
+  });
+
+  test('shows error on invalid credentials', async ({ page }) => {
+    await page.fill('input[name="username"]', 'wronguser');
+    await page.fill('input[name="password"]', 'badpass');
+    await page.click('input[type="submit"]');
+    await expect(page.locator('.error')).toContainText(/error/i);
+  });
+
+  // Requires seeded user: username 'test', password '123'
+  test.skip('allows successful login', async ({ page }) => {
+    await page.fill('input[name="username"]', 'test');
+    await page.fill('input[name="password"]', '123');
+    await page.click('input[type="submit"]');
+
+    // Verify redirect to home
+    expect(page.url()).toBe('/');
+    await expect(page.getByText('You were successfully logged in.')).toBeVisible();
+  });
path: sinatra/tests/e2e/login.spec.js
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Consider adding a data seeding mechanism**

The skipped test for successful login requires seeded test data, but there's no clear indication of how or where this data should be created.

---

🏁 Script executed:

```shell
#!/bin/bash
# Check if there's a database seeding script or fixture in the codebase
fd -t f "seed|fixture" --full-path sinatra/

# Check for any references to test user creation in the codebase
rg -t ruby "test.*user|fixture.*user|seed.*user" sinatra/
```

Length of output: 435

---



</details>

**Add a data‑seeding mechanism for the “allows successful login” E2E test**

This test is currently skipped because it depends on a pre‑existing user (`test`/`123`), but there’s no fixture or seed script to create that account before Playwright runs.

Please add a clear seeding step—for example, a Playwright fixture or a standalone `scripts/seed` entrypoint—that inserts the `test` user into the database prior to executing this spec.

• Location: sinatra/tests/e2e/login.spec.js (lines 23–32)  
• Suggestion:  
  – Create a `seedTestUser()` helper (via direct DB call or API endpoint) and invoke it in a Playwright `beforeAll` or custom fixture.  
  – Alternatively, add a CLI script (`scripts/seed.js` or `seeds/`) that your CI/test runner can invoke to populate test data.  
• Verify that running the seed step enables this test to pass reliably.

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-18T10:36:34Z
author_association: NONE

PR comments:
user: login: deepsource-io[bot]
created_at: 2025-04-16T05:38:37Z
body: <div><p>Here's the code health analysis summary for commits <code>de9dfaa..7f5aa57</code>. <a href="https://app.deepsource.com/gh/DevOpsDynamite/DynaSearch/run/d054c745-70ae-4282-b071-b6fb6b141bf8/">View details on DeepSource</a>&nbsp;↗.</p><h3>Analysis Summary</h3><table><thead><tr><th>Analyzer</th><th>Status</th><th>Summary</th><th>Link</th></tr></thead><tbody><tr><td><img src="https://static.deepsource.com/analyzer_logos/ruby.svg" alt="DeepSource Ruby Logo" width="16px" height="16px"/><strong>Ruby</strong></td><td><span>✅&nbsp;</span><span>Success</span></td><td></td><td><a href="https://app.deepsource.com/gh/DevOpsDynamite/DynaSearch/run/d054c745-70ae-4282-b071-b6fb6b141bf8/ruby/">View Check</a>&nbsp;↗</td></tr><tr><td><img src="https://static.deepsource.com/analyzer_logos/docker.svg" alt="DeepSource Docker Logo" width="16px" height="16px"/><strong>Docker</strong></td><td><span>✅&nbsp;</span><span>Success</span></td><td></td><td><a href="https://app.deepsource.com/gh/DevOpsDynamite/DynaSearch/run/d054c745-70ae-4282-b071-b6fb6b141bf8/docker/">View Check</a>&nbsp;↗</td></tr></tbody></table><hr/><blockquote><div>💡 If you’re a repository administrator, you can configure the quality gates from the <a href="https://app.deepsource.com/gh/DevOpsDynamite/DynaSearch/settings/reporting">settings</a>.</div></blockquote></div>

author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-04-16T05:40:39Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

This set of changes introduces end-to-end Playwright tests for the Sinatra application, including new test scripts for core user flows such as about, login, registration, search, and weather. Supporting configuration files for Playwright and Node.js dependencies are added. The `.gitignore` is updated to exclude log and Playwright output files. The CI workflow is refactored into separate jobs for testing and linting, and a new Playwright workflow is introduced. The production Docker Compose setup gains a dedicated log volume, with corresponding changes to entrypoint scripts for permissions. Minor refactors and removals are made to route files and helper method names.

## Changes

| File(s)                                                                                     | Change Summary                                                                                                                                                                                                                                                                                                                                                                         |
|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `.github/workflows/ci.yaml`                                                                 | Refactored into three jobs: Ruby tests, RuboCop linting, and Dockerfile linting; uses official Hadolint action; improved dependency setup and caching.                                                                                                                                                                                                                                |
| `.github/workflows/continuous_delivery.yml`                                                 | Removed "feature/refactor" from workflow triggers; minor whitespace adjustment.                                                                                                                                                                                                                                                                                                        |
| `.github/workflows/playwright.yml`                                                          | Added new workflow to run Playwright end-to-end tests on push, PR, and manual triggers; sets up Ruby, Node.js, SQLite, and runs Playwright tests, uploading HTML reports.                                                                                                                                                                                                              |
| `.gitignore`, `sinatra/tests/.gitignore`                                                    | Updated to ignore additional log file patterns and Playwright/node-related output in the tests directory.                                                                                                                                                                                                                                       |
| `sinatra/docker-compose.prod.yml`, `sinatra/docker-entrypoint.sh`                           | Added and mounted a named volume `sinatra_logs` to `/app/log`; entrypoint ensures `/app/log` exists and is owned by `appuser`.                                                                                                                                                                                                                                                        |
| `sinatra/app.rb`, `sinatra/benchmark_search.rb`                                             | Minor refactors: session secret assignment separated into a variable; SQL query formatting improved; logger comment moved.                                                                                                                                                                                                                                                            |
| `sinatra/helpers/application_helpers.rb`, `sinatra/routes/api.rb`, `sinatra/routes/pages.rb`| Renamed helper method `get_cached_forecast` to `cached_forecast`; updated internal calls; removed `routes/pages.rb` and all its route handlers.                                                                                                                                                                                                |
| `sinatra/schema_test.sql`                                                                   | Added new SQL schema for users and pages tables, with default records for testing.                                                                                                                                                                                                                                                             |
| `sinatra/tests/e2e/about.spec.js`, `login.spec.js`, `register.spec.js`, `search.spec.js`, `weather.spec.js` | Added new Playwright end-to-end test scripts for about, login, registration, search, and weather features, covering both success and error scenarios.                                                                                                                                                                                          |
| `sinatra/tests/package.json`, `playwright.config.js`                                        | Added Node.js package and Playwright configuration for running and managing end-to-end tests.                                                                                                                                                                                                                                                  |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant Sinatra App
    participant Playwright

    Developer->>GitHub Actions: Push/PR to main/dev or manual dispatch
    GitHub Actions->>Sinatra App: Build and start app (test DB)
    GitHub Actions->>Playwright: Install dependencies, run tests
    Playwright->>Sinatra App: Simulate user actions (search, login, register, etc.)
    Sinatra App-->>Playwright: Responds to simulated requests
    Playwright->>GitHub Actions: Uploads HTML test report
```

## Assessment against linked issues

| Objective                                                                                                 | Addressed | Explanation                                                                                           |
|-----------------------------------------------------------------------------------------------------------|-----------|-------------------------------------------------------------------------------------------------------|
| Log user search queries with timestamp using lightweight logging (Logger/file/SQLite), persistent storage, easy access (Issue #124) | ❓        | Logging code is removed with the deletion of `routes/pages.rb`; unclear if logging remains elsewhere.  |
| Logging does not significantly impact search performance (Issue #124)                                      | ❓        | Cannot determine performance impact as logging implementation is not visible in the current changes.   |
| Document the logging setup, including how to access the logs (Issue #124)                                  | ❌        | No documentation changes regarding log access are present in this PR.                                 |

## Possibly related PRs

- DevOpsDynamite/DynaSearch#143: Also adds the Playwright end-to-end test workflow, indicating directly related changes in test automation.
- DevOpsDynamite/DynaSearch#131: Introduces the `routes/pages.rb` file, which this PR removes, indicating a direct relationship in route management.
- DevOpsDynamite/DynaSearch#139: Modifies the same Docker Compose and entrypoint files for logging support, closely related to the log volume and directory changes here.

## Suggested reviewers

- theaskou

## Poem

> In the warren of code where the carrots grow bright,  
> New tests now hop in, both by day and by night.  
> With Playwright they scurry, through login and search,  
> Ensuring each feature won’t leave us in lurch.  
> Logs find new burrows, and helpers rename—  
> This rabbit’s quite proud of a codebase less tame!  
> 🐇✨

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcSHFcLzpIACIAERIJaMg5SGxESkgAQUiAa0RMJQoifyJIAApbSDMARgAWAAYAShQMXApFbAZpdEhyAHdIADMSamx/PxIvaiiCSC98IiJ4DFK+9QQsXFgSSFjZDDQAZRGKBlgedpExDRhtxlhMUmQ0Wnp5xeXSwewMMXh8A5edTyRDcUTwQbwBhoHzyQb4PjpZxnfhgqjiAGIAA0kDWWzCd3eMhIn3saCk9GWPVi+AYOQyEnwXkcO1mZAc4zRiCQNF+JBumVe6n+gK8shxWx27yG8EiyAeUmSJDI6FeM3wBJ2GiW4iIGARO0hkTCGt4CXYmuYQ3aVoEJJW9ge/nongEQIYYpxvHwND+DoYFGF0N8AjSy2kyGW8IozGoIpu7mQlRetH8iHSzww9EhAA9ukgHN0agAmWroLNVaoAZgA7Am7thuLRpihkB60OmIfAoh2evqMGABP40DlSf0hiNcGN+bcdmg8LAEQoMJCY89aNt/HyTZqLvgrrgAOTIRC4WTGojYeBKIHkbH2SaDMD+CTdgb4Qa7phKHEFFoesMAX4T8mFYdhIywUDuEiHN0GHRAbgAOQ1c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SAWV2oA0GLPNX6gP17K91WqC9W7rAgOoPmVqB5X8yeV16wlc2vVg8rTVhoHlZUAI7mr1QWgPUBBuDBqw516ayNdqACACrLwYs4MDWuiwNrUAaa/mTQBoB8y+VsG3dbyt2gGAVYAG8WeqDM3VA1YeoK8HSulnxbtN6oITZRuo2oAIVxZOFcisJBor9lQKfoCAA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=DevOpsDynamite/DynaSearch&utm_content=140):

- 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 generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: NONE
user: login: theaskou
created_at: 2025-04-18T11:43:54Z
body: Nice! Looking forward to see how it works
author_association: CONTRIBUTOR