From da49c7f2e25e9db3c5590d0d1985506ad3cdb7b2 Mon Sep 17 00:00:00 2001 From: cesnimda Date: Fri, 20 Nov 2026 08:55:57 +0100 Subject: [PATCH] test(discovery): preserve legacy saved searches across temporary queries --- .../SavedJobSearchSqliteTests.cs | 50 +++++++++++++++++++ .../00/GEOGRAPHY_MULTI_COUNTRY_QA.md | 20 ++++++++ 2 files changed, 70 insertions(+) diff --git a/JobTrackerApi.Tests/SavedJobSearchSqliteTests.cs b/JobTrackerApi.Tests/SavedJobSearchSqliteTests.cs index 98edbe07..506338f4 100644 --- a/JobTrackerApi.Tests/SavedJobSearchSqliteTests.cs +++ b/JobTrackerApi.Tests/SavedJobSearchSqliteTests.cs @@ -149,6 +149,56 @@ public sealed class SavedJobSearchSqliteTests(ITestOutputHelper output) fixture.Discovery.VerifyNoOtherCalls(); } + [Theory] + [InlineData("Soins de proximité", "aide-soignant·e", "Orle\u0301ans / Orléans, Centre-Val de Loire")] + [InlineData("Opieka bez lokalizacji", "pielęgniarka", "")] + public async Task Temporary_search_keeps_legacy_filters_and_dismissal_history(string name, string query, string location) + { + await using var fixture = await SqliteFixture.CreateAsync(); + var firstSeen = new DateTimeOffset(2025, 3, 3, 8, 0, 0, TimeSpan.Zero); + var previousRun = firstSeen.AddDays(1); + var legacy = new SavedJobSearch + { + OwnerUserId = "owner-1", Name = name, Query = query, Location = location, + CreatedAtUtc = firstSeen, UpdatedAtUtc = previousRun, LastRunAtUtc = previousRun, + Results = [new SavedJobSearchResult + { + ExternalJobId = "historical-nav-id", FirstSeenAtUtc = firstSeen, + LastSeenAtUtc = previousRun, IsDismissed = true + }] + }; + fixture.Db.SavedJobSearches.Add(legacy); + await fixture.Db.SaveChangesAsync(); + fixture.Db.ChangeTracker.Clear(); + fixture.Discovery.Setup(x => x.SearchAsync("lærer", "Tønsberg", It.IsAny())) + .ReturnsAsync(Array.Empty()); + fixture.Discovery.Setup(x => x.SearchAsync(query, location, It.IsAny())) + .ReturnsAsync(new[] { Job("historical-nav-id") }); + + Assert.IsType((await fixture.Controller.Search("lærer", "Tønsberg", default)).Result); + var original = Assert.Single(await List(fixture.Controller)); + Assert.Equal(new JobDiscoveryController.SavedSearchDto(legacy.Id, name, query, location, true, previousRun, 1, 1), original); + + var run = Assert.IsType(Assert.IsType( + (await fixture.Controller.RunSavedSearch(legacy.Id, default)).Result).Value); + var seen = Assert.Single(run.Jobs); + Assert.False(seen.IsNew); + Assert.True(seen.IsDismissed); + fixture.Db.ChangeTracker.Clear(); + var retained = Assert.Single(await List(fixture.Controller)); + Assert.True(retained.LastRunAtUtc > previousRun); + Assert.Equal(original with { LastRunAtUtc = retained.LastRunAtUtc }, retained); + var history = await fixture.Db.SavedJobSearchResults.AsNoTracking().SingleAsync(); + Assert.Equal(legacy.Id, history.SavedJobSearchId); + Assert.Equal("historical-nav-id", history.ExternalJobId); + Assert.Equal(firstSeen, history.FirstSeenAtUtc); + Assert.Equal(retained.LastRunAtUtc, history.LastSeenAtUtc); + Assert.True(history.IsDismissed); + fixture.Discovery.Verify(x => x.SearchAsync("lærer", "Tønsberg", It.IsAny()), Times.Once); + fixture.Discovery.Verify(x => x.SearchAsync(query, location, It.IsAny()), Times.Once); + fixture.Discovery.VerifyNoOtherCalls(); + } + [Theory] [InlineData("name-empty")] [InlineData("name-long")] diff --git a/docs/global-jobs/00/GEOGRAPHY_MULTI_COUNTRY_QA.md b/docs/global-jobs/00/GEOGRAPHY_MULTI_COUNTRY_QA.md index 4660b479..7be95338 100644 --- a/docs/global-jobs/00/GEOGRAPHY_MULTI_COUNTRY_QA.md +++ b/docs/global-jobs/00/GEOGRAPHY_MULTI_COUNTRY_QA.md @@ -40,3 +40,23 @@ Node syntax and Git source whitespace checks passed. Native red/green output and AST-only `graphify update . --no-cluster` completed exit 0: 19,848 nodes / 49,194 edges. Missing PDF/SQL extractors and 146 inputs yielding no symbols remain graph limitations. Generated graph files stay local/untracked; no semantic/LLM graph pass was run. No application tests/build/browser, real geographic datasets, provider/model/translation service or human/native-language/device qualification was run. No central roadmap edit, runtime feature, qualification-status promotion, main merge or production deployment. Only normal development-branch Git publication is authorised. + +## 20 November 2026 · existing saved-search compatibility + +GJ-00 ADR-07 requires future migration to retain the original keyword, unresolved free-text location, search identity and dismissal/first-seen history. EUROPE-READY §§2 and 11 also require temporary geography changes to preserve named searches. The 19 November specification run above could establish neither database readback nor what the current discovery runner actually receives. + +Two cases in `SavedJobSearchSqliteTests.Temporary_search_keeps_legacy_filters_and_dismissal_history` seed existing rows and historical dismissed results in SQLite, clear EF tracking, run a different ad hoc search and reload the named search. One stored value contains composed and decomposed accents with punctuation. The other has a Polish occupation keyword and an empty location. The strict discovery stub checks the original arguments on manual rerun. The final database read verifies the original search ID, name, filters, active state, bare external ID, original first-seen instant and dismissal. A repeated result updates last-seen and last-run and remains previously seen. + +The test baseline was `6da2e79a8a8d5e77bf5d6d1acf12a762e1ae138a`. The saved-search entity, discovery controller, runner and pre-existing SQLite tests matched integration `245f2feaa8bee2db8f5da0797b3e33f6ef8b056e` byte for byte. The authoritative ADR blob in planning commit `0ec9f98e` was `dcde56f5435da64ca4ac4e4e1b0b69e29d9c6f2e`. + +The locked restore used the local NuGet cache. .NET SDK 9.0.317 built and ran the following selection. + +```powershell +dotnet test JobTrackerApi.Tests/JobTrackerApi.Tests.csproj --no-restore --filter 'FullyQualifiedName~SavedJobSearchSqliteTests|FullyQualifiedName~SavedJobSearchAlertTests|FullyQualifiedName~JobDiscoveryControllerTests' +``` + +**PASSED** 27 cases, including the two new cases. The breakdown was 12 SQLite persistence, 12 existing alert-worker and three existing discovery-controller cases. Failed 0, skipped 0. Local TRX SHA-256 was `933ab479e2d7d7b2b704a8341947673c2c5c5ff90c45cfa80ad8ec4ae128efee`. No provider or model was contacted. + +The AST-only Graphify refresh passed with 19,854 nodes and 49,213 edges. SQL extraction remained unavailable and 146 source inputs yielded no symbols. The generated graph stays local. + +**NOT RUN** MariaDB, HTTP/browser, real providers, authenticated country/language preference updates, a migration and rollback. Current persisted location is a string. Empty means no location text. Existing rows carry no authority to interpret a string as a canonical place, country or radius. At GJ-06 entry, reuse these legacy cases against approved migration and rollback on MariaDB, alongside owner isolation and result history checks. GJ-01 entry requirements remain open.