Skip to content

Conversation

Kolbe23
Copy link

@Kolbe23 Kolbe23 commented Apr 17, 2025

User description

…al E2E testing

Description

Give a summary of the change that you have made

This PR introduces a SQLite-compatible Prisma schema (schema.test.prisma) and corresponding environment config (.env.test) to enable local E2E testing without PostgreSQL. Additionally, it removes the unused PostgreSQL service from docker-compose-test.yml in alignment with issue #333.

This allows contributors to work with a lightweight, in-memory-compatible database setup without requiring PostgreSQL.

Fixes #333

Dependencies

@prisma/client (existing dependency)

env-cmd (used for loading test-specific env vars)

SQLite (as defined in the Prisma datasource)

Future Improvements

Mention any improvements to be done in future related to any file/feature

Add GitHub Actions workflow to run tests with SQLite on CI

Allow toggling between PostgreSQL and SQLite via env vars for broader test coverage

Mentions

Mention and tag the people
@keyshade/maintainers (for review)

Screenshots of relevant screens

Add screenshots of relevant screens

Developer's checklist

  • My PR follows the style guidelines of this project
  • I have performed a self-check on my work

If changes are made in the code:

  • I have followed the coding guidelines
  • My changes in code generate no new warnings
  • My changes are breaking another fix/feature of the project
  • I have added test cases to show that my feature works
  • I have added relevant screenshots in my PR
  • There are no UI/UX issues

Documentation Update

  • This PR requires an update to the documentation at docs.keyshade.xyz
  • I have made the necessary updates to the documentation, or no documentation changes are required.

PR Type

Enhancement, Configuration changes


Description

  • Added SQLite-compatible Prisma schema for testing.

  • Introduced .env.test for SQLite database configuration.

  • Replaced Postgres with SQLite for local E2E testing.

  • Improved testing setup with lightweight database support.


Changes walkthrough 📝

Relevant files
Configuration changes
.env.test
Introduced `.env.test` for SQLite database configuration 

.env.test

  • Added new environment variables for SQLite configuration.
  • Configured DATABASE_URL to use SQLite.
  • Included placeholders for other services like Redis and SMTP.
  • Set up default values for testing environment.
  • +71/-0   
    Enhancement
    schema.test.prisma
    Added SQLite-compatible Prisma schema for testing               

    apps/api/src/prisma/schema.test.prisma

  • Added SQLite-compatible Prisma schema for testing.
  • Defined models for entities like User, Workspace, and Project.
  • Configured SQLite as the database provider.
  • Included relations and constraints for all models.
  • +353/-0 

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis 🔶

    333 - Partially compliant

    Compliant requirements:

    • Update schema.prisma to be compatible with Prisma SQLite

    Non-compliant requirements:

    • Remove the db service in docker-compose-test.yml

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Missing Documentation

    The new environment file contains many placeholder values without clear documentation on which ones are required for SQLite testing versus which can remain as placeholders.

    [email protected]
    REDIS_URL=redis://127.0.0.1:6379
    REDIS_PASSWORD=
    
    API_PORT=4200
    DOMAIN=localhost
    
    GITHUB_CLIENT_ID= 
    GITHUB_CLIENT_SECRET= 
    GITHUB_CALLBACK_URL=
    
    GOOGLE_CLIENT_ID=
    GOOGLE_CLIENT_SECRET=
    GOOGLE_CALLBACK_URL=
    
    GITLAB_CLIENT_ID=
    GITLAB_CLIENT_SECRET=
    GITLAB_CALLBACK_URL=
    
    SENTRY_ORG=
    NEXT_PUBLIC_SENTRY_ENVIRONMENT=
    
    SENTRY_API_DSN=
    SENTRY_API_TRACES_SAMPLE_RATE=1.0
    SENTRY_API_PROFILES_SAMPLE_RATE=1.0
    SENTRY_API_ENVIRONMENT=
    
    NEXT_PUBLIC_SENTRY_WEB_DSN=
    NEXT_PUBLIC_SENTRY_WEB_TRACES_SAMPLE_RATE=1.0
    NEXT_PUBLIC_SENTRY_WEB_PROFILES_SAMPLE_RATE=1.0
    NEXT_PUBLIC_GOOGLE_ANALYTICS_MEASUREMENT_ID=
    
    NEXT_PUBLIC_SENTRY_PLATFORM_DSN=
    NEXT_PUBLIC_SENTRY_PLATFORM_TRACES_SAMPLE_RATE=1.0
    NEXT_PUBLIC_SENTRY_PLATFORM_PROFILES_SAMPLE_RATE=1.0
    NEXT_PUBLIC_BACKEND_URL=http://localhost:4200
    
    SENTRY_CLI_DSN=
    SENTRY_CLI_TRACES_SAMPLE_RATE=1.0
    SENTRY_CLI_PROFILES_SAMPLE_RATE=1.0
    
    SMTP_HOST=
    SMTP_PORT=
    SMTP_SECURE=false
    SMTP_EMAIL_ADDRESS=
    SMTP_PASSWORD=
    FROM_EMAIL="your-name <[email protected]>"
    
    MINIO_ENDPOINT=
    MINIO_PORT=
    MINIO_ACCESS_KEY=
    MINIO_SECRET_KEY=
    MINIO_USE_SSL=
    MINIO_BUCKET_NAME=
    
    JWT_SECRET=secret
    
    WEB_FRONTEND_URL=http://localhost:3000
    PLATFORM_FRONTEND_URL=http://localhost:3025
    PLATFORM_OAUTH_SUCCESS_REDIRECT_PATH=/oauth/signin
    PLATFORM_OAUTH_FAILURE_REDIRECT_PATH=/oauth/failure
    
    FEEDBACK_FORWARD_EMAIL=
    
    NODE_ENV=dev
    
    THROTTLE_TTL=60
    THROTTLE_LIMIT=5
    Incomplete Implementation

    The PR adds a SQLite-compatible schema but doesn't include changes to the docker-compose-test.yml file to remove the PostgreSQL service as specified in the ticket requirements.

    datasource db {
      provider = "sqlite"
      url      = env("DATABASE_URL")
    }

    Copy link
    Contributor

    codiumai-pr-agent-free bot commented Apr 17, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Security
    Avoid hardcoded secrets

    Using a hardcoded value "secret" for JWT_SECRET in the test environment poses a
    security risk. Even in test environments, it's better to use a randomly
    generated string or a placeholder that indicates it should be replaced.

    .env.test [59]

    -JWT_SECRET=secret
    +JWT_SECRET=test_jwt_secret_replace_in_production
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: Using a hardcoded value like "secret" for JWT_SECRET is a security risk, as it could be accidentally used in production or lead to insecure practices. The suggestion improves security awareness by using a more descriptive value that clearly indicates it's for testing only.

    Medium
    • Update

    @Kolbe23 Kolbe23 changed the title chore(test): add SQLite-compatible Prisma schema and .env.test for local development chore(test): swap to SQLite for local E2E — schema, .env, and docker cleanup Apr 17, 2025
    @Sambit003
    Copy link
    Contributor

    @rajdip-b

    Copy link
    Member

    Choose a reason for hiding this comment

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

    not sure about what this does

    Copy link
    Member

    Choose a reason for hiding this comment

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

    we would need to tie up sqlite with e2e tests. they are already present and can be run using pnpm e2e:api

    Copy link
    Member

    Choose a reason for hiding this comment

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

    i dont think we should be maintaining a test schema file

    Copy link
    Contributor

    @Kolbe23, please resolve all open reviews!

    Copy link
    Contributor

    @Kolbe23, please resolve all open reviews; otherwise this PR will be closed after Thu Apr 24 2025 16:47:46 GMT+0000 (Coordinated Universal Time)!

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

    Successfully merging this pull request may close these issues.

    API: Swap the testing db with SQLite
    3 participants