Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor(schema): add describe blocks in tests for each kind of schema #577

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

muntaxir4
Copy link
Contributor

@muntaxir4 muntaxir4 commented Dec 4, 2024

User description

Description

@keyshade/schema:

  • Create describe blocks to contain tests for each kind of schema. Removed old test comments.
  • Change count type from string to number in secret and variable RollbackResponses.

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

Tests


Description

  • Refactored all schema tests by introducing describe blocks for better organization and readability.
  • Grouped existing test cases under appropriate describe blocks to enhance test structure.
  • Added missing assertions and validation checks in some test files.
  • Removed old test comments to clean up the test files.

Changes walkthrough 📝

Relevant files
Tests
13 files
secret.spec.ts
Refactor tests with `describe` blocks for schema organization.

packages/schema/tests/secret.spec.ts

  • Added describe blocks to organize tests by schema type.
  • Grouped existing tests under new describe blocks for better structure.
  • Ensured all test cases are wrapped within appropriate describe blocks.

  • +428/-413
    workspace.spec.ts
    Organize workspace tests using `describe` blocks.               

    packages/schema/tests/workspace.spec.ts

  • Introduced describe blocks for each schema test group.
  • Organized tests into logical sections using describe.
  • Enhanced test readability and structure with describe blocks.
  • +410/-378
    workspace-role.spec.ts
    Categorize workspace role tests with `describe` blocks.   

    packages/schema/tests/workspace-role.spec.ts

  • Added describe blocks to categorize tests by schema.
  • Improved test organization with describe blocks.
  • Structured tests for better clarity and maintenance.
  • +341/-330
    integration.spec.ts
    Structure integration tests using `describe` blocks.         

    packages/schema/tests/integration.spec.ts

  • Implemented describe blocks for integration schema tests.
  • Structured tests into sections using describe.
  • Enhanced test clarity and organization with describe blocks.
  • +326/-315
    auth.spec.ts
    Organize auth tests with `describe` blocks.                           

    packages/schema/tests/auth.spec.ts

  • Introduced describe blocks for auth schema tests.
  • Organized tests into sections using describe.
  • Improved test readability and structure with describe blocks.
  • +35/-33 
    workspace-membership.spec.ts
    Refactor tests with `describe` blocks for schema organization

    packages/schema/tests/workspace-membership.spec.ts

  • Introduced describe blocks to organize tests by schema type.
  • Enhanced test readability by grouping related tests.
  • Added missing assertions for test validations.
  • +334/-313
    variable.spec.ts
    Organize variable schema tests with `describe` blocks       

    packages/schema/tests/variable.spec.ts

  • Added describe blocks to group tests by schema type.
  • Improved test structure and readability.
  • Included additional assertions for validation checks.
  • +363/-352
    api-key.spec.ts
    Refactor API key tests using `describe` blocks                     

    packages/schema/tests/api-key.spec.ts

  • Grouped tests with describe blocks for better organization.
  • Enhanced test clarity and structure.
  • Added assertions for validation results.
  • +280/-266
    environment.spec.ts
    Organize environment schema tests with `describe` blocks 

    packages/schema/tests/environment.spec.ts

  • Utilized describe blocks to categorize tests by schema.
  • Improved test organization and readability.
  • Added assertions for validation outcomes.
  • +265/-254
    user.spec.ts
    Refactor user schema tests with `describe` blocks               

    packages/schema/tests/user.spec.ts

  • Implemented describe blocks to organize user schema tests.
  • Enhanced test readability and structure.
  • Added assertions for validation checks.
  • +207/-197
    pagination.spec.ts
    Refactor pagination schema tests with describe blocks       

    packages/schema/tests/pagination.spec.ts

  • Added describe blocks to group tests for PageRequestSchema,
    PageResponseSchema, ResponseErrorSchema, and ClientResponseSchema.
  • Organized existing test cases under their respective describe blocks.
  • Removed old test comments and improved test structure.
  • +150/-146
    event.spec.ts
    Refactor event schema tests with describe blocks                 

    packages/schema/tests/event.spec.ts

  • Introduced describe blocks for GetEventsRequestSchema and
    GetEventsResponseSchema tests.
  • Structured existing test cases within the new describe blocks.
  • Enhanced test organization and readability.
  • +110/-108
    enums.test.ts
    Refactor enum tests with describe blocks                                 

    packages/schema/tests/enums.test.ts

  • Added describe blocks for each enum type test.
  • Organized tests for integrationTypeEnum, expiresAfterEnum,
    rotateAfterEnum, eventSourceEnum, eventTriggererEnum,
    eventSeverityEnum, eventTypeEnum, authorityEnum, and
    projectAccessLevelEnum.
  • Improved test clarity and structure.
  • +136/-118

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Code Organization
    The test file contains a large number of test cases that could benefit from further grouping and organization. Consider splitting some of the larger test groups into smaller, more focused test suites.

    Copy link
    Contributor

    codiumai-pr-agent-free bot commented Dec 4, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    ✅ Fix incorrect type validation in schema test where a numeric value is validated as string
    Suggestion Impact:The suggestion impacted the commit by changing the type of 'count' from a string to a number in the test case for RollBackSecretResponseSchema.

    code diff:

    -        count: '1'
    +        count: 1

    The test case for RollBackSecretResponseSchema validates that count is a string, but
    this seems incorrect as count should typically be a number. Consider updating the
    schema and test to use a numeric type instead.

    packages/schema/tests/secret.spec.ts [294-297]

     const result = RollBackSecretResponseSchema.safeParse({
    -  count: '1'
    +  count: 1
     })
     expect(result.success).toBe(true)
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The suggestion identifies a potential data type inconsistency where count is validated as a string ('1') when it should logically be a number (1). This could prevent proper type safety and lead to runtime issues.

    8

    💡 Need additional feedback ? start a PR chat

    @muntaxir4 muntaxir4 requested a review from rajdip-b December 4, 2024 21:25
    @rajdip-b rajdip-b merged commit c0763f3 into keyshade-xyz:develop Dec 5, 2024
    6 checks passed
    @muntaxir4 muntaxir4 deleted the refactor/schema-tests branch December 5, 2024 08:15
    rajdip-b pushed a commit that referenced this pull request Jan 23, 2025
    ## [2.9.0](v2.8.0...v2.9.0) (2025-01-23)
    
    ### 🚀 Features
    
    * **api-client:** Get all workspace invitation ([#619](#619)) ([8a23850](8a23850))
    * **api,cli,api-client,schema:** Enhance permissions to allow filtering by environments through project roles ([#599](#599)) ([030b539](030b539))
    * **api:** Add `ADMIN` authority for API keys ([#609](#609)) ([fb6aba7](fb6aba7))
    * **api:** Add email template for inviting user to workspace ([#480](#480)) ([f5ddf7a](f5ddf7a))
    * **api:** Add email template for sending OTP to the user ([#582](#582)) ([cb6bbcb](cb6bbcb))
    * **api:** Add endpoint to fetch all workspace invitations for a user ([#586](#586)) ([d45417a](d45417a))
    * **api:** Add logout endpoint to clear token cookie ([#581](#581)) ([27f81ba](27f81ba))
    * **api:** Add slack integration ([#531](#531)) ([fe124d8](fe124d8))
    * **cli:** Add CLI command to check version flag using `--version` or `-v` ([#650](#650)) ([31b5efe](31b5efe))
    * **cli:** Add functionality to operate on Workspace Membership ([#589](#589)) ([0fde62b](0fde62b))
    * **cli:** Add import sub commmand for project. ([#594](#594)) ([9896f27](9896f27))
    * **cli:** Add List-invitation command ([#633](#633)) ([874f8c2](874f8c2))
    * **cli:** Added keyshade command to cli ([cf260ae](cf260ae))
    * **cli:** Api health probe ([#645](#645)) ([dd854f4](dd854f4))
    * **cli:** Create basic README.md ([a1b74e9](a1b74e9))
    * **cli:** Log publicKey, privacyKey, & accessLevel after project creation ([#623](#623)) ([5d5b329](5d5b329))
    * **cli:** Supports to specify environment(s) and its optional description ([#634](#634)) ([62083b1](62083b1))
    * **cli:** update README with feature and installation ([#644](#644)) ([a4d2a6a](a4d2a6a))
    * **platform:** Add a new [secure] and added loader on project screen ([#603](#603)) ([c3a08cc](c3a08cc))
    * **platform:** Add new variables to a project ([#593](#593)) ([d6c6252](d6c6252))
    * **platform:** Delete variable from a project ([#600](#600)) ([e64a738](e64a738))
    * **platform:** Edit existing variables in a project ([#602](#602)) ([bb48f6c](bb48f6c))
    * **platform:** Show all the existing variables inside a project ([#591](#591)) ([5276bb8](5276bb8))
    * **platofrm:** Added online/offline status detection in the platform ([#585](#585)) ([89aa84f](89aa84f))
    * **schema:** Add workspace invitation schema ([#612](#612)) ([1a5721b](1a5721b))
    * **web:** Add Google Analytics integration ([#649](#649)) ([397d6da](397d6da))
    
    ### 🐛 Bug Fixes
    
    * **api:** Empty name `""` accepted as a valid name while creating environments ([#583](#583)) ([a33f4b5](a33f4b5))
    * **api:** Enable global project access ([#580](#580)) ([b3a0309](b3a0309))
    * **api:** Update build command ([0ddfa59](0ddfa59))
    * **cli:** Add keywords for improved package discoverability ([#641](#641)) ([57ce10b](57ce10b))
    * **cli:** Check for .keyshade dir if profile isn't found ([#636](#636)) ([a69665d](a69665d))
    * **cli:** Create project --store-private-key option default value removed ([#638](#638)) ([20f16c6](20f16c6))
    * **cli:** Fixed binary path in package.json ([e531af0](e531af0))
    * **cli:** Fixed binary path in package.json ([81d674d](81d674d))
    * **cli:** Incorrect message on listing projects ([#624](#624)) ([eeffa42](eeffa42))
    * **cli:** Module errors ([d3432c5](d3432c5))
    * **cli:** Module errors ([a639065](a639065))
    * **cli:** Module errors ([a7742b1](a7742b1))
    * **cli:** Module errors ([e96300e](e96300e))
    * **cli:** Profile name now can use - and _ and updated error message ([#639](#639)) ([00dd66a](00dd66a))
    * **cli:** Prompt users for all values if no option set and show default values ([#640](#640)) ([fe862ab](fe862ab))
    * **docker:** Update build script ([40ef3e2](40ef3e2))
    * **platform:** Check if `Env. Name` is left empty ([#646](#646)) ([5f3fac8](5f3fac8))
    * **platform:** Clickable Workspaces combobox options ([#630](#630)) ([acc96f7](acc96f7))
    * **platform:** Optimized user update request body ([#605](#605)) ([ee1adf0](ee1adf0))
    * **platform:** Type error in navbar ([8199de8](8199de8))
    * **README:** Update Discord badge ([6f9382e](6f9382e))
    * **schema:** Add versions field to project [secure]s and variables response ([#590](#590)) ([755ea46](755ea46))
    
    ### 📚 Documentation
    
    * **cli:** Update changelog to include missed out changes ([8910c5c](8910c5c))
    * Updated alignment of pictures in API Testing page ([5d69223](5d69223))
    * Updated alignment of pictures in API Testing page ([e31eeca](e31eeca))
    
    ### 🔧 Miscellaneous Chores
    
    * Add Sentry and update CI ([#653](#653)) ([ca96862](ca96862))
    * **ci:** Add CLI deployment script ([51de9d1](51de9d1))
    * **ci:** Add internal package dependencies to existing workflows ([#592](#592)) ([a9fc39e](a9fc39e))
    * **ci:** Add scope ([8ef89a8](8ef89a8))
    * **ci:** Bug fix in workflow ([d583a46](d583a46))
    * **ci:** Bug fix in workflow ([eb9d60f](eb9d60f))
    * **ci:** Bump version to 2.2.0 ([951bd14](951bd14))
    * **ci:** Deploy DB migrations ([ea1beed](ea1beed))
    * **ci:** Fixed chaining and scripts ([6a009eb](6a009eb))
    * **ci:** Fixed environment name ([172c348](172c348))
    * **ci:** Fixed errors ([f28e3b5](f28e3b5))
    * **ci:** Minor fixes ([c7f05a0](c7f05a0))
    * **ci:** Push docker images of platform and API to ACR ([5f79dd7](5f79dd7))
    * **ci:** Remove npm ci ([3d45a4c](3d45a4c))
    * **ci:** Remove pnpm cache ([f45970c](f45970c))
    * **ci:** Update app redeployment ([18cf765](18cf765))
    * **ci:** Update web deployment to push to ACR ([26d4bed](26d4bed))
    * **cli:** Bumped CLI to v2.4.0 ([09efcd9](09efcd9))
    * **cli:** Rearranged dependency ([b6e344d](b6e344d))
    * **cli:** Removed changeset ([6c436de](6c436de))
    * **cli:** Update package name ([23552a1](23552a1))
    * **cli:** Update package name ([480cf54](480cf54))
    * **cli:** Update package.json ([871679a](871679a))
    * **cli:** Updated build scripts ([2e2b42d](2e2b42d))
    * **docker:** Update port of platform docker build ([c79d886](c79d886))
    * Housekeeping ([2ed31c0](2ed31c0))
    * **platoform:** Swapped all legacy API calls with `@keyshade/api-client` ([#584](#584)) ([c600db7](c600db7))
    * Removed .postman folder ([4b2b675](4b2b675))
    * Reverted back registry ([1699a89](1699a89))
    * **schema:** Add describe blocks in tests for each kind of schema ([#577](#577)) ([c0763f3](c0763f3))
    * Update npmrc ([9f7f495](9f7f495))
    * Update pipelines; fixed api docker ([3f36a17](3f36a17))
    * Update platform build command ([83a1851](83a1851))
    * **web:** Fix CI ([d1bc740](d1bc740))
    * **web:** Update dockerfile and ci to include google analytics env ([f2df4f4](f2df4f4))
    
    ### 🔨 Code Refactoring
    
    * **cli:** Replace arguments with options ([#615](#615)) ([498f44e](498f44e))
    * **platform:** Optimized codebase ([#629](#629)) ([d411081](d411081))
    * **platform:** Refactor project components ([#626](#626)) ([5b70805](5b70805))
    * **web:** Changed the text in the hero section of the web application ([#579](#579)) ([a92925f](a92925f))
    @rajdip-b
    Copy link
    Member

    🎉 This PR is included in version 2.9.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

    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.

    2 participants