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: 'ESP-IDF Install New Component' test case #833

Merged
merged 1 commit into from
Oct 19, 2023
Merged

Conversation

AndriiFilippov
Copy link
Collaborator

@AndriiFilippov AndriiFilippov commented Oct 16, 2023

Description

Added 'ESP-IDF Install New Component' test case.
Test case install New Component (mdns) - checks the console for the presence of the correct message - checks the idf_component.yml file for the presence of component record (espressif/mdns)

Fixes # (IEP-XXX)

Type of change

  • New SWT Bot test case

Test Configuration:

  • ESP-IDF Version: v5.1.1
  • OS (Windows,Linux and macOS): Windows 10

Checklist

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

Summary by CodeRabbit

  • New Feature: Enhanced testing capabilities for the Espressif IDF project. This includes the ability to simulate the creation of a new project, build the project, install a new component, and verify the installation.
  • Improvement: Added several helper methods to streamline project operations. These include waiting for a project build, refreshing a project, opening and checking the content of a project's component file, and opening a new component.

These updates aim to improve the reliability of the software by enhancing testing capabilities and making project operations more efficient.

@coderabbitai
Copy link

coderabbitai bot commented Oct 16, 2023

Walkthrough

The changes introduce a new test case for the Espressif IDF project, enhancing the testing suite by simulating project creation, build, and component installation. The updates also improve the ProjectTestOperations class, adding methods for project build waiting, component installation, project refreshing, and component YAML file interaction.

Changes

File Path Summary
.../NewEspressifIDFProjectTest.java Added a new test case givenNewProjectCreatedThenInstallNewComponent(), simulating project creation, build, and component installation.
.../ProjectTestOperations.java Enhanced functionality with methods for project build waiting, component installation, project refreshing, and component YAML file interaction.

🐇
"In the land of code, where the shadows lie,
A rabbit hops, its gaze held high.
With each new test, it leaps and bounds,
In the realm of bugs, it astounds.
Through the maze of logic, it finds its way,
Celebrating each successful play.
So here's to changes, big and small,
To the rabbit coder, who conquers all!" 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review 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.

Review Status

Actionable comments generated: 3

Commits Files that changed from the base of the PR and between 0267c08 and ff55c58.
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/operations/ProjectTestOperations.java (3 hunks)
Additional comments (Suppressed): 6
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (6)
  • 61-74: The new method waitForProjectNewComponentInstalled is introduced to wait until the console view contains the message "Successfully added dependency", indicating that a new component has been installed successfully. This method is similar to waitForProjectBuild but waits for a different message. The timeout value for waiting is set to 10,000 milliseconds (10 seconds). Please verify if this timeout value is sufficient for the component installation process.

  • 103-110: The new method refreshProjectUsingContextMenu is introduced to refresh a project using the context menu. This method can be useful in scenarios where the project needs to be refreshed to reflect the latest changes, such as after a new component has been installed.

  • 113-141: The new method openProjectComponentYMLFileInTextEditorUsingContextMenu is introduced to open the idf_component.yml file of a project in a text editor using the context menu. This method can be useful in scenarios where the content of the idf_component.yml file needs to be checked or modified. The method tries to find the idf_component.yml file in the 'main' subfolder of the project and throws a RuntimeException if the file is not found after a certain number of attempts.

  • 143-154: The new helper method findTreeItem is introduced to find a tree item with a specific name under a given parent item. This method can be useful in scenarios where a specific item needs to be found in the project explorer.

  • 156-163: The new method checkTextEditorContentForPhrase is introduced to check if the content of the active text editor contains a specific phrase. This method can be useful in scenarios where the content of a text file needs to be checked for a specific phrase, such as after a new component has been installed. The method throws a RuntimeException if the specified phrase is not found in the text editor.

  • 165-173: The new method openProjectNewComponentUsingContextMenu is introduced to open the "Install New Component" option of a project using the context menu. This method can be useful in scenarios where a new component needs to be installed in a project.

Comment on lines +299 to +307
private static void whenInstallNewComponentUsingContextMenu() throws IOException
{
ProjectTestOperations.openProjectNewComponentUsingContextMenu(projectName, bot);
bot.editorByTitle(projectName).show();
bot.button("Install").click();
ProjectTestOperations.waitForProjectNewComponentInstalled(bot);
bot.editorByTitle(projectName).close();
ProjectTestOperations.refreshProjectUsingContextMenu(projectName, bot);
}
Copy link

Choose a reason for hiding this comment

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

The method whenInstallNewComponentUsingContextMenu() installs a new component and refreshes the project. However, it doesn't handle any potential exceptions that might occur during the installation or the refresh. Consider adding error handling to make the code more robust.

  private static void whenInstallNewComponentUsingContextMenu() throws IOException
  {
    try {
      ProjectTestOperations.openProjectNewComponentUsingContextMenu(projectName, bot);
      bot.editorByTitle(projectName).show();
      bot.button("Install").click();
      ProjectTestOperations.waitForProjectNewComponentInstalled(bot);
      bot.editorByTitle(projectName).close();
      ProjectTestOperations.refreshProjectUsingContextMenu(projectName, bot);
    } catch (Exception e) {
      e.printStackTrace();
      fail("Failed to install new component using context menu: " + e.getMessage());
    }
  }

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.

LGTM!
@AndriiFilippov I would suggest you to please wait for any more tests along the idf components area as that will probably be revamped in the near future and may require you to write new tests again or update the old ones drastically

Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

LGTM

@AndriiFilippov AndriiFilippov merged commit f3598d0 into master Oct 19, 2023
@AndriiFilippov AndriiFilippov deleted the IEP-1038 branch October 19, 2023 11:51
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