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

[v3] fix tests after plugins and event refactor #3746

Conversation

stendler
Copy link

@stendler stendler commented Sep 14, 2024

Description

Fix most of the tests failing since the recent refactorings for the plugin and event systems, as well as some other issues regarding method signatures and logging calls (https://github.com/wailsapp/wails/actions/runs/10837644078).

(Skipping the failing mac tests introduced in 6787ce9 as I don't have a mac, but the role UseSelectionForFind declared for darwin is not defined in roles.go)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

In CI: https://github.com/stendler/wails/actions/runs/10863138422

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

Release Notes

  • New Features

    • Streamlined event handling mechanism for "clicked", "button-pressed", and "hover" events.
    • Enhanced flexibility in service initialization with additional service options.
  • Improvements

    • Simplified error logging during service startup for better consistency.
    • Improved readability and maintainability of event emission logic.
    • Enhanced clarity of plugin lifecycle methods and context-aware initialization.
  • Bug Fixes

    • Resolved issues related to menu item management and event processing on macOS.
    • Fixed a system tray startup panic on Windows for smoother operation.

Copy link
Contributor

coderabbitai bot commented Sep 14, 2024

Walkthrough

The changes in this pull request primarily focus on updating the event handling mechanism across multiple files, transitioning from the app.customEventProcessor.On method to the more standardized app.OnEvent method. Additionally, modifications include improvements in error logging practices, function signatures to enhance flexibility, and the introduction of build constraints for platform-specific code. Overall, the updates aim to streamline event handling, improve code readability, and enhance logging robustness.

Changes

File Change Summary
v3/examples/plain/main.go Changed event listener registration from app.customEventProcessor.On to app.OnEvent for the "clicked" event.
v3/examples/wml/main.go Updated event listener registration from app.customEventProcessor.On to app.OnEvent for "button-pressed" and "hover" events.
v3/internal/assetserver/assetserver_webview.go Modified error logging to use fmt.Sprintf for better formatting when URL retrieval fails.
v3/internal/generator/testcases/complex_instantiations/funcs.go Added a variadic parameter of type application.ServiceOptions to ServiceInitialiser function.
v3/internal/generator/testcases/complex_instantiations/other/funcs.go Similar modification to ServiceInitialiser to accept variadic application.ServiceOptions.
v3/internal/signal/signal.go Updated logging statements in Start method to use fmt.Sprintf for string formatting.
v3/internal/templates/_common/main.go.tmpl Simplified event emission logic by directly calling app.EmitEvent instead of creating an application.WailsEvent struct.
v3/pkg/application/application.go Changed error logging during service startup from globalApplication.error to globalApplication.Logger.Error.
v3/pkg/w32/actions.go Added build constraint //go:build windows to specify Windows-only compilation.
v3/plugins/experimental/oauth/plugin.go Transitioned from Init to OnStartup method, accepting context and service options; updated event handling to use application.CustomEvent.
v3/plugins/experimental/single_instance/plugin.go Renamed Shutdown to OnShutdown, and Init to OnStartup, with new parameters for context and service options.
v3/plugins/experimental/start_at_login/plugin.go Similar renaming of Shutdown to OnShutdown and Init to OnStartup, with updated method signatures for clarity.

Possibly related PRs

  • Ignore internal service methods when binding #3720: This PR involves changes to the event handling mechanism, specifically updating the method for registering event listeners, which is directly related to the changes made in the main PR regarding the event handling in main.go.
  • [linux] fix: update for new events syntax #3734: This PR also modifies the event handling mechanism by updating deprecated methods to the new event handling syntax, which aligns with the changes in the main PR that reflect a shift in how events are processed.

🐇 In the code we hop and play,
New methods guide us on our way.
Events now dance with clearer grace,
As logs and options find their place.
With every change, we leap and cheer,
A brighter path is now so near! 🌟

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6e9b8e9 and 5e22d3b.

Files selected for processing (1)
  • mkdocs-website/docs/en/changelog.md (1 hunks)
Additional comments not posted (1)
mkdocs-website/docs/en/changelog.md (1)

38-38: LGTM!

The changelog entry is well-formatted and provides a clear description of the fix. The categorization under the Fixed section is appropriate, and the reference to the pull request and contributor is helpful.


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

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@leaanthony
Copy link
Member

Thanks for taking the time to do this🙏 The v3 branch is considered unstable at the moment so it can sometimes be broken.

Please could you add an entry to the changelog located at mkdocs-website/docs/changelog.md? Thanks!

Copy link

sonarcloud bot commented Sep 14, 2024

@stendler
Copy link
Author

@leaanthony yeah, no worries - I expect it to be broken sometimes. The tests and CI are great to find easy targets to contribute a fix - especially if I try to keep the CI in my fork green anyway. :)
Also wasn't sure if fixing tests warrants an entry in the changelog - it's fixing something that was not even released yet. But having my contributions recognized in there is much appreciated!

@leaanthony
Copy link
Member

leaanthony commented Sep 17, 2024

Not quite sure why github isn't picking up that this is merged on v3-alpha but it is 👍

@leaanthony leaanthony closed this Sep 17, 2024
@stendler
Copy link
Author

stendler commented Sep 19, 2024

I don't know how GitHub detects squashed merges, but maybe the squashed commit is differing too much (contents due to resolved conflicts, author, message..).
In any way: thanks for merging!

@leaanthony
Copy link
Member

Thanks for being part of the community!

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.

2 participants