-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CDMS-200 refactors analytics chart mechanism to run in parrallel and …
…allow charts to be specified
- Loading branch information
1 parent
1b759f5
commit ce27576
Showing
13 changed files
with
262 additions
and
114 deletions.
There are no files selected for viewing
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
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
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
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
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,105 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Btms.Common.Extensions; | ||
using Btms.Model; | ||
using Btms.SyncJob; | ||
using Btms.Backend.IntegrationTests.JsonApiClient; | ||
using FluentAssertions; | ||
using System.Net; | ||
using System.Net.Http.Json; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Serialization; | ||
using Btms.Backend.IntegrationTests.Extensions; | ||
using Btms.Backend.IntegrationTests.Helpers; | ||
using Json.More; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Btms.Backend.IntegrationTests; | ||
|
||
[Trait("Category", "Integration")] | ||
public class AnalyticsTests(IntegrationTestsApplicationFactory factory, ITestOutputHelper testOutputHelper) | ||
: BaseApiTests(factory, testOutputHelper), IClassFixture<IntegrationTestsApplicationFactory> | ||
{ | ||
|
||
// private static void ShouldNotBeNull<T>([DoesNotReturnIf(true), NotNull] T? value) | ||
// { | ||
// // throw if null | ||
// value.Should().NotBeNull(); | ||
// } | ||
|
||
[Fact] | ||
public async Task GetIndividualMultiSeriesDatetimeChart() | ||
{ | ||
//Act | ||
var response = await Client.GetAsync( | ||
"/analytics/dashboard?chartsToRender=importNotificationLinkingByCreated"); | ||
|
||
// Assert | ||
response.IsSuccessStatusCode.Should().BeTrue(response.StatusCode.ToString()); | ||
|
||
var responseDictionary = await response.ToJsonDictionary(); | ||
|
||
responseDictionary.Count.Should().Be(1); | ||
|
||
responseDictionary.Keys.Should().Equal("importNotificationLinkingByCreated"); | ||
|
||
} | ||
|
||
[Fact] | ||
public async Task GetIndividualMultiSeriesChart() | ||
{ | ||
//Act | ||
var response = await Client.GetAsync( | ||
"/analytics/dashboard?chartsToRender=lastMonthMovementsByItemCount"); | ||
|
||
// Assert | ||
response.IsSuccessStatusCode.Should().BeTrue(response.StatusCode.ToString()); | ||
|
||
var responseDictionary = await response.ToJsonDictionary(); | ||
|
||
responseDictionary.Count.Should().Be(1); | ||
|
||
responseDictionary.Keys.Should().Equal("lastMonthMovementsByItemCount"); | ||
|
||
} | ||
|
||
[Fact] | ||
public async Task GetIndividualSingleSeriesChart() | ||
{ | ||
//Act | ||
var response = await Client.GetAsync( | ||
"/analytics/dashboard?chartsToRender=last7DaysImportNotificationsLinkingStatus"); | ||
|
||
// Assert | ||
response.IsSuccessStatusCode.Should().BeTrue(response.StatusCode.ToString()); | ||
|
||
var responseDictionary = await response.ToJsonDictionary(); | ||
|
||
responseDictionary.Count.Should().Be(1); | ||
|
||
responseDictionary.Keys.Should().Equal("last7DaysImportNotificationsLinkingStatus"); | ||
|
||
} | ||
|
||
[Fact] | ||
public async Task GetAllCharts() | ||
{ | ||
//Act | ||
var response = await Client.GetAsync("/analytics/dashboard"); | ||
|
||
// Assert | ||
response.IsSuccessStatusCode.Should().BeTrue(response.StatusCode.ToString()); | ||
|
||
var responseDictionary = await response.ToJsonDictionary(); | ||
|
||
responseDictionary.Count.Should().Be(13); | ||
|
||
responseDictionary.Keys.Take(2).Should().Equal( | ||
"importNotificationLinkingByCreated", | ||
"importNotificationLinkingByArrival"); | ||
|
||
responseDictionary["importNotificationLinkingByCreated"].Should().NotBeNull(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Btms.Backend.IntegrationTests/Extensions/HttpExtensions.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,14 @@ | ||
using System.Text.Json.Nodes; | ||
using Btms.Common.Extensions; | ||
|
||
namespace Btms.Backend.IntegrationTests.Extensions; | ||
|
||
public static class HttpExtensions | ||
{ | ||
public static async Task<IDictionary<string, JsonNode>> ToJsonDictionary(this HttpResponseMessage? response) | ||
{ | ||
var responseDictionary = (await response!.Content.ReadAsStringAsync()).ToJsonDictionary(); | ||
ArgumentNullException.ThrowIfNull(responseDictionary); | ||
return responseDictionary; | ||
} | ||
} |
Oops, something went wrong.