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

Ability to configure default browser (OSOE-733) #324

Closed
Piedone opened this issue Nov 17, 2023 · 1 comment · Fixed by #326
Closed

Ability to configure default browser (OSOE-733) #324

Piedone opened this issue Nov 17, 2023 · 1 comment · Fixed by #326
Assignees
Labels
enhancement New feature or request

Comments

@Piedone
Copy link
Member

Piedone commented Nov 17, 2023

All of our tests have something like [Theory, Chrome] on them. It's extremely rare that we use some other browser than Chrome, and it's practically non-existent that we'd test multiple browsers in the same test suite. So, instead of repeating the same Chrome attribute on all tests, and then pass it to ExecuteTestAfterSetupAsync() or some other method, let's add the ability to configure a default value for it.

  • Set BrowserConfiguration.Browser to Chrome by default.
  • Add overloads in OrchardCoreUITestBase<TEntryPoint> that don't accept a browser.
  • Remove Chrome from all tests but a single sample (use an existing one for it), where we demonstrate it being used and passed on as today.

Jira issue

@Piedone Piedone added the enhancement New feature or request label Nov 17, 2023
@github-actions github-actions bot changed the title Ability to configure default browser Ability to configure default browser (OSOE-733) Nov 17, 2023
@Piedone
Copy link
Member Author

Piedone commented Nov 27, 2023

The UI Testing Toolbox now offers a default for the browser being used. Since in all but a single test in the history of Lombiq this was Chrome, that's now the default. The endless [Theory, Chrome] attributes and passing the browser down the call chain are now while still supported, unnecessary, unless you want to use a different or multiple browsers.

Everything should keep on working, but it's still nicer to remove the now unnecessary code. So, in all projects, please do this:

  1. Update to the latest UI Testing Toolbox. Then code cleanup time! Warning: UITestBase classes should usually remain so check and revert them if they change after the below steps!
  2. Do a Find and Replace in the UI test projects with the following will cover most cases: [Theory, Chrome][Fact], (Browser browser) =>() =>, , browser););.
  3. Run the following with "Use regular expressions" checked: ,\r\n.*browser\););, ,\r\n.*browser,,.
  4. Do a Find and Replace of (Browser browser)().
  5. Do a reference lookup for Browser.Chrome (Shift+F12) to find any missed cases.
  6. Finally, you'll need to check the formatting of all tests, because e.g. you may be able to make methods a lot more compact with fewer line breaks. All tests will have now unused references too, but if you have cleanup on save configured in VS, then just saving them will get rid of that.

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

Successfully merging a pull request may close this issue.

1 participant