-
Notifications
You must be signed in to change notification settings - Fork 75
Migrate integration tests to in-process hosts via WebApplicationFactory and remove external server orchestration from build
#564
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
Merged
xperiandri
merged 23 commits into
dev
from
copilot/use-webapplicationfactory-integration-tests
May 17, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e92e6f5
Migrate integration tests to in-process hosts via WebApplicationFacto…
Copilot 1cb4ec1
Add dedicated introspection update integration tests
Copilot 4a192ad
Remove trailing blank lines in integration provider tests
Copilot da42711
Address review feedback in introspection and swapi tests
Copilot 35f0275
Improve test host disposal and introspection file update safety
Copilot 7b3a024
Clarify introspection update test variable naming
Copilot 2f0108c
Make introspection update test idempotence explicit
Copilot a953ff4
Rename introspection stream variable for clarity
Copilot 4c3e468
Replace lazy shared test clients with explicit client factory methods
Copilot 4b3788c
Refactor repeated friends index access in remote provider tests
Copilot 6e3b98a
Apply do blocks for friend assertions in SwapiRemoteProviderTests
Copilot cf98a5a
Remove unused integration test targets from build script
Copilot 28a3e9a
Restore introspection update in default build target chain
Copilot b9516f2
Restore introspection refresh in `BuildAndTest` target pipeline
Copilot c2bd3b5
Plan: replace custom introspection update target with test invocation
Copilot 7b3e9b8
Replace custom introspection update logic with integration test execu…
Copilot da16a5e
Use integration introspection update tests in build pipeline
Copilot 5867d45
Revert unintended introspection.json change
Copilot 1645ed9
WIP fixing `FSharp.Data.GraphQL.Integration.slnx` build
xperiandri 9d1b0e0
Fix slnx build blockers
Copilot db23e2c
Stabilize sample introspection build inputs
Copilot bf46908
fixup! WIP fixing `FSharp.Data.GraphQL.Integration.slnx` build
xperiandri 5179f08
Revert sample-local introspection snapshot
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
tests/FSharp.Data.GraphQL.IntegrationTests/IntrospectionUpdateTests.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| module FSharp.Data.GraphQL.IntegrationTests.IntrospectionUpdateTests | ||
|
|
||
| open System | ||
| open System.IO | ||
| open System.Net.Http.Json | ||
| open System.Text.Json | ||
| open System.Threading | ||
| open Xunit | ||
|
|
||
| let introspectionFilePath = | ||
| Path.Combine (__SOURCE_DIRECTORY__, "integration-introspection.json") | ||
| |> Path.GetFullPath | ||
|
|
||
| let normalizeJsonDocument options (document : JsonDocument) = | ||
| use buffer = new MemoryStream () | ||
| use writer = new Utf8JsonWriter (buffer, options) | ||
| document.WriteTo writer | ||
| writer.Flush () | ||
| buffer.Seek (0L, SeekOrigin.Begin) |> ignore | ||
| JsonDocument.Parse buffer | ||
|
|
||
| let parseAndNormalizeJsonAsync ct options stream = | ||
| task { | ||
| let! document = JsonDocument.ParseAsync (stream, cancellationToken = ct) | ||
| return normalizeJsonDocument options document | ||
| } | ||
|
|
||
| let areSchemasEqual (document1 : JsonDocument) (document2 : JsonDocument) = | ||
| let schema1 = document1.RootElement.GetProperty("data").GetProperty("__schema") | ||
| let schema2 = document2.RootElement.GetProperty("data").GetProperty("__schema") | ||
| schema1.GetRawText() = schema2.GetRawText() | ||
|
|
||
| let readDestinationDocumentAsync ct (stream : FileStream) = | ||
| task { | ||
| try | ||
| let! document = JsonDocument.ParseAsync (stream, cancellationToken = ct) | ||
| return ValueSome document | ||
| with :? JsonException -> | ||
| return ValueNone | ||
| } | ||
|
|
||
| let updateIntrospectionFileAsync ct sourceStream = | ||
| task { | ||
| use destinationStream = | ||
| new FileStream (introspectionFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read) | ||
|
|
||
| let options = JsonWriterOptions(Indented = true) | ||
| let! sourceDocument = parseAndNormalizeJsonAsync ct options sourceStream | ||
| destinationStream.Seek (0L, SeekOrigin.Begin) |> ignore | ||
| let! destinationDocument = readDestinationDocumentAsync ct destinationStream | ||
|
|
||
| let shouldUpdate = | ||
| match destinationDocument with | ||
| | ValueNone -> true | ||
| | ValueSome document -> not (areSchemasEqual document sourceDocument) | ||
|
|
||
| if shouldUpdate then | ||
| destinationStream.Seek (0L, SeekOrigin.Begin) |> ignore | ||
| destinationStream.SetLength 0 | ||
| use writer = new Utf8JsonWriter (destinationStream, options) | ||
| sourceDocument.WriteTo writer | ||
| writer.Flush () | ||
|
|
||
| return shouldUpdate | ||
| } | ||
|
|
||
| [<Fact>] | ||
| let ``Get GraphQL introspection response returns schema`` () = | ||
| task { | ||
| use httpClient = TestHosts.createIntegrationHttpClient () | ||
| let! response = httpClient.GetFromJsonAsync<JsonElement>("/", CancellationToken.None) | ||
| let schema = response.GetProperty("data").GetProperty("__schema") | ||
| Assert.NotEqual(Unchecked.defaultof<JsonElement>, schema) | ||
| let hasErrors, _ = response.TryGetProperty "errors" | ||
| Assert.False hasErrors | ||
| } | ||
|
|
||
| [<Fact>] | ||
| let ``Update integration introspection file when schema changes`` () = | ||
| task { | ||
| use httpClient = TestHosts.createIntegrationHttpClient () | ||
| let! sourceStream = httpClient.GetStreamAsync("/") | ||
| let! wasUpdated = updateIntrospectionFileAsync CancellationToken.None sourceStream | ||
| Assert.True(File.Exists introspectionFilePath) | ||
| if wasUpdated then | ||
| let! sourceStreamSecondRun = httpClient.GetStreamAsync("/") | ||
| use sourceStreamForVerification = sourceStreamSecondRun | ||
| let! wasUpdatedSecondRun = updateIntrospectionFileAsync CancellationToken.None sourceStreamForVerification | ||
| Assert.False wasUpdatedSecondRun | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot мне кажется что обновлять introspection всё таки нужно
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вернул обновление introspection в дефолтную цепочку: добавил
StartStarWarsServerTargetиUpdateIntrospectionFileTargetпередAllвbuild/Program.fs. Коммит:038c282.