-
-
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
26 changed files
with
3,915 additions
and
12 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
src/Nikcio.UHeadless.IntegrationTests.TestProject/uSync/v9/Content/old-page.config
This file was deleted.
Oops, something went wrong.
Binary file modified
BIN
+4 KB
(100%)
src/Nikcio.UHeadless.IntegrationTests.TestProject/umbraco/Data/Default-Tests
Binary file not shown.
111 changes: 111 additions & 0 deletions
111
src/Nikcio.UHeadless.IntegrationTests/ApiTests.ContentByRouteQuery.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,111 @@ | ||
using System.Net.Http.Json; | ||
using System.Text; | ||
|
||
namespace Nikcio.UHeadless.IntegrationTests.Defaults; | ||
|
||
public partial class ApiTests | ||
{ | ||
private const string _contentByRouteSnapshotPath = $"{SnapshotConstants.BasePath}/ContentByRoute"; | ||
|
||
[Theory] | ||
[InlineData("https://site-1.com", "/", null, false, null, true)] | ||
[InlineData("https://site-1.com", "/homepage", null, false, null, true)] | ||
[InlineData("https://site-1.com", "/page-1", null, false, null, true)] | ||
[InlineData("https://site-1.com", "/page-2", null, false, null, true)] | ||
[InlineData("https://site-1.com", "/collection-of-pages/block-list-page", null, false, null, true)] | ||
[InlineData("", "/no-domain-site", null, false, null, true)] | ||
[InlineData("", "/no-domain-homepage", null, false, null, true)] | ||
[InlineData("https://site-2.com", "/", null, false, null, true)] | ||
[InlineData("https://site-2.com", "/page-1", null, false, null, true)] | ||
[InlineData("https://site-culture.com", "/homepage", "en-us", false, null, true)] | ||
[InlineData("https://site-culture.dk", "/homepage", "da", false, null, true)] | ||
[InlineData("https://site-1.com", "/old-page", "en-us", false, null, true)] | ||
[InlineData("https://site-1.com", "/new-page", "en-us", false, null, true)] | ||
public async Task ContentByRouteQuery_Snaps_Async( | ||
string baseUrl, | ||
string route, | ||
string? culture, | ||
bool? includePreview, | ||
string? segment, | ||
bool expectSuccess) | ||
{ | ||
var snapshotProvider = new SnapshotProvider($"{_contentByRouteSnapshotPath}/Snaps"); | ||
HttpClient client = _factory.CreateClient(); | ||
|
||
using var request = JsonContent.Create(new | ||
{ | ||
query = ContentByRouteQueries.GetItems, | ||
variables = new | ||
{ | ||
baseUrl, | ||
route, | ||
culture, | ||
includePreview, | ||
segment | ||
} | ||
}); | ||
|
||
HttpResponseMessage response = await client.PostAsync("/graphql", request).ConfigureAwait(true); | ||
|
||
string responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(true); | ||
|
||
string snapshotName = $"ContentByRoute_Snaps_{Convert.ToBase64String(Encoding.UTF8.GetBytes(baseUrl))}_{Convert.ToBase64String(Encoding.UTF8.GetBytes(route))}_{culture}_{includePreview}_{segment}"; | ||
|
||
await snapshotProvider.AssertIsSnapshotEqualAsync(snapshotName, responseContent).ConfigureAwait(true); | ||
Assert.Equal(expectSuccess, response.IsSuccessStatusCode); | ||
} | ||
} | ||
|
||
public static class ContentByRouteQueries | ||
{ | ||
public const string GetItems = """ | ||
query ContentByRouteQuery( | ||
$baseUrl: String!, | ||
$route: String!, | ||
$culture: String | ||
$includePreview: Boolean | ||
$fallbacks: [PropertyFallback!] | ||
$segment: String | ||
) { | ||
contentByRoute( | ||
baseUrl: $baseUrl, | ||
route: $route, | ||
inContext: { | ||
culture: $culture | ||
includePreview: $includePreview | ||
fallbacks: $fallbacks | ||
segment: $segment | ||
} | ||
) { | ||
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 | ||
} | ||
} | ||
""" + Fragments.TypedProperties; | ||
} |
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"items": [], | ||
"page": 1, | ||
"pageSize": 0, | ||
"totalItems": 15, | ||
"totalItems": 16, | ||
"hasNextPage": true | ||
} | ||
} | ||
|
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
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 |
---|---|---|
|
@@ -247,7 +247,7 @@ | |
], | ||
"page": 1, | ||
"pageSize": 1, | ||
"totalItems": 15, | ||
"totalItems": 16, | ||
"hasNextPage": true | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -1760,7 +1760,7 @@ | |
], | ||
"page": 1, | ||
"pageSize": 5, | ||
"totalItems": 15, | ||
"totalItems": 16, | ||
"hasNextPage": true | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -1760,7 +1760,7 @@ | |
], | ||
"page": 1, | ||
"pageSize": 5, | ||
"totalItems": 15, | ||
"totalItems": 16, | ||
"hasNextPage": true | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -1760,7 +1760,7 @@ | |
], | ||
"page": 1, | ||
"pageSize": 5, | ||
"totalItems": 15, | ||
"totalItems": 16, | ||
"hasNextPage": true | ||
} | ||
} | ||
|
Oops, something went wrong.