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

SWTBot test case: Partition Table Editor #1012

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

AndriiFilippov
Copy link
Collaborator

@AndriiFilippov AndriiFilippov commented Jul 1, 2024

Description

add Partition Table Editor test cases.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • Tests

    • Updated test suite for Espressif IDF project.
    • Added new Partition Table Editor test class.
    • Commented out several redundant test methods and improved existing tests for robustness.
    • Modified project build wait logic and enhanced error handling in test operations.
    • Introduced new methods for checking shell content and managing partition tables.
  • Chores

    • Increased JVM memory allocation for testing.
    • Streamlined test environment setup process.
    • Updated build configuration in project's POM file.

Copy link

coderabbitai bot commented Jul 1, 2024

Walkthrough

This pull request introduces comprehensive modifications to the Espressif IDF UI testing framework. The changes primarily focus on refactoring test classes, enhancing test operations, and updating build configurations. Key modifications include commenting out several test methods in NewEspressifIDFProjectTest, introducing a new NewEspressifIDFProjectPartitionTableEditorTest class, updating environment setup and project test operations, and adjusting the project's Maven configuration to improve testing resource allocation.

Changes

File Change Summary
tests/com.espressif.idf.ui.test/.../NewEspressifIDFProjectTest.java - Commented out multiple test methods
- Updated build and component installation test methods
- Modified console output assertion logic
tests/com.espressif.idf.ui.test/.../NewEspressifIDFProjectPartitionTableEditorTest.java - New test class added
- Comprehensive testing for Partition Table Editor functionality
tests/com.espressif.idf.ui.test/.../EnvSetupOperations.java - Removed C/C++ indexer configuration code
- Added ESP-IDF Manager tab activation/closing
tests/com.espressif.idf.ui.test/.../ProjectTestOperations.java - Reduced project build timeout
- Removed openProjectNewComponentUsingContextMenu method
- Added new methods for shell and partition table testing
tests/pom.xml - Increased JVM memory allocation
- Added new target platform configuration
- Introduced macOS-specific profile

Suggested reviewers

  • alirana01
  • kolipakakondal

Possibly related PRs

Poem

🐰 Hopping through code with glee,
Test rabbits refactor with espree!
Commented lines, new methods bloom,
Our testing framework escapes the gloom 🧪
Debugging magic, pure and bright! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7af99e and ba11e44.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_macos
  • GitHub Check: build

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>, 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. (Beta)
  • @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.

CodeRabbit Configuration 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.

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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3321cc0 and f64ad58.

Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
Additional comments not posted (6)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (6)

35-38: Specify a more specific exception type.

The beforeTestClass method currently throws a generic Exception. It's better to specify a more specific exception type to improve readability and error handling.

-	public static void beforeTestClass() throws Exception
+	public static void beforeTestClass() throws IOException

55-60: Make the sleep duration configurable or add a comment.

The loadEnv method includes a sleep duration of 1000 milliseconds. Consider making this duration configurable or adding a comment to explain its necessity.

-	bot.sleep(1000);
+	bot.sleep(1000); // Sleep to ensure the environment is fully set up

OR

private static final int SLEEP_DURATION = 1000;

private static void loadEnv() throws Exception {
	bot = WorkBenchSWTBot.getBot();
	EnvSetupOperations.setupEspressifEnv(bot);
	bot.sleep(SLEEP_DURATION);
}

62-66: LGTM!

The method givenNewEspressifIDFProjectIsSelected is correctly implemented.


68-71: LGTM!

The method givenProjectNameIs is correctly implemented.


73-76: LGTM!

The method whenNewProjectIsSelected is correctly implemented.


78-83: LGTM!

The method whenProjectIsBuiltUsingContextMenu is correctly implemented.

Comment on lines 41 to 46
public void afterEachTest()
{
Fixture.cleanTestEnv();
}
Copy link

Choose a reason for hiding this comment

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

Handle potential exceptions within the method.

The afterEachTest method currently does not handle potential exceptions. Consider adding exception handling to ensure the test environment is cleaned up properly even if an error occurs.

@After
public void afterEachTest() {
	try {
		Fixture.cleanTestEnv();
	} catch (Exception e) {
		// Log the exception and proceed with cleanup
		e.printStackTrace();
	}
}

Comment on lines +85 to +226
private static void cleanTestEnv()
{
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
ProjectTestOperations.closeAllProjects(bot);
ProjectTestOperations.deleteAllProjects(bot);
}
Copy link

Choose a reason for hiding this comment

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

Handle potential exceptions within the method.

The cleanTestEnv method currently does not handle potential exceptions. Consider adding exception handling to ensure the test environment is cleaned up properly even if an error occurs.

private static void cleanTestEnv() {
	try {
		TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
		ProjectTestOperations.closeAllProjects(bot);
		ProjectTestOperations.deleteAllProjects(bot);
	} catch (Exception e) {
		// Log the exception and proceed with cleanup
		e.printStackTrace();
	}
}

@kolipakakondal
Copy link
Collaborator

@alirana01 please review this

@AndriiFilippov AndriiFilippov changed the title SWTBot test case: Partition Table Editor WIP: SWTBot test case: Partition Table Editor Aug 30, 2024
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: 0

Outside diff range and nitpick comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1)

47-55: Refactor the method name to follow Java naming conventions.

The method name is very long and does not follow the Java naming conventions. Please refactor it to a shorter name that follows the camelCase convention.

For example:

@Test
public void testPartitionTableEditorDisabledForNewUnbuiltProject() throws Exception {
	// ...
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f64ad58 and 2acabf6.

Files selected for processing (3)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (0 hunks)
Files not reviewed due to no reviewable changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java
Additional comments not posted (10)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (9)

35-39: LGTM!

The beforeTestClass method is correctly implemented to load the test environment.


41-45: Skipping comment as the past review feedback is still applicable.

Please address the exception handling suggestion from the previous review round.


64-69: LGTM!

The loadEnv method is correctly implemented to load the test environment.


71-75: LGTM!

The givenNewEspressifIDFProjectIsSelected method is correctly implemented to set up the project category and subcategory for the test.


77-80: LGTM!

The givenProjectNameIs method is correctly implemented to set up the project name for the test.


82-85: LGTM!

The whenNewProjectIsSelected method is correctly implemented to set up a new project for the test.


94-97: LGTM!

The whenOpenPartitionTableEditor method is correctly implemented to open the partition table editor for the test.


99-104: LGTM!

The thenEditorIsDisabled method is correctly implemented to validate the partition table editor is disabled for the test.


106-111: Skipping comment as the past review feedback is still applicable.

Please address the exception handling suggestion from the previous review round.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1)

273-273: LGTM!

The change refactors the method call to use a more generic launchCommandUsingContextMenu method, which improves code reusability and maintainability. The behavior of the test case remains unchanged.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2acabf6 and c070833.

Files selected for processing (2)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

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

Outside diff range and nitpick comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (2)

581-588: LGTM! Consider adding error handling.

The checkShellContent method is well-structured and serves a clear purpose. The naming of the method and variables is appropriate and self-explanatory.

As an improvement, consider adding error handling for exceptional cases, such as when the specified shell or label is not found. This will make the method more robust and provide better feedback to the caller.


590-616: LGTM! Consider adding error handling.

The checkPartitionTableContent method is well-structured and serves a clear purpose. The naming of the method and variables is appropriate and self-explanatory.

As an improvement, consider adding error handling for exceptional cases, such as when the table is not found or has a different structure. This will make the method more robust and provide better feedback to the caller.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 622f45b and 72ca9ac.

Files selected for processing (2)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java
Additional comments not posted (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (1)

Line range hint 629-647: LGTM!

The joinJobByName method is well-structured and serves a clear purpose. The naming of the method and variables is appropriate and self-explanatory.

The method handles the InterruptedException by logging an error message, which is a good practice.

No changes are necessary.

Comment on lines 618 to 632
public static boolean compareRows(SWTWorkbenchBot bot) throws IOException
{
SWTBotTable table = bot.table();
int defaultRows = 3;
int actualRows = table.rowCount();
if (1 != (actualRows - defaultRows))
{
return false;
}
return true;
}
Copy link

Choose a reason for hiding this comment

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

Fix the incorrect logic.

The logic of the compareRows method seems incorrect. It checks if the actual number of rows is not equal to the default value plus one, which is the opposite of what the method name suggests.

If the actual number of rows is equal to the default value plus one, the method should return true, but it returns false instead.

Please update the logic to match the expected behavior:

public static boolean compareRows(SWTWorkbenchBot bot) throws IOException
{
    SWTBotTable table = bot.table();
    int defaultRows = 3;
    int actualRows = table.rowCount();
    return actualRows == defaultRows + 1;
}

This will ensure that the method returns true when the actual number of rows is equal to the default value plus one, and false otherwise.

@AndriiFilippov AndriiFilippov changed the title WIP: SWTBot test case: Partition Table Editor SWTBot test case: Partition Table Editor Sep 18, 2024
@AndriiFilippov
Copy link
Collaborator Author

please, review @alirana01 @sigmaaa

Tests cover basic functional checks:

  1. Project not built: Verify if a pop-up appears when opening the Partition Table.
  2. Check if the table content corresponds to the documentation.
  3. Add a row to the table.
  4. Delete a row from the table.
  5. Delete a row, Save and Quit, reopen, and verify the changes.
  6. Delete a row, Save, reopen, and verify the changes.

Copy link
Collaborator

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

@AndriiFilippov LGTM can you please verify the builds they are failing on linux

edit:Seems like failures are not your tests

@AndriiFilippov
Copy link
Collaborator Author

@AndriiFilippov LGTM can you please verify the builds they are failing on linux

edit:Seems like failures are not your tests

So, could merge ?

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: 6

🧹 Outside diff range and nitpick comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1)

156-161: Consider combining build operations into a single utility method

The method whenProjectIsBuiltUsingContextMenu performs multiple steps to build the project. To improve code reusability and readability, consider combining these steps into a single utility method within ProjectTestOperations.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4e33063 and d48e8b0.

📒 Files selected for processing (3)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (2 hunks)
🔇 Additional comments (7)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

Line range hint 273-279: Improved code reusability with generic command launch method

The change to use ProjectTestOperations.launchCommandUsingContextMenu is a good improvement. It enhances code reusability and flexibility by using a generic method to launch context menu commands. This approach can be easily extended to other commands in the future.


Line range hint 282-284: Consistent use of generic command launch method for project refresh

This change aligns well with the previous modification, using ProjectTestOperations.launchCommandUsingContextMenu for the refresh operation. It maintains consistency in how context menu commands are executed across different operations, which is a good practice for code maintainability.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

221-226: Exception handling in cleanTestEnv method

As previously mentioned in past review comments, the cleanTestEnv method does not handle potential exceptions. Incorporating exception handling ensures that cleanup processes are executed properly even if errors occur.


42-46: Exception handling in afterEachTest method

As previously mentioned in past review comments, the afterEachTest method calls Fixture.cleanTestEnv() without exception handling. Ensure that exceptions are caught and managed to prevent tests from failing silently.


31-34: ⚠️ Potential issue

Adjust method naming conventions in the Fixture inner class

In Java, method names should follow the camelCase convention starting with a lowercase letter. The methods within the Fixture class begin with uppercase letters (e.g., ThenInformationMessagePopUp()), which is inconsistent with Java naming conventions. Please rename these methods to improve code readability and maintainability.

Apply this diff to rename the methods:

- private static void ThenInformationMessagePopUp() throws IOException
+ private static void thenInformationMessagePopUp() throws IOException

- private static void ThenBuiltInPartitionTableDisplayed() throws IOException
+ private static void thenBuiltInPartitionTableDisplayed() throws IOException

- private static void ThenCheckRowAdded() throws IOException
+ private static void thenCheckRowAdded() throws IOException

- private static void ThenCheckRowDeleted() throws IOException
+ private static void thenCheckRowDeleted() throws IOException

- private static void ThenCheckChangesSaved() throws IOException
+ private static void thenCheckChangesSaved() throws IOException

Likely invalid or redundant comment.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (2)

27-30: LGTM on the added imports

The new imports for SWTBotLabel and SWTBotTable are appropriate for the added functionalities.


618-624: LGTM on comparePartitionTableRows method

The method comparePartitionTableRows correctly calculates the difference in row count and compares it to the expected difference.

Comment on lines 48 to 124
@Test
public void givenNewProjectCreatedNotBuiltWhenOpenPartitionTableEditorThenInformationPopUpMessage() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor1Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenOpenPartitionTableEditor();
Fixture.ThenInformationMessagePopUp();
}

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorThenBuiltInPartitionTableDisplayed()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor2Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.ThenBuiltInPartitionTableDisplayed();
}

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenAddRowThenCheckRowAdded() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor3Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.whenAddRowToPartitionTable();
Fixture.ThenCheckRowAdded();
}

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenDeleteSelectedRowThenCheckRowDeleted()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor4Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.whenDeleteRowFromPartitionTable();
Fixture.ThenCheckRowDeleted();
}

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenDeleteSelectedRowWhenSaveAndQuitwhenReopenPartitionTableThenCheckChangesSaved()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor5Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.whenDeleteRowFromPartitionTable();
Fixture.whenSaveAndQuit();
Fixture.whenOpenPartitionTableEditor();
Fixture.thenCheckChangesSaved();
}

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenDeleteSelectedRowWhenSaveAndCancelwhenReopenPartitionTableThenCheckChangesSaved()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor6Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.whenDeleteRowFromPartitionTable();
Fixture.whenSavePartitionTable();
Fixture.whenCancel();
Fixture.whenOpenPartitionTableEditor();
Fixture.thenCheckChangesSaved();
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Place assertions directly within test methods for clarity

While using the Fixture class helps to organize code, placing assertions directly within the test methods enhances test clarity and makes it easier to understand the test flow. Consider refactoring the tests to include assertions in the test methods.

Comment on lines +133 to +138
private static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
bot.sleep(1000);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid using fixed delays like bot.sleep(1000);

Using fixed delays can lead to flaky tests due to variable execution times. Instead, use explicit wait conditions provided by SWTBot to wait for specific UI elements or operations to complete.

Apply this diff to replace bot.sleep(1000); with a proper wait condition:

 private static void loadEnv() throws Exception
 {
     bot = WorkBenchSWTBot.getBot();
     EnvSetupOperations.setupEspressifEnv(bot);
-    bot.sleep(1000);
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }
📝 Committable suggestion

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

Suggested change
private static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
bot.sleep(1000);
}
private static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
}

Comment on lines 163 to 166
private static void whenOpenPartitionTableEditor() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential exceptions when opening the Partition Table Editor

The method whenOpenPartitionTableEditor can throw IOException, but exceptions are not being handled within the method. Consider adding exception handling to ensure that any issues are caught and logged appropriately.

Apply this diff to add exception handling:

 private static void whenOpenPartitionTableEditor()
 {
-    ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
+    try {
+        ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
+    } catch (IOException e) {
+        // Log the exception and handle it accordingly
+        e.printStackTrace();
+    }
 }
📝 Committable suggestion

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

Suggested change
private static void whenOpenPartitionTableEditor() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
}
private static void whenOpenPartitionTableEditor()
{
try {
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
} catch (IOException e) {
// Log the exception and handle it accordingly
e.printStackTrace();
}
}

Comment on lines +626 to +632
public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
{
SWTBotTable table = bot.table();
table.select(1);
bot.toolbarButton("Delete Selected").click();
bot.button("OK").click();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add validation in deletePartitionTableRow

To prevent potential exceptions, consider adding a check to ensure that the table has at least two rows before attempting to select and delete a row at index 1.

Apply this diff to add validation:

 public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
 {
     SWTBotTable table = bot.table();
+    if (table.rowCount() > 1) {
         table.select(1);
         bot.toolbarButton("Delete Selected").click();
         bot.button("OK").click();
+    } else {
+        // Handle the case where there are not enough rows to delete
+        throw new IllegalStateException("Unable to delete row: Table does not have enough rows.");
+    }
 }
📝 Committable suggestion

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

Suggested change
public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
{
SWTBotTable table = bot.table();
table.select(1);
bot.toolbarButton("Delete Selected").click();
bot.button("OK").click();
}
public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
{
SWTBotTable table = bot.table();
if (table.rowCount() > 1) {
table.select(1);
bot.toolbarButton("Delete Selected").click();
bot.button("OK").click();
} else {
// Handle the case where there are not enough rows to delete
throw new IllegalStateException("Unable to delete row: Table does not have enough rows.");
}
}

Comment on lines +581 to +588
public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
{
SWTBotShell shell = bot.shell(shellName);
shell.activate();
SWTBotLabel label = bot.label(expectedText);
String actualText = label.getText();
return expectedText.equals(actualText);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential exceptions in checkShellContent

The method checkShellContent may throw a WidgetNotFoundException if the shell or label with the expected text is not found. To enhance robustness, consider catching this exception and returning false when the shell or label is not found.

Apply this diff to handle exceptions:

 public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
 {
     try {
         SWTBotShell shell = bot.shell(shellName);
         shell.activate();
         SWTBotLabel label = bot.label(expectedText);
         String actualText = label.getText();
         return expectedText.equals(actualText);
     } catch (WidgetNotFoundException e) {
         return false;
     }
 }
📝 Committable suggestion

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

Suggested change
public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
{
SWTBotShell shell = bot.shell(shellName);
shell.activate();
SWTBotLabel label = bot.label(expectedText);
String actualText = label.getText();
return expectedText.equals(actualText);
}
public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
{
try {
SWTBotShell shell = bot.shell(shellName);
shell.activate();
SWTBotLabel label = bot.label(expectedText);
String actualText = label.getText();
return expectedText.equals(actualText);
} catch (WidgetNotFoundException e) {
return false;
}
}

Comment on lines +590 to +616
public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
{
String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
"0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
int builtInIndex = 0;
SWTBotTable table = bot.table();
int columns = table.columnCount();
int rows = table.rowCount();
if (columns != 6 && rows != 3)
{
return false;
}
for (int col = 0; col < columns; col++)
{
for (int row = 0; row < rows; row++)
{
String tableContent = table.cell(row, col);

if (!builtInPartitionArray[builtInIndex].equals(tableContent))
{
return false;
}
builtInIndex++;
}
}
return true;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the condition and loop order in checkPartitionTableContent

  1. Incorrect logical operator in the condition

    The condition if (columns != 6 && rows != 3) should use the logical OR operator || to correctly validate the table dimensions. Using && means the return false statement will not execute if either columns equals 6 or rows equals 3.

  2. Swap the loop order for proper traversal

    The nested loops should iterate over rows first and then columns to access table cells in row-major order, matching the structure of builtInPartitionArray.

Apply this diff to correct the issues:

 public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
 {
     String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
             "0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
     int builtInIndex = 0;
     SWTBotTable table = bot.table();
     int columns = table.columnCount();
     int rows = table.rowCount();
-    if (columns != 6 && rows != 3)
+    if (columns != 6 || rows != 3)
     {
         return false;
     }
-    for (int col = 0; col < columns; col++)
+    for (int row = 0; row < rows; row++)
     {
-        for (int row = 0; row < rows; row++)
+        for (int col = 0; col < columns; col++)
         {
             String tableContent = table.cell(row, col);

             if (!builtInPartitionArray[builtInIndex].equals(tableContent))
             {
                 return false;
             }
             builtInIndex++;
         }
     }
     return true;
 }
📝 Committable suggestion

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

Suggested change
public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
{
String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
"0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
int builtInIndex = 0;
SWTBotTable table = bot.table();
int columns = table.columnCount();
int rows = table.rowCount();
if (columns != 6 && rows != 3)
{
return false;
}
for (int col = 0; col < columns; col++)
{
for (int row = 0; row < rows; row++)
{
String tableContent = table.cell(row, col);
if (!builtInPartitionArray[builtInIndex].equals(tableContent))
{
return false;
}
builtInIndex++;
}
}
return true;
}
public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
{
String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
"0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
int builtInIndex = 0;
SWTBotTable table = bot.table();
int columns = table.columnCount();
int rows = table.rowCount();
if (columns != 6 || rows != 3)
{
return false;
}
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < columns; col++)
{
String tableContent = table.cell(row, col);
if (!builtInPartitionArray[builtInIndex].equals(tableContent))
{
return false;
}
builtInIndex++;
}
}
return true;
}

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d48e8b0 and d392805.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectSBOMTest.java (1 hunks)
🧰 Additional context used

Comment on lines 76 to 91
// @Test
// public void givenNewProjectCreatedBuiltWhenRunSBOMtoolRedirectOutputToFileThenCheckConsoleAndSbomFile()
// throws Exception
// {
// Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
// Fixture.givenProjectNameIs("NewProjectSbomThirdTest");
// Fixture.whenNewProjectIsSelected();
// Fixture.whenProjectIsBuiltUsingContextMenu();
// Fixture.whenOpenSbomTool();
// Fixture.whenRedirectOutputToTheFileClicked();
// Fixture.whenRunSbomTool();
// Fixture.thenCheckInConsole();
// Fixture.whenRefreshProject();
// Fixture.thenOpenSbomFile();
// Fixture.thenCheckSbomFile();
// }
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

SBOM tool output redirection lacks active tests.

The test method givenNewProjectCreatedBuiltWhenRunSBOMtoolRedirectOutputToFileThenCheckConsoleAndSbomFile has been commented out, and no other tests currently cover the functionality of redirecting SBOM tool output to a file. This may lead to unverified behavior in the SBOM feature.

Please address this by either re-enabling the commented-out test or adding new tests to ensure comprehensive coverage of the SBOM tool's output redirection functionality.

🔗 Analysis chain

Clarify the reason for commenting out the test method.

The test method givenNewProjectCreatedBuiltWhenRunSBOMtoolRedirectOutputToFileThenCheckConsoleAndSbomFile has been commented out. This test appears to cover a specific scenario of redirecting SBOM tool output to a file and verifying the results, which seems important for ensuring the tool's functionality.

Could you please clarify:

  1. Why was this test method commented out?
  2. Is the functionality it tests still relevant?
  3. If so, is this scenario covered by other tests, or should we consider re-enabling this test?

Ensuring comprehensive test coverage is crucial for maintaining the reliability of the SBOM tool feature.

To help verify the current test coverage, you can run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for tests related to SBOM file output redirection

# Test: Look for other test methods that might cover similar functionality
rg --type java -i "redirect.*output.*file" tests/

Length of output: 1348

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: 2

🧹 Outside diff range and nitpick comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

Line range hint 389-395: Approve refactoring of component installation method

The change from openProjectNewComponentUsingContextMenu to launchCommandUsingContextMenu appears to be a good refactoring that improves code reusability. This change is approved.

However, consider extracting the string "Install New Component" into a constant to improve maintainability and reduce the risk of typos.

Consider applying this change:

+ private static final String INSTALL_NEW_COMPONENT_COMMAND = "Install New Component";

- ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Install New Component");
+ ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, INSTALL_NEW_COMPONENT_COMMAND);

Line range hint 183-395: Overall feedback: Remove duplicates and focus on meaningful test additions

The changes in this file primarily consist of adding duplicate test methods, which is not a recommended practice in test development. Here are some suggestions for improvement:

  1. Remove all duplicate test methods (those with suffix '1').
  2. If the intention is to increase test coverage, consider adding new test cases that cover different scenarios, edge cases, or potential failure modes.
  3. Instead of duplicating entire methods, you could parameterize existing tests to cover multiple scenarios.
  4. The refactoring in the whenInstallNewComponentUsingContextMenu method is a good change. Consider applying similar refactoring to other methods if applicable.

By focusing on meaningful test additions and avoiding duplication, you can improve the overall quality and maintainability of the test suite.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 577f794 and acf724e.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2 hunks)
🧰 Additional context used

Comment on lines 183 to 191
@Test
public void givenNewIDFProjectIsSelectedThenProjectIsCreatedAndAddedToProjectExplorer1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectTest");
Fixture.whenNewProjectIsSelected();
Fixture.thenProjectIsAddedToProjectExplorer();

}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate test method

This test method is an exact duplicate of givenNewIDFProjectIsSelectedThenProjectIsCreatedAndAddedToProjectExplorer. Duplicate tests don't add value to the test suite and increase maintenance overhead. Consider removing this method or modifying it to test a different scenario if needed.

Comment on lines 193 to 297
Fixture.givenProjectNameIs("NewProjectTestTemplate");
Fixture.givenProjectTemplateIs("bluetooth/esp_hid_device");
Fixture.whenProjectIsCreatedFromTemplate();
Fixture.thenProjectIsAddedToProjectExplorer();
Fixture.thenProjectHasTheFile("esp_hid_device_main.c", "/main");
Fixture.thenProjectHasTheFile("esp_hid_gap.c", "/main");
Fixture.thenProjectHasTheFile("esp_hid_gap.h", "/main");
}

@Test
public void givenNewIDFProjectIsCreatedAndBuiltUsingContextMenuOnProjectThenProjectIsCreatedAndBuilt1()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectForContextMenuBuildTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenConsoleShowsBuildSuccessful();
}

@Test
public void givenNewIDFProjectIsCreatedAndBuiltUsingToolbarButtonThenProjectIsBuilt1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectToolbarBuildButtonTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenConsoleShowsBuildSuccessful();
}

@Test
public void givenNewProjectCreatedAndRenamedAfterThenProjectIsBuildSuccessfully1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectForRenameTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsRenamed("NewProjectForRenameTest2");
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenConsoleShowsBuildSuccessful();
}

@Test
public void givenNewProjectCreatedDfuBuiltThenHasDfuBin1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectTestDFU");
Fixture.whenNewProjectIsSelected();
Fixture.thenLaunchTargetIsSelectedFromLaunchTargets("esp32s2");
Fixture.turnOnDfu();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenProjectHasTheFile("dfu.bin", "/build");
Fixture.turnOffDfu();
}

@Test
public void givenNewProjectCreatedThenInstallNewComponent1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectForInstallNewComponentTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenInstallNewComponentUsingContextMenu();
Fixture.whenRefreshProject();
Fixture.checkIfNewComponentIsInstalledUsingContextMenu();
}

@Test
public void givenNewProjectCreatedBuiltAndThenProjectCleanUsingContextMenu1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectCleanTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenProjectCleanUsingContextMenu();
Fixture.whenRefreshProject();
Fixture.checkIfProjectCleanedFilesInBuildFolder();
}

@Test
public void givenNewProjectCreatedBuiltAndThenProjectFullCleanUsingContextMenu1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectFullCleanTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenProjectFullCleanUsingContextMenu();
Fixture.whenRefreshProject();
Fixture.checkIfProjectFullCleanedFilesInBuildFolder();
}

@Test
public void givenNewProjectCreatedBuiltAndThenProjectPythonCleanUsingContextMenu1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPythonCleanTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenProjectPythonCleanUsingContextMenu();
Fixture.checkPythonCLeanCommandDeleteFolder();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove all duplicate test methods

All test methods with the suffix '1' (from lines 193 to 297) are exact duplicates of existing test methods. This includes:

  • givenNewIDFProjectIsSelectedFromTemplateThenProjectIsCreatedAndAddedToProjectExplorerWithRequiredFiles1
  • givenNewIDFProjectIsCreatedAndBuiltUsingContextMenuOnProjectThenProjectIsCreatedAndBuilt1
  • givenNewIDFProjectIsCreatedAndBuiltUsingToolbarButtonThenProjectIsBuilt1
  • givenNewProjectCreatedAndRenamedAfterThenProjectIsBuildSuccessfully1
  • givenNewProjectCreatedDfuBuiltThenHasDfuBin1
  • givenNewProjectCreatedThenInstallNewComponent1
  • givenNewProjectCreatedBuiltAndThenProjectCleanUsingContextMenu1
  • givenNewProjectCreatedBuiltAndThenProjectFullCleanUsingContextMenu1
  • givenNewProjectCreatedBuiltAndThenProjectPythonCleanUsingContextMenu1

Duplicating test methods without changes doesn't improve test coverage and increases maintenance overhead. Consider removing these duplicate methods. If the intention is to test different scenarios or edge cases, modify the methods to reflect those specific cases instead of creating exact duplicates.

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: 2

🧹 Outside diff range and nitpick comments (6)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1)

80-81: LGTM! Consider adding a clarifying comment.

The cleanup of the ESP-IDF Manager tab is a good practice for test isolation. Consider adding a comment to explain the purpose:

+  // Cleanup: Ensure ESP-IDF Manager tab is closed after setup to prevent UI state interference
   bot.cTabItem("ESP-IDF Manager").activate();
   bot.cTabItem("ESP-IDF Manager").close();
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

25-30: Update class header documentation

The class header comment incorrectly states this is for testing the "SBOM feature". Please update it to reflect that this class tests the Partition Table Editor functionality.

 /**
- * Test class to test the SBOM feature
+ * Test class to test the Partition Table Editor functionality
  *
  * @author Andrii Filippov
  *
  */

55-131: Consider more concise test method names and specific exceptions

While the test methods are well-structured, consider:

  1. Using shorter but still descriptive names
  2. Declaring specific exceptions instead of the broad Exception

Example of more concise naming:

-public void givenNewProjectCreatedNotBuiltWhenOpenPartitionTableEditorThenInformationPopUpMessage()
+public void openEditorWithoutBuildShowsInfoMessage()

-public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorThenBuiltInPartitionTableDisplayed()
+public void openEditorWithBuiltProjectShowsTable()

Example of specific exception handling:

-public void openEditorWithoutBuildShowsInfoMessage() throws Exception
+public void openEditorWithoutBuildShowsInfoMessage() throws IOException

34-35: Consider adding edge case tests

The current test suite covers basic functionality well. Consider adding tests for:

  1. Invalid partition table configurations
  2. Maximum/minimum values for partition sizes
  3. Concurrent access to the partition table
  4. Error scenarios during save operations

Would you like assistance in implementing these additional test cases?

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (2)

88-89: Consider making the build wait timeout configurable

The build wait timeout has been reduced from 600,000ms to 300,000ms. While this might be sufficient for most cases, consider making it configurable through a system property to handle varying build times across different environments.

The addition of consoleView.close() is good as it helps clean up UI resources.

- DefaultPropertyFetcher.getLongPropertyValue(DEFAULT_PROJECT_BUILD_WAIT_PROPERTY, 300000));
+ DefaultPropertyFetcher.getLongPropertyValue(DEFAULT_PROJECT_BUILD_WAIT_PROPERTY, 
+    System.getProperty("build.wait.timeout", "300000")));

621-627: Improve readability of comparePartitionTableRows

The method could be more readable by using descriptive variable names and extracting the calculation into a separate variable.

 public static boolean comparePartitionTableRows(SWTWorkbenchBot bot, int expectedDifference) throws IOException
 {
     SWTBotTable table = bot.table();
-    int defaultRows = 3;
+    int expectedBaseRows = 3;
     int actualRows = table.rowCount();
-    return (actualRows - defaultRows) == expectedDifference;
+    int actualDifference = actualRows - expectedBaseRows;
+    return actualDifference == expectedDifference;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between acf724e and c009d36.

📒 Files selected for processing (3)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (4 hunks)
🔇 Additional comments (6)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

36-53: LGTM! Good error handling in setup/teardown

The setup and teardown methods are well-implemented with proper error handling.


140-145: Replace fixed delay with explicit wait condition

The bot.sleep(1000) should be replaced with an explicit wait condition as suggested in the previous review.


170-173: Add exception handling in whenOpenPartitionTableEditor

The method should handle potential exceptions as suggested in the previous review.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (3)

584-591: Add error handling in checkShellContent

This is a duplicate of a previous review comment. The method needs to handle WidgetNotFoundException when the shell or label is not found.


593-619: Fix logical operator and loop order in checkPartitionTableContent

This is a duplicate of a previous review comment. The method needs:

  1. Correct logical operator in the dimension check
  2. Swap the loop order for proper traversal

629-635: Add validation in deletePartitionTableRow

This is a duplicate of a previous review comment. The method needs to validate that the table has enough rows before attempting to delete.

Comment on lines +175 to +179
private static void ThenInformationMessagePopUp() throws IOException
{
assertTrue(ProjectTestOperations.checkShellContent(bot, "Information",
"Failed to get partition CSV file name from sdkconfig. Make sure your project is compiled and has sdkconfig."));
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Follow Java naming conventions for method names

Method names starting with uppercase letters don't follow Java naming conventions. Please update them to start with lowercase letters.

-private static void ThenInformationMessagePopUp()
+private static void thenInformationMessagePopUp()

-private static void ThenBuiltInPartitionTableDisplayed()
+private static void thenBuiltInPartitionTableDisplayed()

-private static void ThenCheckRowAdded()
+private static void thenCheckRowAdded()

-private static void ThenCheckRowDeleted()
+private static void thenCheckRowDeleted()

Also applies to: 181-184, 191-194, 201-204, 223-226

Comment on lines 304 to 305
bot.cTabItem("README.md").activate();
bot.cTabItem("README.md").close();
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider handling potential widget exceptions

The README tab operations might fail if the tab doesn't exist. Consider adding error handling.

- bot.cTabItem("README.md").activate();
- bot.cTabItem("README.md").close();
+ try {
+     SWTBotCTabItem readmeTab = bot.cTabItem("README.md");
+     readmeTab.activate();
+     readmeTab.close();
+ } catch (WidgetNotFoundException e) {
+     logger.debug("README.md tab not found", e);
+ }

Committable suggestion skipped: line range outside the PR's diff.

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 (5)
.github/workflows/ci.yml (5)

13-16: Consider making runner labels more maintainable

The runner labels are hardcoded to a specific machine (BrnoUBU0004). This tight coupling could cause issues if the runner needs to be replaced or if you need to scale the CI pipeline.

Consider using more generic labels based on capabilities rather than specific machine names.


25-25: Consider parameterizing the workspace path

The workspace path is hardcoded. This could cause issues when running on different environments or if the runner configuration changes.

Consider using a GitHub Actions environment variable or workflow input parameter for the workspace path:

-- run: mkdir -p /opt/actions-runner/_work/workspace/testdata/.metadata
++ run: mkdir -p ${GITHUB_WORKSPACE}/testdata/.metadata

48-55: Optimize Maven build configuration

The Maven build configuration has several points for optimization:

  1. Debug logging (-X) is always enabled, which can slow down the build and create large log files.
  2. The workspace path is repeated in multiple parameters.

Consider these improvements:

  run: |
    export NO_AT_BRIDGE=1
    mvn clean verify \
      -Djarsigner.skip=true \
      -DskipTests=false \
-     -DtestWorkspace=/opt/actions-runner/_work/workspace/testdata \
-     -Dtycho.testArgLine="-data /opt/actions-runner/_work/workspace/testdata" \
-     -X -e
+     -DtestWorkspace=${WORKSPACE_DIR} \
+     -Dtycho.testArgLine="-data ${WORKSPACE_DIR}" \
+     -e

Where WORKSPACE_DIR is defined as an environment variable at the job level.


94-98: Improve version extraction reliability

The version extraction uses a complex sed command that might be fragile if the filename pattern changes.

Consider using a more robust approach:

  - name: Extract Version Number
    id: extract_version
    run: |
-     version=$(ls releng/com.espressif.idf.product/target/products/Espressif-IDE-*.tar.gz | sed -E 's/.*Espressif-IDE-([0-9]+\.[0-9]+\.[0-9]+)-.*/\1/' | head -n 1)
+     version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
      echo "VERSION=${version}" >> $GITHUB_ENV

144-145: Fix YAML formatting

Remove extra blank lines at the end of the file.

                   releng/ide-dmg-builder/Espressif-IDE-macosx-cocoa-x86_64.dmg
                   releng/ide-dmg-builder/Espressif-IDE-macosx-cocoa-aarch64.dmg
-
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 145-145: too many blank lines

(1 > 0) (empty-lines)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c6af85 and 9716744.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml (1 hunks)
  • tests/pom.xml (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/pom.xml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ci.yml

5-5: could not parse as YAML: yaml: line 5: found character that cannot start any token

(syntax-check)

🪛 yamllint (1.35.1)
.github/workflows/ci.yml

[error] 5-5: syntax error: found character '\t' that cannot start any token

(syntax)


[warning] 145-145: too many blank lines

(1 > 0) (empty-lines)

Comment on lines 5 to 8
push:
branches: [ master ]
pull_request:
branches: [ master ]
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix YAML syntax: Replace tabs with spaces

The YAML syntax is invalid due to the use of tabs for indentation. YAML requires spaces for indentation.

Apply this diff to fix the indentation:

-	push:
-		branches: [ master ]
-	pull_request:
-		branches: [ master ]
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
📝 Committable suggestion

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

Suggested change
push:
branches: [ master ]
pull_request:
branches: [ master ]
push:
branches: [ master ]
pull_request:
branches: [ master ]
🧰 Tools
🪛 actionlint (1.7.4)

5-5: could not parse as YAML: yaml: line 5: found character that cannot start any token

(syntax-check)

🪛 yamllint (1.35.1)

[error] 5-5: syntax error: found character '\t' that cannot start any token

(syntax)

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 (1)
.github/workflows/ci.yml (1)

1-16: Missing essential workflow configurations

The workflow is missing several important configurations:

  1. Timeout settings to prevent hung jobs
  2. Environment setup for SWTBot tests
  3. Test artifacts collection
  4. Test results reporting

Consider adding these essential configurations:

name: Test Runner

on:
  push:
    branches:
      - master

jobs:
  test:
+    timeout-minutes: 60
    runs-on:
      - self-hosted
      - BrnoUBU0004
+    env:
+      DISPLAY: :99
+
    steps:
+      - uses: actions/checkout@v4
+      
+      - name: Set up test environment
+        run: |
+          Xvfb :99 &
+          sleep 3
+
+      - name: Set up Java
+        uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: '17'
+
       - name: Test Runner Functionality
-        run: echo "Runner is active and working!"
+        run: |
+          # Add your SWTBot test execution commands here
+          echo "Running SWTBot tests..."
+
+      - name: Upload Test Results
+        if: always()
+        uses: actions/upload-artifact@v3
+        with:
+          name: test-results
+          path: |
+            **/TEST-*.xml
+            **/swtbot-results/**
🧰 Tools
🪛 actionlint (1.7.4)

12-12: label "BrnoUBU0004" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9716744 and 8e3ef3b.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ci.yml

12-12: label "BrnoUBU0004" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

🔇 Additional comments (2)
.github/workflows/ci.yml (2)

3-7: Verify the branch protection rules for direct pushes to master

The workflow only triggers on push to master branch. This could potentially allow untested changes to be merged directly into the master branch without going through pull request reviews.

Consider adding pull request trigger to ensure changes are tested before merging:

on:
  push:
    branches:
      - master
+  pull_request:
+    branches:
+      - master

9-13: ⚠️ Potential issue

Review self-hosted runner security implications

Using a self-hosted runner with custom label BrnoUBU0004 has several implications:

  1. The runner label is not standard and might cause issues with workflow portability
  2. Self-hosted runners can access internal resources and need proper security controls
✅ Verification successful

Let me analyze the files found and gather more specific information about potential security implications.


Based on the analysis of the codebase, I can now generate the final response:

Self-hosted runner usage requires security review but appears appropriate

The self-hosted runner with label BrnoUBU0004 is used in a controlled development environment for this Eclipse-based IDE project. The codebase analysis shows:

  1. No sensitive credentials or tokens are hardcoded in the repository
  2. Environment variables are properly managed through Eclipse's IDFEnvironmentVariables system
  3. The runner primarily handles build and test operations for an IDE development workflow

While using a self-hosted runner does require security considerations, in this case:

  • The custom label appears to be part of a standardized naming scheme for the organization's build infrastructure
  • The codebase doesn't expose sensitive operations to the CI environment
  • The project is an IDE development tool, where controlled build environments are often necessary
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any sensitive files or configurations in the repository
# that might be accessible to the self-hosted runner
rg -g '!.git' -l '(?i)(password|secret|key|token|credential)'

Length of output: 8900


Script:

#!/bin/bash
# Check for workflow files that might access sensitive resources
rg -g '*.yml' -g '*.yaml' -A 5 -B 5 '(secrets\.|env\.|environment:)'

# Check for other workflow files using self-hosted runners
fd -e yml -e yaml . .github/workflows/ --exec grep -l "self-hosted"

# Look for any environment variables or secrets usage in the codebase
rg -g '!.git' -A 3 '(?i)(GITHUB_TOKEN|API_KEY|process\.env|getenv|System\.getenv|secrets\.|SECRET)'

Length of output: 40980

🧰 Tools
🪛 actionlint (1.7.4)

12-12: label "BrnoUBU0004" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

Comment on lines 15 to 16
- name: Test Runner Functionality
run: echo "Runner is active and working!"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Pipeline appears to be incomplete

The current step only echoes a test message, which seems insufficient for a test pipeline. Based on the PR objectives mentioning SWTBot test cases for the Partition Table Editor, the workflow should include steps to:

  1. Set up the test environment
  2. Run the SWTBot tests
  3. Report test results

Would you like me to help generate a complete workflow configuration that includes the necessary steps for running SWTBot tests?

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

🔭 Outside diff range comments (2)
.github/workflows/ci.yml (2)

Line range hint 47-48: Configure environment for SWTBot UI tests

The current Maven command doesn't properly set up the environment for SWTBot UI tests. These tests require a display server and specific configurations.

Enhance the build step with proper SWTBot configuration:

     - name: Build with Maven
-      run: export NO_AT_BRIDGE=1 && mvn clean verify -Djarsigner.skip=true spotbugs:spotbugs -DskipTests=false -DtestWorkspace=/opt/actions-runner/_work/workspace
+      run: |
+        # Set up Xvfb for UI tests
+        export DISPLAY=:99
+        Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
+        # Wait for Xvfb
+        sleep 3
+        # Run tests with SWTBot configuration
+        export NO_AT_BRIDGE=1
+        mvn clean verify \
+          -Djarsigner.skip=true \
+          -DskipTests=false \
+          -DtestWorkspace=/opt/actions-runner/_work/workspace \
+          -Dtest.useUIThread=false \
+          -Dorg.eclipse.swtbot.search.timeout=10000 \
+          spotbugs:spotbugs
🧰 Tools
🪛 actionlint (1.7.4)

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 40-40: trailing spaces

(trailing-spaces)


Line range hint 11-11: Add Windows platform support for complete test coverage

The PR objectives require testing on Windows, Linux, and macOS, but the workflow is missing Windows platform support.

Add Windows job configuration:

jobs:
+  build_windows:
+    runs-on: windows-latest
+    
+    steps:
+    - uses: actions/checkout@v2
+    
+    - name: Set up JDK 21
+      uses: actions/setup-java@v4
+      with:
+        java-version: '21'
+        distribution: 'temurin'
+    
+    - name: Build with Maven
+      shell: bash
+      run: |
+        # Run tests with SWTBot configuration
+        mvn clean verify \
+          -Djarsigner.skip=true \
+          -DskipTests=false \
+          -DtestWorkspace=$GITHUB_WORKSPACE/_work/workspace \
+          -Dtest.useUIThread=false \
+          -Dorg.eclipse.swtbot.search.timeout=10000 \
+          spotbugs:spotbugs
🧰 Tools
🪛 actionlint (1.7.4)

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 40-40: trailing spaces

(trailing-spaces)

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

Line range hint 12-16: Improve test environment isolation and cleanup

Self-hosted runners need proper workspace isolation and cleanup to prevent test interference between runs.

Add cleanup steps:

     steps:
+    - name: Clean workspace
+      run: |
+        rm -rf $GITHUB_WORKSPACE/*
+        rm -rf ~/.m2/repository/com/espressif/
     - uses: actions/checkout@v2
🧰 Tools
🪛 actionlint (1.7.4)

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 40-40: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e3ef3b and ac17e73.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ci.yml

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

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

🔭 Outside diff range comments (1)
.github/workflows/ci.yml (1)

Line range hint 47-48: Configure SWTBot test execution environment

The Maven command needs to be updated to properly handle SWTBot UI tests. The hardcoded test workspace path might cause issues on different runners.

Consider updating the Maven command to include SWTBot-specific configurations:

-    run: export NO_AT_BRIDGE=1 && mvn clean verify -Djarsigner.skip=true spotbugs:spotbugs -DskipTests=false -DtestWorkspace=/opt/actions-runner/_work/workspace
+    run: |
+      export NO_AT_BRIDGE=1
+      export DISPLAY=:99
+      Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
+      mvn clean verify \
+        -Djarsigner.skip=true \
+        -DskipTests=false \
+        -DtestWorkspace=${{ runner.temp }}/workspace \
+        -Dtest.useUIThread=false \
+        -Dtycho.testArgLine="-Dorg.eclipse.swtbot.search.timeout=10000" \
+        spotbugs:spotbugs
🧰 Tools
🪛 actionlint (1.7.4)

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 40-40: trailing spaces

(trailing-spaces)

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

Line range hint 77-82: Improve version extraction reliability

The current version extraction relies on parsing filenames, which could be fragile.

Consider using Maven's version information directly:

    - name: Extract version number
      id: extract_version
      run: |
-       # List all files and extract the version number from the file names
-       version=$(ls releng/com.espressif.idf.product/target/products/Espressif-IDE-*.tar.gz | sed -E 's/.*Espressif-IDE-([0-9]+\.[0-9]+\.[0-9]+)-.*/\1/' | head -n 1)
+       # Extract version from Maven
+       version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
        echo "VERSION=${version}" >> $GITHUB_ENV
🧰 Tools
🪛 actionlint (1.7.4)

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 40-40: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac17e73 and e801efe.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (2 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ci.yml

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


69-69: the runner of "actions/setup-java@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (1)
.github/workflows/ci.yml (1)

Line range hint 13-16: Ensure comprehensive platform coverage for SWTBot tests

The current configuration uses a specific self-hosted runner (BrnoUBU0004), which might limit the ability to test on all platforms. According to the PR objectives, the tests should be verified on Windows, Linux, and macOS.

Consider using GitHub-hosted runners or multiple self-hosted runners to ensure comprehensive platform coverage:

   runs-on:
-    - self-hosted
-    - eclipse
-    - BrnoUBU0004
+    ${{ matrix.os }}
+  strategy:
+    matrix:
+      os: [ubuntu-latest, windows-latest]
🧰 Tools
🪛 actionlint (1.7.4)

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 40-40: trailing spaces

(trailing-spaces)

Comment on lines 41 to 45
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update setup-java action to latest version

Both jobs use outdated versions of the setup-java action.

Update to the latest version:

# In both jobs
-    uses: actions/setup-java@v3
-    uses: actions/setup-java@v2
+    uses: actions/setup-java@v4

Also applies to: 68-71

🧰 Tools
🪛 actionlint (1.7.4)

42-42: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

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: 2

🔭 Outside diff range comments (1)
releng/com.espressif.idf.configuration/pom.xml (1)

Line range hint 41-41: Update JRE version for consistency

This file still references JRE 17 while other files have been updated to JRE 21. This inconsistency could lead to build issues.

Apply this diff to maintain consistency:

-    <executionEnvironment>org.eclipse.justj.openjdk.hotspot.jre.full-17</executionEnvironment>
+    <executionEnvironment>org.eclipse.justj.openjdk.hotspot.jre.full-21</executionEnvironment>
🧹 Nitpick comments (1)
tests/com.espressif.idf.ui.test/pom.xml (1)

14-20: Consider managing dependencies in parent POM.

For better maintainability and version consistency across modules, consider moving the dependency declaration to the parent POM's <dependencyManagement> section.

Here's how you could refactor it:

  1. In the parent POM (com.espressif.idf.tests), add:
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.espressif.idf</groupId>
            <artifactId>com.espressif.idf.core.test</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>
  1. Then in this file, simplify to:
<dependencies>
    <dependency>
        <groupId>com.espressif.idf</groupId>
        <artifactId>com.espressif.idf.core.test</artifactId>
    </dependency>
</dependencies>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e801efe and 7ae4227.

📒 Files selected for processing (4)
  • bundles/pom.xml (1 hunks)
  • releng/com.espressif.idf.configuration/pom.xml (1 hunks)
  • releng/com.espressif.idf.product/pom.xml (1 hunks)
  • tests/com.espressif.idf.ui.test/pom.xml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build_macos
🔇 Additional comments (2)
tests/com.espressif.idf.ui.test/pom.xml (1)

14-20: Verify version consistency across modules.

The new dependency uses version 0.0.1-SNAPSHOT while the parent POM uses 1.0.0-SNAPSHOT. Please ensure this version difference is intentional and won't cause any compatibility issues.

Run this script to check version consistency across related modules:

✅ Verification successful

Version consistency verified across test modules

The version difference is consistent with the project's structure - all test modules use 0.0.1-SNAPSHOT while parent modules use 1.0.0-SNAPSHOT. This appears to be an intentional versioning scheme.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check version consistency across related modules
# Look for other POMs that might reference these artifacts

echo "Checking version references in POMs:"
find . -name "pom.xml" -type f -exec grep -l "com.espressif.idf.core.test\|com.espressif.idf.ui.test" {} \;

echo -e "\nChecking version declarations:"
find . -name "pom.xml" -type f -exec grep -A 1 -B 1 "0.0.1-SNAPSHOT\|1.0.0-SNAPSHOT" {} \;

Length of output: 4612

releng/com.espressif.idf.configuration/pom.xml (1)

109-109: Review SpotBugs plugin changelog for breaking changes

The SpotBugs Maven plugin has been updated from 4.7.0.0 to 4.7.3.0. Please review the changelog to ensure there are no breaking changes that could affect the build process.

✅ Verification successful

SpotBugs plugin update appears safe

The update from 4.7.0.0 to 4.7.3.0 is a patch version change with standard plugin usage and no custom configurations that could be affected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Fetch SpotBugs Maven plugin releases to check for breaking changes
echo "Fetching SpotBugs Maven plugin releases..."
gh api repos/spotbugs/spotbugs-maven-plugin/releases --jq '.[].body' | grep -i "breaking"

Length of output: 184


Script:

#!/bin/bash
# Search for SpotBugs configurations and usage in the codebase
echo "Searching for SpotBugs configurations..."
rg -l "spotbugs" --type xml

# Check for custom SpotBugs configurations
echo -e "\nSearching for spotbugs-exclude.xml files..."
fd "spotbugs-exclude.xml"

# Look for any SpotBugs custom rules
echo -e "\nSearching for custom SpotBugs rules..."
rg -l "CustomBugDetector|BugDetector" --type java

Length of output: 439

bundles/pom.xml Outdated
@@ -46,7 +46,7 @@
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<executionEnvironment>org.eclipse.justj.openjdk.hotspot.jre.full-17</executionEnvironment>
<executionEnvironment>org.eclipse.justj.openjdk.hotspot.jre.full-21</executionEnvironment>
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

JRE 21 upgrade is incomplete and inconsistent

The upgrade to JRE 21 in bundles/pom.xml conflicts with the current codebase configuration:

  • All bundle MANIFEST.MF files still require JavaSE-17 or JavaSE-11
  • CI workflows are inconsistent: only ci.yml uses Java 21, while others use Java 17
  • A systematic upgrade approach is needed to align all components with JRE 21
🔗 Analysis chain

Verify compatibility with JRE 21 upgrade

The upgrade from JRE 17 to JRE 21 is a significant change that requires careful verification:

  1. Ensure all dependencies and plugins are compatible with JRE 21
  2. Verify that all build environments (CI/CD) have JRE 21 installed
  3. Test the build process on all supported platforms (Windows, Linux, macOS)

Run this script to check for potential compatibility issues:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for explicit Java version requirements in dependencies
echo "Checking for Java version requirements in dependencies..."
find . -name "MANIFEST.MF" -type f -exec grep -l "Bundle-RequiredExecutionEnvironment\|JavaSE" {} \;

# Check for Java version in build environments
echo "Checking Java version in GitHub Actions workflows..."
find .github/workflows -type f -exec grep -l "java-version\|setup-java" {} \;

Length of output: 1733


Script:

#!/bin/bash
# Check actual JRE requirements in MANIFEST.MF files
echo "=== Checking JRE requirements in MANIFEST.MF files ==="
find . -name "MANIFEST.MF" -type f -exec sh -c 'echo "=== $1 ==="; grep "Bundle-RequiredExecutionEnvironment\|JavaSE" "$1"' sh {} \;

echo -e "\n=== Checking Java version in GitHub Actions workflows ==="
find .github/workflows -type f -exec sh -c 'echo "=== $1 ==="; grep -A 1 "java-version\|setup-java" "$1"' sh {} \;

Length of output: 3781

@@ -114,7 +114,7 @@
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<executionEnvironment>org.eclipse.justj.openjdk.hotspot.jre.full-17</executionEnvironment>
<executionEnvironment>org.eclipse.justj.openjdk.hotspot.jre.full-21</executionEnvironment>
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Update JRE version consistently across product configuration

The upgrade to JRE 21 in the POM file requires corresponding updates in idf.product:

  • Update -Dosgi.requiredJavaVersion=17 to -Dosgi.requiredJavaVersion=21 in vmArgs for all platforms
  • Update VM container definitions from JavaSE-17 to JavaSE-21 for linux, macos, and windows
🔗 Analysis chain

Verify product packaging with JRE 21

The upgrade to JRE 21 in the product configuration requires verification of:

  1. Product packaging compatibility with JRE 21
  2. JRE 21 support for all target architectures (x86_64, aarch64)
  3. Bundle signing process compatibility
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check product configuration for potential JRE dependencies
echo "Checking product configuration..."
find . -name "*.product" -type f -exec grep -l "java\|jre\|jdk" {} \;

# Check for architecture-specific configurations
echo "Checking architecture-specific configurations..."
find . -name "*.product" -type f -exec grep -l "x86_64\|aarch64" {} \;

Length of output: 381


Script:

#!/bin/bash
# Display content of the product configuration file
echo "Content of idf.product:"
cat ./releng/com.espressif.idf.product/idf.product

# Check for any feature requirements that might depend on Java version
echo -e "\nChecking feature requirements:"
rg -l "requiresJava|requiredJavaVersion|Bundle-RequiredExecutionEnvironment" --type xml

Length of output: 5968

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 (2)
.github/workflows/ci_windows.yml (2)

40-44: Update the setup-java action version

The static analysis tool indicates that the runner for actions/setup-java@v3 might be outdated. Consider updating to the latest version to ensure compatibility and security.

-    - name: Set up JDK 21
-      uses: actions/setup-java@v3
+    - name: Set up JDK 21
+      uses: actions/setup-java@v4
       with:
         java-version: '21'
         distribution: 'temurin'
🧰 Tools
🪛 actionlint (1.7.4)

41-41: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


Line range hint 47-47: Consider parameterizing the test workspace path

The hardcoded Windows test workspace path might cause issues when running on different machines or in different environments.

Consider using a GitHub Actions environment variable or a workflow input parameter:

-      run: mvn clean verify "-Djarsigner.skip=true" "-DskipTests=false" "-DtestWorkspace=C:/actions-runner/_work/workspace"
+      run: mvn clean verify "-Djarsigner.skip=true" "-DskipTests=false" "-DtestWorkspace=${{ runner.workspace }}"
🧰 Tools
🪛 actionlint (1.7.4)

41-41: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 39-39: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ae4227 and 9c15093.

📒 Files selected for processing (1)
  • .github/workflows/ci_windows.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ci_windows.yml

41-41: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build_macos

Comment on lines 40 to 44
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

JDK 21 upgrade requires additional configuration changes

The codebase is currently configured for JDK 17. Before upgrading to JDK 21, the following changes are required:

  • Update target platform configuration in bundles/pom.xml from org.eclipse.justj.openjdk.hotspot.jre.full-17 to JDK 21
  • Update JustJ OpenJDK dependency in target platform from version 17.0.12 to a JDK 21 version
  • Verify SWTBot test compatibility with JDK 21
🔗 Analysis chain

Verify JDK 21 compatibility with project dependencies

The upgrade from JDK 17 to 21 is significant. While using the latest JDK version is generally good practice, please ensure:

  1. All project dependencies and plugins support JDK 21
  2. SWTBot tests are compatible with JDK 21
  3. The Eclipse RCP target platform supports JDK 21

Run this script to check for potential compatibility issues:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for JDK version constraints in project dependencies

# Check Maven POMs for Java version constraints
echo "Checking Java version constraints in POMs..."
fd -e xml -x grep -l "source\|target\|release\|java.version" {}

# Check for SWTBot version compatibility
echo "Checking SWTBot dependencies..."
fd -e xml -x grep -l "org.eclipse.swtbot" {}

Length of output: 1007


Script:

#!/bin/bash
# Extract Java version settings and target platform configuration
echo "=== Java Version Settings ==="
rg -A 2 "<maven.compiler.(source|target)>|<java.version>|<release>" ./releng/pom.xml ./bundles/pom.xml ./tests/pom.xml

echo -e "\n=== Target Platform Configuration ==="
cat ./releng/com.espressif.idf.target/pom.xml

echo -e "\n=== SWTBot Test Files ==="
fd -e java -x grep -l "SWTBot|swtbot" {}

Length of output: 1016


Script:

#!/bin/bash
echo "=== Java Version Settings (Extended Search) ==="
rg -l "source|target|release|java.version" ./releng/pom.xml ./bundles/pom.xml ./tests/pom.xml | xargs cat

echo -e "\n=== Target Platform Definition ==="
fd -e target -x cat {}

echo -e "\n=== Test Files ==="
fd -e java -p "test" -x head -n 20 {}

Length of output: 46384

🧰 Tools
🪛 actionlint (1.7.4)

41-41: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

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 (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (2)

55-87: Improve test readability by extracting setup steps

The test methods contain multiple setup steps that could be extracted into helper methods to improve readability and maintainability.

For example, extract common setup steps into a helper method:

+private void setupTestProject(String projectName) throws Exception {
+    Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
+    Fixture.givenProjectNameIs(projectName);
+    Fixture.whenNewProjectIsSelected();
+}

 @Test
 public void givenNewProjectCreatedNotBuiltWhenOpenPartitionTableEditorThenInformationPopUpMessage() throws Exception {
-    Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
-    Fixture.givenProjectNameIs("NewProjectPartitionTableEditor1Test");
-    Fixture.whenNewProjectIsSelected();
+    setupTestProject("NewProjectPartitionTableEditor1Test");
     Fixture.whenOpenPartitionTableEditor();
     Fixture.ThenInformationMessagePopUp();
 }

137-140: Enhance assertions with meaningful error messages

The assertions should include descriptive error messages to help identify test failures.

Apply this diff to improve the assertions:

 private static void ThenBuiltInPartitionTableDisplayed() throws IOException {
-    assertTrue(ProjectTestOperations.checkPartitionTableContent(bot));
+    assertTrue("Expected built-in partition table content was not displayed",
+        ProjectTestOperations.checkPartitionTableContent(bot));
 }

 private static void ThenCheckRowAdded() throws IOException {
-    assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
+    assertTrue("Expected one additional row in partition table",
+        ProjectTestOperations.comparePartitionTableRows(bot, 1));
 }

Also applies to: 147-150

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c15093 and 8a0a8d5.

📒 Files selected for processing (2)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionEditorTest.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build_macos
🔇 Additional comments (4)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (4)

55-63: Method naming doesn't follow Java conventions

Method names starting with uppercase letters (e.g., ThenInformationMessagePopUp) don't follow Java naming conventions.


96-101: Replace fixed delay with explicit wait condition

Using fixed delays can lead to flaky tests.


126-129: Add exception handling for Partition Table Editor operations

The method should handle potential exceptions.


142-146: Verify row addition success before proceeding

The whenAddRowToPartitionTable method should verify that the button click was successful.

Add verification by running this script to check if there are any error dialogs after clicking the button:

Comment on lines +25 to +30
/**
* Test class to test the SBOM feature
*
* @author Andrii Filippov
*
*/
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update JavaDoc to reflect the correct purpose of the test class

The JavaDoc comment incorrectly states this is a test class for the "SBOM feature", but the class actually tests the Partition Table Editor functionality.

Apply this diff to correct the JavaDoc:

 /**
- * Test class to test the SBOM feature
+ * Test class to validate the Partition Table Editor functionality
  * 
  * @author Andrii Filippov
  *
  */
📝 Committable suggestion

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

Suggested change
/**
* Test class to test the SBOM feature
*
* @author Andrii Filippov
*
*/
/**
* Test class to validate the Partition Table Editor functionality
*
* @author Andrii Filippov
*
*/

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: 0

🧹 Nitpick comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (2)

55-87: Improve test method documentation and naming

While the test methods follow good practices, consider these improvements:

  1. Add descriptive comments before each test method explaining the test scenario
  2. Consider shorter method names while maintaining clarity, e.g.:
    • testPartitionEditorWithoutBuild()
    • testPartitionEditorWithBuild()
    • testAddRowToPartitionTable()

143-151: Add verification for row addition

The row addition test could be more robust by verifying the content of the added row, not just the row count.

 private static void whenAddRowToPartitionTable() throws IOException
 {
     bot.toolbarButton("Add Row").click();
+    // Wait for row to be added and become editable
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }

 private static void ThenCheckRowAdded() throws IOException
 {
-    assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
+    assertTrue("Row count should increase by 1", ProjectTestOperations.comparePartitionTableRows(bot, 1));
+    // Verify the new row has default values
+    assertTrue("New row should have default values", 
+        ProjectTestOperations.verifyPartitionTableRowContent(bot, "app", "0x10000", "0x100000", ""));
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bcc033 and a879f49.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

25-30: Update JavaDoc to reflect the correct purpose of the test class

The JavaDoc comment incorrectly states this is a test class for the "SBOM feature", but the class actually tests the Partition Table Editor functionality.


132-151: Follow Java naming conventions for method names

Methods starting with uppercase letters don't follow Java naming conventions:

  • ThenInformationMessagePopUp
  • ThenBuiltInPartitionTableDisplayed
  • ThenCheckRowAdded

126-130: 🛠️ Refactor suggestion

Replace fixed delay with explicit wait condition

Using bot.sleep(5000) can lead to flaky tests. Replace it with an explicit wait condition.

 private static void whenOpenPartitionTableEditor() throws IOException
 {
     ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
-    bot.sleep(5000);
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
+    bot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive("Partition Table Editor"));
 }

Likely invalid or redundant comment.

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 (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1)

Line range hint 273-277: Extract command string as a constant.

The command string "Install New Component" should be extracted as a constant to maintain consistency and ease maintenance.

Consider adding a constant in a suitable location (e.g., IDFConstants or a dedicated UI constants class):

+    public static final String INSTALL_NEW_COMPONENT_COMMAND = "Install New Component";
     // ...
-    ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Install New Component");
+    ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, INSTALL_NEW_COMPONENT_COMMAND);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a879f49 and 1af2875.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_macos
  • GitHub Check: build

@@ -266,11 +265,12 @@ private static void whenProjectIsBuiltUsingContextMenu() throws IOException
{
ProjectTestOperations.buildProjectUsingContextMenu(projectName, bot);
ProjectTestOperations.waitForProjectBuild(bot);
bot.sleep(5000);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace fixed sleep with explicit wait condition.

Using a fixed sleep duration makes the test both slower and less reliable. Instead, use an explicit wait condition that checks for the actual completion of the build operation.

Consider using TestWidgetWaitUtility.waitUntilCondition() or similar mechanism to wait for a specific condition that indicates build completion, such as:

-            bot.sleep(5000);
+            TestWidgetWaitUtility.waitUntilCondition(
+                () -> !bot.activeShell().getText().contains("Building"),
+                "Build operation did not complete in time"
+            );

Committable suggestion skipped: line range outside the PR's diff.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc00b39 and a0202ca.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_macos
  • GitHub Check: build
🔇 Additional comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

273-273: LGTM: Good refactoring to use generic command launcher

The change to use launchCommandUsingContextMenu() instead of a specific method improves code reusability.


340-340: 🛠️ Refactor suggestion

Replace fixed sleep with explicit wait condition

Using a fixed sleep duration makes the test both slower and less reliable. Instead, use an explicit wait condition that checks for the actual completion of the build operation.

-			bot.sleep(5000);
+			TestWidgetWaitUtility.waitUntilCondition(
+				() -> consoleView.bot().styledText().getText().contains("Memory Type"),
+				"Build operation did not complete in time"
+			);

Likely invalid or redundant comment.

Comment on lines 345 to 346
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
assertTrue(consoleTextString.contains("Memory Type"));
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove or update the commented-out assertion

The commented-out assertion suggests incomplete changes. Either remove it completely or update it to reflect the current expected behavior.

-//			assertTrue(consoleTextString.contains("Build complete (0 errors"));
-			assertTrue(consoleTextString.contains("Memory Type"));
+			assertTrue("Build output should contain memory type information", 
+				consoleTextString.contains("Memory Type"));
📝 Committable suggestion

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

Suggested change
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
assertTrue(consoleTextString.contains("Memory Type"));
assertTrue("Build output should contain memory type information",
consoleTextString.contains("Memory Type"));

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

🔭 Outside diff range comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1)

Line range hint 273-277: Add explicit wait conditions for component installation.

The current implementation could be flaky due to timing issues. Consider using explicit wait conditions to make the test more reliable.

 private static void whenInstallNewComponentUsingContextMenu() throws IOException
 {
     ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Install New Component");
+    TestWidgetWaitUtility.waitUntilCondition(
+        () -> bot.editorByTitle(projectName) != null,
+        "Component installation editor did not open"
+    );
     bot.editorByTitle(projectName).show();
+    TestWidgetWaitUtility.waitUntilCondition(
+        () -> bot.button("Install").isEnabled(),
+        "Install button not enabled"
+    );
     bot.button("Install").click();
     ProjectTestOperations.waitForProjectNewComponentInstalled(bot);
     bot.editorByTitle(projectName).close();
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0202ca and 8fb3fb0.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_macos
  • GitHub Check: build

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8fb3fb0 and 37aff0f.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_macos
  • GitHub Check: build
🔇 Additional comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

Line range hint 274-279: LGTM! Improved component installation approach.

The change to use launchCommandUsingContextMenu with "Install New Component" is a more maintainable approach as it uses the command name directly instead of a specific method.


269-269: 🛠️ Refactor suggestion

Remove redundant sleep after build completion.

The sleep is redundant since ProjectTestOperations.waitForProjectBuild(bot) already waits for the build to complete.

-			bot.sleep(5000);

Likely invalid or redundant comment.

Comment on lines 341 to 350
bot.sleep(5000);
SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
consoleView.show();
consoleView.setFocus();
bot.sleep(5000);
String consoleTextString = consoleView.bot().styledText().getText();
assertTrue(consoleTextString.contains("Build complete (0 errors"));
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
bot.sleep(5000);
assertTrue(consoleTextString.contains("Total time"));
bot.sleep(5000);
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Fix build verification logic using proper wait utility.

The current implementation has several issues:

  1. Multiple redundant sleep calls that make the test slower and flaky
  2. Commented out essential build completion check
  3. Using "Total time" as a build completion indicator is less reliable than checking for "Build complete"

Replace with a more robust implementation:

-			bot.sleep(5000);
 			SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
 			consoleView.show();
 			consoleView.setFocus();
-			bot.sleep(5000);
-			String consoleTextString = consoleView.bot().styledText().getText();
-//			assertTrue(consoleTextString.contains("Build complete (0 errors"));
-			bot.sleep(5000);
-			assertTrue(consoleTextString.contains("Total time"));
-			bot.sleep(5000);
+			TestWidgetWaitUtility.waitUntilViewContains(
+				bot,
+				"Build complete (0 errors",
+				consoleView,
+				30000
+			);
🔗 Analysis chain

Fix build verification logic.

The current implementation has several issues:

  1. Multiple redundant sleep calls that make the test slower and flaky
  2. Commented out essential build completion check
  3. Using "Total time" as a build completion indicator is less reliable than checking for "Build complete"

Replace with a more robust implementation:

-			bot.sleep(5000);
 			SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
 			consoleView.show();
 			consoleView.setFocus();
-			bot.sleep(5000);
-			String consoleTextString = consoleView.bot().styledText().getText();
-//			assertTrue(consoleTextString.contains("Build complete (0 errors"));
-			bot.sleep(5000);
-			assertTrue(consoleTextString.contains("Total time"));
-			bot.sleep(5000);
+			TestWidgetWaitUtility.waitUntilCondition(
+				() -> {
+					String consoleText = consoleView.bot().styledText().getText();
+					return consoleText.contains("Build complete (0 errors");
+				},
+				"Build did not complete successfully"
+			);

Let's verify the build completion patterns in the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check build completion patterns in test files and production code
rg -B 2 -A 2 "Build complete.*errors" tests/
rg -B 2 -A 2 "Build complete.*errors" bundles/

Length of output: 3427


Script:

#!/bin/bash
# Check for TestWidgetWaitUtility
rg -l "TestWidgetWaitUtility"

# If found, show its implementation
ast-grep --pattern 'class TestWidgetWaitUtility {
  $$$
}'

Length of output: 1041


Script:

#!/bin/bash
# Show TestWidgetWaitUtility implementation
cat "tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/common/utility/TestWidgetWaitUtility.java"

# Show other usages for reference
rg -B 2 -A 2 "TestWidgetWaitUtility\.waitUntilCondition" tests/

Length of output: 8364

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: 2

♻️ Duplicate comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1)

271-271: 🛠️ Refactor suggestion

Remove redundant sleep after build completion.

The fixed sleep is redundant since ProjectTestOperations.waitForProjectBuild(bot) already handles waiting for build completion. Using fixed sleep durations makes tests both slower and less reliable.

-			bot.sleep(5000);
🧹 Nitpick comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1)

347-376: Improve console output verification robustness.

While the enhanced error logging is good, consider using TestWidgetWaitUtility for more reliable verification:

-			if (consoleTextString.contains("Build complete (0 errors,"))
-			{
-				System.out.println("Expected string found in console output.");
-			}
-			else
-			{
-				System.out.println("Expected string NOT found. Logging relevant console output:");
-				// ... logging code ...
-				fail("Console does not show build successful message");
-			}
+			TestWidgetWaitUtility.waitUntilCondition(
+				() -> {
+					String consoleText = consoleView.bot().styledText().getText();
+					return consoleText.contains("Build complete (0 errors,");
+				},
+				"Build did not complete successfully",
+				() -> {
+					// Current logging code for failure case
+					String text = consoleView.bot().styledText().getText();
+					System.out.println("Build failed. Logging console output...");
+					// ... rest of your logging code ...
+				}
+			);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e1f1f2 and 60dcd1c.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build_macos
🔇 Additional comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1)

9-9: LGTM!

The addition of the fail import is appropriate for the enhanced error handling in the console verification.

Comment on lines 377 to 384
// bot.sleep(10000);
// String consoleTextString = consoleView.bot().styledText().getText();
// assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
// assertTrue("Console does not show build successful message",
// consoleTextString.contains("Build complete (0 errors,"));
// String consoleTextString = consoleView.bot().styledText().getText();
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove commented-out code.

Clean up the commented-out code blocks to improve maintainability. If these represent alternative implementations, they should be removed since we now have a better implementation.

-//			bot.sleep(10000);
-//			String consoleTextString = consoleView.bot().styledText().getText();
-//			assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
-//			assertTrue("Console does not show build successful message",
-//					consoleTextString.contains("Build complete (0 errors,"));
-//			String consoleTextString = consoleView.bot().styledText().getText();
-//			assertTrue(consoleTextString.contains("Build complete (0 errors"));
📝 Committable suggestion

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

Suggested change
// bot.sleep(10000);
// String consoleTextString = consoleView.bot().styledText().getText();
// assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
// assertTrue("Console does not show build successful message",
// consoleTextString.contains("Build complete (0 errors,"));
// String consoleTextString = consoleView.bot().styledText().getText();
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
}
}

Comment on lines 386 to 391
private static void assertConsoleShowsBuildSuccessful()
{
SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
consoleView.show();
consoleView.setFocus();

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove or implement the empty method.

The assertConsoleShowsBuildSuccessful() method appears to be incomplete and unused. Either:

  1. Remove it if it's not needed
  2. Implement it and update callers to use it
  3. Add a TODO comment if it's for future use
-		private static void assertConsoleShowsBuildSuccessful()
-		{
-			SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
-			consoleView.show();
-			consoleView.setFocus();
-
-		}

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 (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

7-9: Remove unused import.

The fail import is not used in any of the changed code.

 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;

Line range hint 276-280: Extract component installation steps into a utility method.

The component installation steps could be encapsulated in a utility method for better reusability and maintainability.

-			ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Install New Component");
-			bot.editorByTitle(projectName).show();
-			bot.button("Install").click();
-			ProjectTestOperations.waitForProjectNewComponentInstalled(bot);
-			bot.editorByTitle(projectName).close();
+			ProjectTestOperations.installNewComponent(projectName, bot);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b28c418 and 9675cec.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_macos
  • GitHub Check: build
🔇 Additional comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

356-361: 🛠️ Refactor suggestion

Remove empty method.

The assertConsoleShowsBuildSuccessful() method is empty and unused. Either implement it or remove it.

-		private static void assertConsoleShowsBuildSuccessful()
-		{
-			SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
-			consoleView.show();
-			consoleView.setFocus();
-
-		}

Likely invalid or redundant comment.


271-271: 🛠️ Refactor suggestion

Replace fixed sleep with explicit wait condition.

Using a fixed sleep duration makes the test both slower and less reliable. Instead, use an explicit wait condition that checks for the actual completion of the build operation.

-			bot.sleep(5000);
+			TestWidgetWaitUtility.waitUntilCondition(
+				() -> ProjectTestOperations.isBuildComplete(bot),
+				"Build operation did not complete in time"
+			);

Likely invalid or redundant comment.

Comment on lines 341 to 354
private static void thenConsoleShowsBuildSuccessful() throws IOException
{
// SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
// consoleView.show();
// consoleView.setFocus();
// bot.sleep(10000);
// String consoleTextString = consoleView.bot().styledText().getText();
// assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
// assertTrue("Console does not show build successful message", consoleTextString.contains("Error:"));
// String consoleTextString = consoleView.bot().styledText().getText();
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
// private static void thenCheckResultInConsole() throws IOException
ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete");
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Clean up commented code and improve build verification.

The current implementation has several issues:

  1. Large block of commented-out code that should be removed
  2. The build verification could be more robust
-		private static void thenConsoleShowsBuildSuccessful() throws IOException
-		{
-//			SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
-//			consoleView.show();
-//			consoleView.setFocus();
-//			bot.sleep(10000);
-//			String consoleTextString = consoleView.bot().styledText().getText();
-//			assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
-//			assertTrue("Console does not show build successful message", consoleTextString.contains("Error:"));
-//			String consoleTextString = consoleView.bot().styledText().getText();
-//			assertTrue(consoleTextString.contains("Build complete (0 errors"));
-//		private static void thenCheckResultInConsole() throws IOException
-			ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete");
-		}
+		private static void thenConsoleShowsBuildSuccessful() throws IOException {
+			SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
+			consoleView.show();
+			consoleView.setFocus();
+			
+			TestWidgetWaitUtility.waitUntilViewContains(
+				bot,
+				"Build complete (0 errors",
+				consoleView,
+				"Build did not complete successfully"
+			);
+		}
📝 Committable suggestion

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

Suggested change
private static void thenConsoleShowsBuildSuccessful() throws IOException
{
// SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
// consoleView.show();
// consoleView.setFocus();
// bot.sleep(10000);
// String consoleTextString = consoleView.bot().styledText().getText();
// assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
// assertTrue("Console does not show build successful message", consoleTextString.contains("Error:"));
// String consoleTextString = consoleView.bot().styledText().getText();
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
// private static void thenCheckResultInConsole() throws IOException
ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete");
}
private static void thenConsoleShowsBuildSuccessful() throws IOException {
SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
consoleView.show();
consoleView.setFocus();
TestWidgetWaitUtility.waitUntilViewContains(
bot,
"Build complete (0 errors",
consoleView,
"Build did not complete successfully"
);
}

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: 2

🧹 Nitpick comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/ProjectSearchConsoleTest.java (1)

69-78: Consider improving test structure and assertions.

While the test methods are well-organized, consider these improvements:

  1. Add intermediate assertions to verify project creation before build
  2. Extract common build verification logic to reduce duplication
  3. Add error scenarios (e.g., build failures) for better coverage

Example refactor for intermediate assertions:

 @Test
 public void givenNewIDFProjectIsCreatedAndBuiltUsingContextMenuOnProjectThenProjectIsCreatedAndBuilt()
         throws Exception
 {
     Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
     Fixture.givenProjectNameIs("NewProjectForContextMenuBuildTest");
     Fixture.whenNewProjectIsSelected();
+    // Verify project creation
+    Fixture.thenProjectHasTheFile("CMakeLists.txt", "/");
+    Fixture.thenProjectHasTheFile("main", "/");
     Fixture.whenProjectIsBuiltUsingContextMenu();
     Fixture.thenConsoleShowsBuildSuccessful();
 }

Also applies to: 80-88, 90-99

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9675cec and d928bee.

📒 Files selected for processing (2)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/ProjectSearchConsoleTest.java (1 hunks)
🔇 Additional comments (3)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

Line range hint 238-242: LGTM! Good refactoring to use a more generic approach.

The change from openProjectNewComponentUsingContextMenu to launchCommandUsingContextMenu is a good improvement as it uses a more generic approach for launching context menu commands.


233-233: ⚠️ Potential issue

Replace fixed sleep with explicit wait condition.

Using a fixed sleep duration makes the test both slower and less reliable. Instead, use an explicit wait condition that checks for the actual completion of the build operation.

-			bot.sleep(5000);
+			TestWidgetWaitUtility.waitUntilCondition(
+				() -> {
+					SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
+					String consoleText = consoleView.bot().styledText().getText();
+					return consoleText.contains("Build complete (0 errors");
+				},
+				"Build operation did not complete in time"
+			);

Likely invalid or redundant comment.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/ProjectSearchConsoleTest.java (1)

1-224: Summary of Review Findings

  1. Major Concern:

    • This file contains project creation and build tests, which seem unrelated to the PR objectives of adding Partition Table Editor tests.
    • Please clarify if this is the correct file for review or provide the actual test files for the Partition Table Editor functionality.
  2. Code Quality Improvements Needed:

    • Replace hard-coded sleeps with proper wait conditions
    • Add intermediate assertions in test methods
    • Clean up commented-out code
    • Improve console verification logic

Let's verify if we're reviewing the correct file:

Comment on lines 189 to 202
private static void thenConsoleShowsBuildSuccessful() throws IOException
{
// SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
// consoleView.show();
// consoleView.setFocus();
// bot.sleep(10000);
// String consoleTextString = consoleView.bot().styledText().getText();
// assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
// assertTrue("Console does not show build successful message", consoleTextString.contains("Error:"));
// String consoleTextString = consoleView.bot().styledText().getText();
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
// private static void thenCheckResultInConsole() throws IOException
ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete");
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Clean up and improve console verification logic.

The thenConsoleShowsBuildSuccessful method needs attention:

  1. Remove commented-out code
  2. Add proper build success/failure verification
  3. Improve error messages for better debugging
 private static void thenConsoleShowsBuildSuccessful() throws IOException
 {
-//    SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
-//    consoleView.show();
-//    consoleView.setFocus();
-//    bot.sleep(10000);
-//    String consoleTextString = consoleView.bot().styledText().getText();
-//    assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
-//    assertTrue("Console does not show build successful message", consoleTextString.contains("Error:"));
-//    String consoleTextString = consoleView.bot().styledText().getText();
-//    assertTrue(consoleTextString.contains("Build complete (0 errors"));
-//  private static void thenCheckResultInConsole() throws IOException
     ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete");
+    // Verify no build errors
+    assertFalse("Build failed with errors",
+        ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Error:"));
+    // Verify build success message
+    assertTrue("Build did not complete successfully",
+        ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete (0 errors"));
 }
📝 Committable suggestion

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

Suggested change
private static void thenConsoleShowsBuildSuccessful() throws IOException
{
// SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
// consoleView.show();
// consoleView.setFocus();
// bot.sleep(10000);
// String consoleTextString = consoleView.bot().styledText().getText();
// assertNotNull("Console text is null, ensure the console is visible and active", consoleTextString);
// assertTrue("Console does not show build successful message", consoleTextString.contains("Error:"));
// String consoleTextString = consoleView.bot().styledText().getText();
// assertTrue(consoleTextString.contains("Build complete (0 errors"));
// private static void thenCheckResultInConsole() throws IOException
ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete");
}
private static void thenConsoleShowsBuildSuccessful() throws IOException
{
ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete");
// Verify no build errors
assertFalse("Build failed with errors",
ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Error:"));
// Verify build success message
assertTrue("Build did not complete successfully",
ProjectTestOperations.findInConsole(bot, "CDT Build Console", "Build complete (0 errors"));
}

Comment on lines 152 to 157
private static void whenProjectIsBuiltUsingContextMenu() throws IOException
{
ProjectTestOperations.buildProjectUsingContextMenu(projectName, bot);
ProjectTestOperations.waitForProjectBuild(bot);
bot.sleep(5000);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace hard-coded sleep with proper wait conditions.

The sleep(5000) in whenProjectIsBuiltUsingContextMenu could make tests flaky. Consider using TestWidgetWaitUtility with proper conditions instead.

 private static void whenProjectIsBuiltUsingContextMenu() throws IOException
 {
     ProjectTestOperations.buildProjectUsingContextMenu(projectName, bot);
     ProjectTestOperations.waitForProjectBuild(bot);
-    bot.sleep(5000);
+    TestWidgetWaitUtility.waitForCondition(bot, 
+        () -> ProjectTestOperations.isBuildComplete(bot),
+        "Build did not complete in time");
 }

Committable suggestion skipped: line range outside the PR's diff.

@AndriiFilippov AndriiFilippov force-pushed the IEP-1270 branch 5 times, most recently from 8b81c39 to e7d402f Compare January 14, 2025 17:12
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b81c39 and b390b4f.

📒 Files selected for processing (6)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (5 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (3 hunks)
  • tests/pom.xml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionEditorTest.java
  • tests/pom.xml
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (5)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (5)

27-27: LGTM!

The new imports are correctly added and are used by the new methods.

Also applies to: 30-30


584-591: 🛠️ Refactor suggestion

Add error handling for widget not found scenarios.

The method should handle cases where the shell or label widgets are not found.

 public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
 {
+    try {
         SWTBotShell shell = bot.shell(shellName);
         shell.activate();
         SWTBotLabel label = bot.label(expectedText);
         String actualText = label.getText();
         return expectedText.equals(actualText);
+    } catch (WidgetNotFoundException e) {
+        logger.debug("Shell or label not found", e);
+        return false;
+    }
 }

Likely invalid or redundant comment.


629-635: 🛠️ Refactor suggestion

Add validation before deleting partition table row.

The method should validate that there are enough rows before attempting to delete.

 public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
 {
     SWTBotTable table = bot.table();
+    if (table.rowCount() <= 1) {
+        throw new IllegalStateException("Cannot delete row: Table must have at least 2 rows");
+    }
     table.select(1);
     bot.toolbarButton("Delete Selected").click();
     bot.button("OK").click();
 }

Likely invalid or redundant comment.


593-619: ⚠️ Potential issue

Fix logical operator and optimize loop order in partition table content check.

The method has two issues:

  1. The condition uses && instead of || which could lead to false negatives
  2. The loop order is column-first instead of row-first, making it less efficient
 public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
 {
     String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
             "0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
     int builtInIndex = 0;
     SWTBotTable table = bot.table();
     int columns = table.columnCount();
     int rows = table.rowCount();
-    if (columns != 6 && rows != 3)
+    if (columns != 6 || rows != 3)
     {
         return false;
     }
-    for (int col = 0; col < columns; col++)
+    for (int row = 0; row < rows; row++)
     {
-        for (int row = 0; row < rows; row++)
+        for (int col = 0; col < columns; col++)
         {
             String tableContent = table.cell(row, col);
             if (!builtInPartitionArray[builtInIndex].equals(tableContent))
             {
                 return false;
             }
             builtInIndex++;
         }
     }
     return true;
 }

Likely invalid or redundant comment.


88-88: Verify build timeout reduction impact.

The build timeout has been reduced from 600,000ms to 300,000ms. This significant reduction could potentially cause test failures on slower systems or during complex builds.

✅ Verification successful

Timeout reduction is safe - uses configurable property

The 300000ms is only a fallback value. The actual timeout is configured in the properties files (90800000ms, ~25 hours) and will be used by DefaultPropertyFetcher before falling back to this default value.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if there are any build timeout related failures in the test logs
# Look for patterns indicating build timeouts or related issues

rg -i "timeout|build.*fail|fail.*build" --glob "*.log"

Length of output: 205


Script:

#!/bin/bash
# Search for DEFAULT_PROJECT_BUILD_WAIT_PROPERTY usage and similar timeout configurations
ast-grep --pattern 'DEFAULT_PROJECT_BUILD_WAIT_PROPERTY'

# Search for timeout-related configurations and comments
rg -i "build.*wait|wait.*build|timeout.*build|build.*timeout" --type java

# Look for documentation about build timeouts
rg -i "build.*timeout|timeout.*build|build.*wait" --type md

Length of output: 3936

Comment on lines 89 to 91
// consoleView.close();
// bot.cTabItem("README.md").activate();
// bot.cTabItem("README.md").close();
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove commented code.

Instead of keeping commented code, it should be removed. If the code is needed for reference, it should be tracked in version control history.

-//		consoleView.close();
-//		bot.cTabItem("README.md").activate();
-//		bot.cTabItem("README.md").close();

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/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

36-40: Add consistent error handling in setup method.

While the afterEachTest method has proper error handling, the beforeTestClass method should follow the same pattern for consistency.

 @BeforeClass
 public static void beforeTestClass() throws Exception
 {
-    Fixture.loadEnv();
+    try {
+        Fixture.loadEnv();
+    } catch (Exception e) {
+        System.err.println("Error during environment setup: " + e.getMessage());
+        throw e; // Rethrow as setup failure is critical
+    }
 }

55-87: Enhance test coverage with additional assertions.

While the current tests verify basic functionality, consider adding more comprehensive assertions:

  1. For givenNewProjectCreatedNotBuiltWhenOpenPartitionTableEditorThenInformationPopUpMessage:

    • Verify that the Partition Table Editor didn't open
    • Verify the dialog button states
  2. For givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorThenBuiltInPartitionTableDisplayed:

    • Verify the number of initial rows
    • Verify the column headers
    • Verify the default values in cells
  3. For givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenAddRowThenCheckRowAdded:

    • Verify the values in the newly added row
    • Verify that the "Add Row" button state changes appropriately

126-130: Add timeout parameter to configuration.

The hardcoded timeout value of 10000ms should be moved to a configuration constant for better maintainability.

+private static final int PARTITION_EDITOR_DIALOG_TIMEOUT_MS = 10000;

 private static void whenOpenPartitionTableEditor() throws IOException
 {
     ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
-    TestWidgetWaitUtility.waitUntilDialogIsNotVisible(bot, "Partition Table Editor", 10000);
+    TestWidgetWaitUtility.waitUntilDialogIsNotVisible(bot, "Partition Table Editor", 
+        PARTITION_EDITOR_DIALOG_TIMEOUT_MS);
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1073a46 and ab5e105.

📒 Files selected for processing (2)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

25-30: Update JavaDoc to reflect the correct purpose of the test class.

The JavaDoc comment incorrectly states this is a test class for the "SBOM feature", but the class actually tests the Partition Table Editor functionality.

 /**
- * Test class to test the SBOM feature
+ * Test class to validate the Partition Table Editor functionality
  * 
  * @author Andrii Filippov
  *
  */

132-151: Follow Java naming conventions for method names.

Method names starting with uppercase letters don't follow Java naming conventions.

-private static void ThenInformationMessagePopUp()
+private static void thenInformationMessagePopUp()

-private static void ThenBuiltInPartitionTableDisplayed()
+private static void thenBuiltInPartitionTableDisplayed()

-private static void ThenCheckRowAdded()
+private static void thenCheckRowAdded()

96-101: Replace fixed delay with explicit wait condition.

Using fixed delays can lead to flaky tests.

 private static void loadEnv() throws Exception
 {
     bot = WorkBenchSWTBot.getBot();
     EnvSetupOperations.setupEspressifEnv(bot);
-    bot.sleep(1000);
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }

Comment on lines +143 to +194
private static void whenAddRowToPartitionTable() throws IOException
{
bot.toolbarButton("Add Row").click();
}

private static void ThenCheckRowAdded() throws IOException
{
assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add retry mechanism for UI interactions.

UI interactions like clicking buttons and checking table contents can be flaky. Consider adding a retry mechanism with appropriate waits.

 private static void whenAddRowToPartitionTable() throws IOException
 {
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
     bot.toolbarButton("Add Row").click();
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }

 private static void ThenCheckRowAdded() throws IOException
 {
+    // Retry up to 3 times with a short delay
+    for (int i = 0; i < 3; i++) {
+        if (ProjectTestOperations.comparePartitionTableRows(bot, 1)) {
+            return;
+        }
+        TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
+    }
     assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
 }
📝 Committable suggestion

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

Suggested change
private static void whenAddRowToPartitionTable() throws IOException
{
bot.toolbarButton("Add Row").click();
}
private static void ThenCheckRowAdded() throws IOException
{
assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
}
private static void whenAddRowToPartitionTable() throws IOException
{
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
bot.toolbarButton("Add Row").click();
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
}
private static void ThenCheckRowAdded() throws IOException
{
// Retry up to 3 times with a short delay
for (int i = 0; i < 3; i++) {
if (ProjectTestOperations.comparePartitionTableRows(bot, 1)) {
return;
}
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
}
assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
}

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: 2

🧹 Nitpick comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1)

55-64: Enhance test coverage and readability.

While the test methods follow a good Given-When-Then pattern, consider these improvements:

  1. Add negative test cases (e.g., invalid partition table entries)
  2. Break down long method names into more manageable ones
  3. Add error case verifications

Example refactoring for better readability:

-    public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenDeleteSelectedRowWhenSaveAndQuitwhenReopenPartitionTableThenCheckChangesSaved()
+    public void shouldPersistDeletedRowAfterSaveAndReopen()

Also, consider adding these test cases:

  1. Attempt to add invalid partition entries
  2. Verify error messages for invalid inputs
  3. Test concurrent modifications

Would you like me to help create these additional test cases?

Also applies to: 66-76, 78-88, 90-101, 103-116, 118-132

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab5e105 and f7af99e.

📒 Files selected for processing (3)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_macos
  • GitHub Check: build
🔇 Additional comments (8)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (6)

109-110: LGTM! Improved regex pattern safety.

Good improvement using Pattern.quote to handle special characters in console type names.


586-593: Handle potential exceptions in shell content verification.

The method needs exception handling for cases where the shell or label is not found.


595-621: Correct the condition and loop order.

The method has issues with the logical operator in the table dimension check and inefficient loop order.


623-629: Fix the incorrect logic.

The comparison logic needs to be corrected to properly validate the row count difference.


631-637: Add validation before row deletion.

The method needs validation to ensure there are enough rows before attempting deletion.


89-92: Verify the reduced build timeout and add error handling.

  1. The build timeout has been reduced from 600,000ms to 300,000ms. Please verify this doesn't impact stability on slower systems.
  2. The README.md tab operations should handle cases where the tab doesn't exist.
- consoleView.close();
- bot.cTabItem("README.md").activate();
- bot.cTabItem("README.md").close();
+ consoleView.close();
+ try {
+     SWTBotCTabItem readmeTab = bot.cTabItem("README.md");
+     readmeTab.activate();
+     readmeTab.close();
+ } catch (WidgetNotFoundException e) {
+     logger.debug("README.md tab not found", e);
+ }
✅ Verification successful

Build timeout reduction is safe, but tab operations need error handling

The build timeout is configurable through the default.project.build.wait property, allowing it to be adjusted for slower systems if needed. However, the README.md tab operations should still implement error handling as suggested in the original review.

- consoleView.close();
- bot.cTabItem("README.md").activate();
- bot.cTabItem("README.md").close();
+ consoleView.close();
+ try {
+     SWTBotCTabItem readmeTab = bot.cTabItem("README.md");
+     readmeTab.activate();
+     readmeTab.close();
+ } catch (WidgetNotFoundException e) {
+     logger.debug("README.md tab not found", e);
+ }
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for build timeout property usage
rg "DEFAULT_PROJECT_BUILD_WAIT_PROPERTY" -B 2 -A 2

# Search for similar tab operations in test files
rg "cTabItem.*README.md" -B 2 -A 2

# Search for error handling patterns in tab operations
ast-grep --pattern 'try {
  $$$
  bot.cTabItem($$$)
  $$$
} catch ($$$) {
  $$$
}'

Length of output: 2433

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (2)

141-146: 🛠️ Refactor suggestion

Improve environment loading reliability.

The loadEnv method has two issues:

  1. Uses a fixed delay with bot.sleep(1000) which can lead to flaky tests
  2. Lacks exception handling for setupEspressifEnv

Apply this diff:

 private static void loadEnv() throws Exception
 {
-    bot = WorkBenchSWTBot.getBot();
-    EnvSetupOperations.setupEspressifEnv(bot);
-    bot.sleep(1000);
+    try {
+        bot = WorkBenchSWTBot.getBot();
+        EnvSetupOperations.setupEspressifEnv(bot);
+        TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
+    } catch (Exception e) {
+        System.err.println("Error during environment setup: " + e.getMessage());
+        throw e;
+    }
 }

Likely invalid or redundant comment.


214-218: 🛠️ Refactor suggestion

Add verification after UI actions.

The save, quit, and cancel operations need verification to ensure the actions completed successfully.

Apply this improvement:

 private static void whenSaveAndQuit() throws IOException
 {
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
     bot.button("Save and Quit").click();
+    TestWidgetWaitUtility.waitUntilDialogIsVisible(bot, "OK", 5000);
     bot.button("OK").click();
+    TestWidgetWaitUtility.waitUntilDialogIsNotVisible(bot, "OK", 5000);
 }

Let's verify if these dialogs are consistently present:

Also applies to: 220-224, 226-229

✅ Verification successful

The review suggestion is valid and should be implemented.

The suggested wait operations using TestWidgetWaitUtility are necessary to ensure UI test stability and are consistent with existing usage patterns in the codebase. The class provides the required methods and is already used in other parts of the same test class.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for dialog definitions in the codebase
rg -A 5 "Save and Quit|OK|Cancel" --type java

Length of output: 65878


Script:

#!/bin/bash
# Search for TestWidgetWaitUtility class definition and usages
rg -A 10 "class TestWidgetWaitUtility" --type java

Length of output: 1624


Script:

#!/bin/bash
# Search for all methods in TestWidgetWaitUtility and their usages
rg -l "TestWidgetWaitUtility" --type java | xargs rg "TestWidgetWaitUtility\." -A 2

Length of output: 11073

Comment on lines +32 to +33
@RunWith(SWTBotJunit4ClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider removing test dependencies.

The use of @FixMethodOrder(MethodSorters.NAME_ASCENDING) suggests that tests are dependent on execution order. This is an anti-pattern in unit testing as it makes tests brittle and harder to maintain.

Consider:

  1. Making each test independent by setting up its own test state
  2. Using appropriate @Before methods for common setup
  3. Removing the @FixMethodOrder annotation once tests are independent

Comment on lines +171 to +175
private static void whenOpenPartitionTableEditor() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
TestWidgetWaitUtility.waitUntilDialogIsNotVisible(bot, "Partition Table Editor", 10000);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add proper wait conditions for UI interactions.

UI operations like opening editors and clicking buttons need proper wait conditions to prevent flaky tests.

Apply these improvements:

 private static void whenOpenPartitionTableEditor() throws IOException
 {
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
     ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
     TestWidgetWaitUtility.waitUntilDialogIsNotVisible(bot, "Partition Table Editor", 10000);
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }

 private static void whenAddRowToPartitionTable() throws IOException
 {
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
     bot.toolbarButton("Add Row").click();
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }

Also applies to: 194-197

@AndriiFilippov
Copy link
Collaborator Author

@alirana01 @kolipakakondal hi !

builds are fixed on Linux runner.

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

Successfully merging this pull request may close these issues.

3 participants