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

fix(develop): remove plugin legacy code #3347

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

bandhan-majumder
Copy link

@bandhan-majumder bandhan-majumder commented Mar 9, 2025

What kind of change does this PR introduce?

Removes plugin related types, queries, mutations and model.

Issue Number:

Fixes #3337

Snapshots/Videos:

output1.mp4

If relevant, did you update the documentation?

Not sure.

Summary

  1. Removes plugin related code
  2. Fix the types
  3. Ensures the admin works correctly.

Does this PR introduce a breaking change?

Yes. It removes the plugin related code from api related code.

Checklist

CodeRabbit AI Review

  • I have reviewed and addressed all critical issues flagged by CodeRabbit AI
  • I have implemented or provided justification for each non-critical suggestion
  • I have documented my reasoning in the PR comments where CodeRabbit AI suggestions were not implemented

Test Coverage

  • I have written tests for all new changes/features
  • I have verified that test coverage meets or exceeds 95%
  • I have run the test suite locally and all tests pass

Other information

Have you read the contributing guide?

Summary by CodeRabbit

  • Refactor

    • Removed all plugin management features, including creation, update, and query capabilities.
    • Streamlined user profiles by eliminating plugin creation options.
  • Documentation

    • Updated public guides and API references to reflect the removal of all plugin-related functionality.
  • Tests

    • Removed legacy tests associated with plugin operations to align with the updated system behavior.

Copy link

coderabbitai bot commented Mar 9, 2025

Walkthrough

This update systematically removes plugin-related functionality across the codebase. It deletes mappings, fields, resolvers, GraphQL types, mutations, queries, subscriptions, and input types associated with plugins. Plugin data loading functions, plugin models, and plugin-specific constants have been removed. Additionally, sample data, documentation, and test cases referencing plugins have been updated or deleted. Overall, the changes eliminate any server-side and schema-level references to plugins, streamlining the code while disabling old plugin management features.

Changes

Files Change Summary
codegen.ts Removed mappings for Plugin and PluginField from the mappers object in the configuration.
sample_data/appUserProfiles.json, sample_data/defaultAppUserProfile.json, sample_data/defaultUser.json, sample_data/users.json Removed the pluginCreationAllowed field/property from all user profile objects.
schema.graphql, src/typeDefs/inputs.ts, src/typeDefs/mutations.ts, src/typeDefs/queries.ts, src/typeDefs/subscriptions.ts, src/typeDefs/types.ts, src/types/generatedGraphQLTypes.ts Deleted all plugin-related types, fields, mutations (blockPluginCreationBySuperadmin, createPlugin, updatePluginStatus), queries (adminPlugin, getPlugins, plugin), subscription (onPluginUpdate), and input types (PluginFieldInput, PluginInput), as well as removed pluginCreationAllowed from relevant types.
src/config/plugins/loadPlugins.ts, src/config/plugins/pluginData.json Removed plugin loading logic and the associated plugin data file.
src/constants.ts, src/index.ts Deleted the PLUGIN_NOT_FOUND constant and removed the loadPlugins() import/invocation from the server startup.
src/models/AppUserProfile.ts, src/models/Plugin.ts, src/models/PluginField.ts, src/models/SampleData.ts, src/models/index.ts Removed pluginCreationAllowed from the user model, deleted entire plugin and plugin field model files, and removed the Plugin option from the allowed values in SampleData and from aggregated exports.
src/resolvers/Mutation/{blockPluginCreationBySuperadmin.ts, createPlugin.ts, updatePluginStatus.ts}, src/resolvers/Query/{getPlugins.ts, index.ts}, src/resolvers/Subscription/{onPluginUpdate.ts, index.ts}, src/resolvers/index.ts Removed all resolvers and middleware related to plugin creation, blocking, status updates, and querying, as well as the subscription for plugin updates.
src/utilities/{createSampleOrganizationUtil.ts, removeSampleOrganizationUtil.ts} Deleted the generateRandomPlugins function and removed any plugin-related processing from organization sample creation and removal utilities.
talawa-api-docs/{interfaces/models_User.InterfaceUser.md, modules.md, modules/types_generatedGraphQLTypes.md} Updated documentation by removing references and entries related to Plugin and PluginField, including changes in interface tables and module listings.
tests/{helpers/plugins.ts, resolvers/Mutation/{blockPluginCreationBySuperadmin.spec.ts, createPlugin.spec.ts, updatePluginStatus.spec.ts}, resolvers/Query/{getCommunityData.spec.ts, getPlugins.spec.ts}, resolvers/Subscription/onPluginUpdate.spec.ts, resolvers/User/userAccess.spec.ts, utilities/createSampleOrganizationUtil.spec.ts} Deleted test files and references for plugin functionality, including helpers, mutation, query, subscription tests, and removed plugin-specific fields from test type definitions.

Sequence Diagram(s)

sequenceDiagram
    participant Server as Server Startup
    participant DB as Database
    Server->>DB: Establish connection
    Note right of Server: Plugin loading logic removed
    DB-->>Server: Connection confirmed
    Server->>Server: Proceed with startup without loading plugins
Loading

Suggested reviewers

  • palisadoes
  • disha1202

Poem

Oh! Hopping through the lines of code,
I leave behind plugins on the road.
Fields and mappings vanish in a blink,
Clean paths ahead—much simpler than you think.
With every hop and twitch of my ear,
I celebrate a codebase light and clear! 🐇


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1436860 and 5a38fc2.

📒 Files selected for processing (1)
  • tests/libraries/logger.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/libraries/logger.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Testing Application (22.x)
  • GitHub Check: Analyse Code With CodeQL (typescript)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Mar 9, 2025

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 9, 2025
@Cioppolo14 Cioppolo14 added the ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files label Mar 9, 2025
@Cioppolo14
Copy link
Contributor

@bandhan-majumder Please make sure all checks pass. If ones are expected to not pass, let me know. Thank you!

@meetulr meetulr self-requested a review March 9, 2025 15:48
@meetulr
Copy link
Contributor

meetulr commented Mar 9, 2025

@bandhan-majumder let me know when this is ready.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 9, 2025
Copy link

codecov bot commented Mar 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.65%. Comparing base (bfccc6c) to head (5a38fc2).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3347      +/-   ##
===========================================
- Coverage    97.65%   97.65%   -0.01%     
===========================================
  Files          365      360       -5     
  Lines        18630    18461     -169     
  Branches      2699     2683      -16     
===========================================
- Hits         18194    18028     -166     
+ Misses         431      428       -3     
  Partials         5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 10, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 10, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
tests/resolvers/Mutation/createPost.spec.ts (1)

83-91: Function structure test may be brittle.

While this test helps verify the createPost function exists and has the expected structure after plugin-related code removal, testing a function's implementation details through string representation is somewhat brittle. If the function implementation changes (even without changing behavior), this test might break.

Consider focusing more on behavior testing rather than implementation details. However, I understand this may be intentional to ensure core structures remain after plugin code removal.

-  it("should verify createPost function structure", async () => {
-    expect(createPost).toBeDefined();
-    expect(typeof createPost).toBe("function");
-
-    const functionString = createPost.toString();
-    expect(functionString).toContain("async");
-    expect(functionString).toContain("req");
-    expect(functionString).toContain("res");
-  });
+  it("should verify createPost function exists and is callable", async () => {
+    expect(createPost).toBeDefined();
+    expect(typeof createPost).toBe("function");
+    
+    // Optionally verify function signature instead of implementation details
+    const mockReq = {} as InterfaceAuthenticatedRequest;
+    const mockRes = mockResponse();
+    
+    // Just verify the function can be called without throwing TypeError
+    expect(() => createPost(mockReq, mockRes)).not.toThrow(TypeError);
+  });
tests/libraries/logger.spec.ts (2)

91-93: Module mocking should be done at the top level.

The vi.mock() calls are hoisted to the top of the file during test execution, but they're conceptually clearer when placed with other mocks at the file level rather than inside a test.

Move the mock to the top of the file with other mocks:

- vi.mock("./../../src/libraries/requestTracing", () => ({
-   getTracingId: vi.fn().mockReturnValue("trace-123"),
- }));

And add this to the top-level mocks:

vi.mock("./../../src/libraries/requestTracing", () => ({
  getTracingId: vi.fn().mockReturnValue("trace-123"),
}));

95-95: Improve the assertion with a more specific expectation.

The assertion that printfMock is called twice is correct but doesn't fully validate the behavior.

Consider adding more specific assertions:

- expect(printfMock).toHaveBeenCalledTimes(2); // Called for both colorized and non-colorized
+ expect(printfMock).toHaveBeenCalledTimes(2);
+ // Verify the context of each call
+ expect(printfMock.mock.calls[0][0]).toBeInstanceOf(Function);
+ expect(printfMock.mock.calls[1][0]).toBeInstanceOf(Function);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e53baca and 1436860.

📒 Files selected for processing (2)
  • tests/libraries/logger.spec.ts (1 hunks)
  • tests/resolvers/Mutation/createPost.spec.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
tests/resolvers/Mutation/createPost.spec.ts (1)
Learnt from: iamanishx
PR: PalisadoesFoundation/talawa-api#3289
File: src/graphql/types/Mutation/deletePost.ts:109-129
Timestamp: 2025-02-24T05:59:01.605Z
Learning: PR #3289 is focused on test cases, specifically adding the `createRegularUserUsingAdmin` helper function for integration tests, and should not include changes to server code.
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Testing Application (22.x)
  • GitHub Check: Analyse Code With CodeQL (typescript)
🔇 Additional comments (2)
tests/resolvers/Mutation/createPost.spec.ts (2)

2-2: Well-structured import statement.

Good practice to consolidate imports from the same module in a single line. This improves readability and maintainability.


76-81: Good validation of mongoose import.

This test effectively validates that mongoose is properly imported and structured as expected, which is important for ensuring the test environment is correctly set up, especially after removing plugin-related code.

@bandhan-majumder
Copy link
Author

@meetulr @palisadoes PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants