-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
4,797 additions
and
0 deletions.
There are no files selected for viewing
Binary file modified
BIN
+24 KB
(100%)
src/Nikcio.UHeadless.IntegrationTests.TestProject/umbraco/Data/Default-Tests
Binary file not shown.
106 changes: 106 additions & 0 deletions
106
src/Nikcio.UHeadless.IntegrationTests/ApiTests.ContentByTagQuery.cs
This file contains 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,106 @@ | ||
using System.Net.Http.Json; | ||
|
||
namespace Nikcio.UHeadless.IntegrationTests.Defaults; | ||
|
||
public partial class ApiTests | ||
{ | ||
private const string _contentByTagSnapshotPath = $"{SnapshotConstants.BasePath}/ContentByTag"; | ||
|
||
[Theory] | ||
[InlineData("normal", null, "en-us", false, null, true)] | ||
[InlineData("normal", null, "en-us", true, null, true)] | ||
[InlineData("normal", null, "da", false, null, true)] | ||
public async Task ContentByTagQuery_Snaps_Async( | ||
string tag, | ||
string? tagGroup, | ||
string? culture, | ||
bool? includePreview, | ||
string? segment, | ||
bool expectSuccess) | ||
{ | ||
var snapshotProvider = new SnapshotProvider($"{_contentByTagSnapshotPath}/Snaps"); | ||
HttpClient client = _factory.CreateClient(); | ||
|
||
using var request = JsonContent.Create(new | ||
{ | ||
query = ContentByTagQueries.GetItems, | ||
variables = new | ||
{ | ||
tag, | ||
tagGroup, | ||
culture, | ||
includePreview, | ||
segment | ||
} | ||
}); | ||
|
||
HttpResponseMessage response = await client.PostAsync("/graphql", request).ConfigureAwait(true); | ||
|
||
string responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(true); | ||
|
||
string snapshotName = $"ContentByTag_Snaps_{tag}_{tagGroup}_{culture}_{includePreview}_{segment}"; | ||
|
||
await snapshotProvider.AssertIsSnapshotEqualAsync(snapshotName, responseContent).ConfigureAwait(true); | ||
Assert.Equal(expectSuccess, response.IsSuccessStatusCode); | ||
} | ||
} | ||
|
||
public static class ContentByTagQueries | ||
{ | ||
public const string GetItems = """ | ||
query ContentByTagQuery( | ||
$tag: String!, | ||
$tagGroup: String, | ||
$culture: String | ||
$includePreview: Boolean | ||
$fallbacks: [PropertyFallback!] | ||
$segment: String | ||
) { | ||
contentByTag( | ||
tag: $tag, | ||
tagGroup: $tagGroup | ||
inContext: { | ||
culture: $culture | ||
includePreview: $includePreview | ||
fallbacks: $fallbacks | ||
segment: $segment | ||
} | ||
) { | ||
items { | ||
url(urlMode: ABSOLUTE) | ||
redirect { | ||
redirectUrl | ||
isPermanent | ||
} | ||
statusCode | ||
properties { | ||
...typedProperties | ||
__typename | ||
} | ||
urlSegment | ||
name | ||
id | ||
key | ||
templateId | ||
parent { | ||
url(urlMode: ABSOLUTE) | ||
properties { | ||
...typedProperties | ||
__typename | ||
} | ||
urlSegment | ||
name | ||
id | ||
key | ||
templateId | ||
} | ||
__typename | ||
} | ||
page | ||
pageSize | ||
totalItems | ||
hasNextPage | ||
} | ||
} | ||
""" + Fragments.TypedProperties; | ||
} |
Oops, something went wrong.