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

chore: Remove unused LayoutServiceCE.createLayout #34305

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented Jun 18, 2024

The LayoutServiceCE.createLayout method is only used in tests, and so, should either be unneeded and so removed, or should be moved to somewhere under test/main/java instead. But since it looks like we don't actually need it, from reading the tests, removing it.

/test sanity

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9564364280
Commit: 2f13223
Cypress dashboard.
Tags: @tag.Sanity

Summary by CodeRabbit

  • Refactor

    • Updated layout retrieval method to include a new parameter.
    • Removed createLayout method to streamline layout creation processes.
    • Utilized Lombok's @RequiredArgsConstructor to simplify constructor definitions.
  • Tests

    • Enhanced test assertions and refactored logic for layout and action service tests.
    • Improved test cleanup process by refining workspace archiving without deleting applications.

Copy link
Contributor

coderabbitai bot commented Jun 18, 2024

Walkthrough

Recent changes involve the LayoutServiceCE interface and its implementation. The createLayout method has been removed, and getLayout has been updated to include an additional parameter for branchName. In tests, assertions were enhanced, and logic in LayoutServiceTest and ActionServiceCE_Test was refactored to improve clarity and efficiency.

Changes

File Path Change Summary
app/.../services/ce/LayoutServiceCE.java Removed createLayout. Updated getLayout method with an additional parameter branchName.
app/.../services/ce/LayoutServiceCEImpl.java Removed createLayout. Refactored constructor to use @RequiredArgsConstructor.
app/.../services/LayoutServiceTest.java Enhanced assertions, refactored cleanup logic, updated test methods with new assertions and refactoring.
app/.../services/ce/ActionServiceCE_Test.java Replaced zipWhen with flatMap in layout creation logic.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant LayoutServiceCE
    participant LayoutServiceCEImpl

    Client->>LayoutServiceCE: getLayout(defaultPageId, layoutId, viewMode, branchName)
    LayoutServiceCE->>LayoutServiceCEImpl: getLayout(defaultPageId, layoutId, viewMode, branchName)
    LayoutServiceCEImpl-->>LayoutServiceCE: Layout object
    LayoutServiceCE-->>Client: Layout object
Loading

Poem

A code change here, a tweak made there, 🐇
Layouts refined with utmost care, ✨
Assertions stronger, tests now bright, 🌟
Efficiency glows in the coder's light. 💻
Constructor’s ease with Lombok's might,
The future of our service shines, so right. 🌟🔧


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jun 18, 2024
@sharat87 sharat87 added the ok-to-test Required label for CI label Jun 18, 2024
@sharat87 sharat87 marked this pull request as ready for review June 18, 2024 13:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4d33d6b and 2f13223.

Files selected for processing (4)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCEImpl.java (1 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java (20 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java (1 hunks)
Additional comments not posted (8)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCE.java (1)

9-9: Ensure that all implementations of the LayoutServiceCE interface are updated to accommodate the new getLayout method signature.

Verification successful

The getLayout method in LayoutServiceCEImpl has been updated to include the new parameters defaultPageId and branchName, matching the updated method signature in the LayoutServiceCE interface.

  • Updated method signature in LayoutServiceCEImpl:
    public Mono<Layout> getLayout(String defaultPageId, String layoutId, Boolean viewMode, String branchName) {

No further issues were found regarding the method signature update.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all implementations of `LayoutServiceCE` have updated method signatures.

# Test: Search for implementations of `LayoutServiceCE`. Expect: Updated method signatures.
rg --type java "implements LayoutServiceCE"

Length of output: 205



Script:

#!/bin/bash
# Description: Verify the `getLayout` method signature in `LayoutServiceCEImpl`.

# Test: Search for the `getLayout` method in `LayoutServiceCEImpl`. Expect: Updated method signature.
rg --type java "getLayout" app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCEImpl.java

Length of output: 546

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCEImpl.java (2)

18-18: The use of @RequiredArgsConstructor and @Slf4j is appropriate and reduces boilerplate code. Ensure that all required fields are indeed final or effectively final for @RequiredArgsConstructor to function correctly.

Also applies to: 35-35


Line range hint 37-46: The implementation of getLayout for a single branch scenario correctly delegates to another overload of getLayout. This reuse of code enhances maintainability. Ensure thorough testing of branch logic to prevent any runtime issues.

app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java (5)

134-134: The modifications in the setup and cleanup methods improve the test's setup robustness and cleanup process. Ensure that these changes are reflected in all relevant test scenarios to maintain consistency.

Also applies to: 143-143, 153-153, 159-159, 164-164


197-198: The new assertions added to the updateLayoutInvalidPageId and updateLayoutInvalidAppId methods enhance test reliability by verifying the precondition states. Confirm that these assertions do not interfere with the intended test flows.

Also applies to: 209-209, 233-234, 236-237


259-266: The refactoring of updateLayoutValidPageId to include multiple layout updates tests the system's robustness more thoroughly. Ensure that each update is independent and does not affect the outcomes of other updates.

Also applies to: 273-275, 277-285, 287-291


298-298: The expansion of createComplexAppForExecuteOnLoad to include more diverse action scenarios is a significant improvement. This should help in catching more edge cases. However, ensure that the increased complexity does not introduce flakiness into the tests.

Also applies to: 514-515, 529-539, 581-581, 740-741


1295-1295: The purgePages method effectively cleans up all pages after tests. Confirm that this method is called in a controlled environment to prevent accidental data loss.

@sharat87 sharat87 enabled auto-merge (squash) June 18, 2024 13:10
@sharat87 sharat87 merged commit f718bfb into release Jun 18, 2024
49 of 50 checks passed
@sharat87 sharat87 deleted the chore/no-create-layout branch June 18, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants