Skip to content

Use QueryContentLocale for locale detection in tests - #4610

Merged
Jack251970 merged 3 commits into
devfrom
fix_locale_explorer_test
Aug 7, 2026
Merged

Use QueryContentLocale for locale detection in tests#4610
Jack251970 merged 3 commits into
devfrom
fix_locale_explorer_test

Conversation

@Jack251970

@Jack251970 Jack251970 commented Aug 7, 2026

Copy link
Copy Markdown
Member

Replaced QueryKeywordLocale with QueryContentLocale to ensure tests adapt to the system's content locale, improving reliability across environments. Clarified a comment for better readability.

Under my system with Chinese locale, I happened to find that explorer test failed. So this a quick fix for that.

image
GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryShouldUseExpectedString("flow.launcher.sln","SELECT TOP 100 \"System.FileName\", \"System.ItemUrl\", \"System.ItemType\" FROM \"SystemIndex\" WHERE (System.FileName LIKE 'flow.launcher.sln%' OR CONTAINS(System.FileName,'\"flow.launcher.sln*\"',1033)) AND scope='file:' ORDER BY System.Search.Rank DESC")
   Source: ExplorerTest.cs line 92
   Duration: 55 ms

  Message: 
  Assert.That(actual, Is.EqualTo(expected))
  String lengths are both 246. Strings differ at index 192.
  Expected: "...*"',2057)) AND scope='file:' ORDER BY System.Search.Rank DESC"
  But was:  "...*"',2052)) AND scope='file:' ORDER BY System.Search.Rank DESC"
  ---------------------^


  Stack Trace: 
ClassicAssert.AreEqual(Object expected, Object actual)
ExplorerTest.GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryShouldUseExpectedString(String userSearchString, String expectedString) line 107
1)    at NUnit.Framework.Legacy.ClassicAssert.AreEqual(Object expected, Object actual)
ExplorerTest.GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryShouldUseExpectedString(String userSearchString, String expectedString) line 107

Summary by cubic

Switch Explorer tests to use QueryContentLocale with invariant formatting so LCID assertions match the system content locale across machines.

Summary of changes

  • Changed: In Explorer tests, replaced QueryKeywordLocale with QueryContentLocale for LCID substitution; used ToString(CultureInfo.InvariantCulture); minor comment/format tweaks.
  • Added: Tests adapt to the query builder’s content locale and use culture-invariant digits for LCID values.
  • Removed: Dependence on keyword locale and the implicit en-US (1033) assumption in assertions.
  • Memory impact: None.
  • Security risks: None.
  • Unit tests: Updated the existing Explorer test; no new tests added.

Release Note
No user-facing changes; improves test reliability on non‑en‑US systems.

Written for commit 45d9cf8. Summary will update on new commits.

Review in cubic

Replaced QueryKeywordLocale with QueryContentLocale to ensure tests adapt to the system's content locale, improving reliability across environments. Clarified a comment for better readability.
Copilot AI lite review requested due to automatic review settings August 7, 2026 09:21
@github-actions github-actions Bot added this to the 2.2.0 milestone Aug 7, 2026
@Jack251970
Jack251970 enabled auto-merge August 7, 2026 09:21
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Windows Search query test now uses QueryContentLocale and invariant-culture formatting to normalize the expected locale identifier.

Changes

Explorer locale test

Layer / File(s) Summary
Update query locale normalization
Flow.Launcher.Test/Plugins/ExplorerTest.cs
The test derives the expected locale from QueryContentLocale and formats it with invariant culture before the assertion.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main test change: using QueryContentLocale for locale detection.
Description check ✅ Passed The description explains the locale-related test failure and the changes that improve reliability across environments.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix_locale_explorer_test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the Windows Index search unit test to derive the expected CONTAINS(..., LCID) locale from the system at runtime, avoiding hard-coded assumptions that can break on non–en-US environments.

Changes:

  • Switches locale substitution in ExplorerTest from QueryKeywordLocale to QueryContentLocale to match how the generated SQL uses LCIDs.
  • Clarifies/standardizes a test comment (// When).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Flow.Launcher.Test/Plugins/ExplorerTest.cs Outdated
Jack251970 and others added 2 commits August 7, 2026 17:24
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Jack251970
Jack251970 disabled auto-merge August 7, 2026 09:24
@Jack251970
Jack251970 enabled auto-merge (squash) August 7, 2026 09:25
@Jack251970 Jack251970 added CI/CD bug Something isn't working labels Aug 7, 2026
@Jack251970
Jack251970 requested review from DavidGBrett and jjw24 August 7, 2026 09:26

@DavidGBrett DavidGBrett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Thanks for the fix

@Jack251970
Jack251970 merged commit 65e5834 into dev Aug 7, 2026
4 checks passed
@Jack251970
Jack251970 deleted the fix_locale_explorer_test branch August 7, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants