Skip to content

Commit

Permalink
Merge branch 'main' into vcluster/ett-certificates-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
frontend-specialisten committed Oct 25, 2024
2 parents 7260c4f + b445b5a commit 972fd8a
Show file tree
Hide file tree
Showing 269 changed files with 4,387 additions and 3,049 deletions.
33 changes: 7 additions & 26 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"type:test-util",
"type:domain",
"type:assets",
"type:styles"
"type:styles",
"type:environments"
]
},
{
Expand All @@ -70,11 +71,7 @@
},
{
"sourceTag": "type:util",
"onlyDependOnLibsWithTags": [
"type:util",
"type:test-util",
"type:environments"
]
"onlyDependOnLibsWithTags": ["type:util", "type:test-util", "type:environments"]
},
{
"sourceTag": "type:test-util",
Expand All @@ -90,19 +87,11 @@
},
{
"sourceTag": "type:e2e-util",
"onlyDependOnLibsWithTags": [
"type:util",
"type:test-util",
"type:e2e-util"
]
"onlyDependOnLibsWithTags": ["type:util", "type:test-util", "type:e2e-util"]
},
{
"sourceTag": "type:domain",
"onlyDependOnLibsWithTags": [
"type:domain",
"type:util",
"type:test-util"
]
"onlyDependOnLibsWithTags": ["type:domain", "type:util", "type:test-util"]
},
{
"sourceTag": "type:shell",
Expand Down Expand Up @@ -152,19 +141,11 @@
},
{
"sourceTag": "product:dh",
"onlyDependOnLibsWithTags": [
"product:dh",
"product:gf",
"product:watt"
]
"onlyDependOnLibsWithTags": ["product:dh", "product:gf", "product:watt"]
},
{
"sourceTag": "product:eo",
"onlyDependOnLibsWithTags": [
"product:eo",
"product:gf",
"product:watt"
]
"onlyDependOnLibsWithTags": ["product:eo", "product:gf", "product:watt"]
},
{
"sourceTag": "product:gf",
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/eo-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
run: bun run nx build ${{ env.app-name }}

- name: Upload web app build artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.app-name }}
path: ./dist/apps/eo/
Expand All @@ -111,7 +111,7 @@ jobs:
- uses: actions/checkout@v4
- name: Generate version
id: version
uses: Energinet-DataHub/acorn-actions/actions/docker-image-version@v1
uses: Energinet-DataHub/acorn-actions/actions/docker-image-version@v3

build:
runs-on: ubuntu-latest
Expand All @@ -124,7 +124,7 @@ jobs:

- name: Build and push container image
id: docker_build
uses: Energinet-DataHub/acorn-actions/actions/docker-build-and-push@v1
uses: Energinet-DataHub/acorn-actions/actions/docker-build-and-push@v3
with:
dockerfile: build/infrastructure/eo/host/Dockerfile
image-name: eo-frontend-app
Expand All @@ -138,7 +138,7 @@ jobs:
concurrency: commits-base-environment
steps:
- name: Update environment
uses: Energinet-DataHub/acorn-actions/actions/update-base-environment@v1
uses: Energinet-DataHub/acorn-actions/actions/update-base-environment@v3
with:
configuration: build/infrastructure/eo/configuration.yaml
deploy_key: ${{ secrets.DEPLOY_KEY_BASE_ENVIRONMENT }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ env:

# DH E2E
# Note: Cypress automatically removes the "CYPRESS_" prefix in CI
CYPRESS_DH_E2E_USERNAME: ${{ secrets.DH_E2E_U1_USERNAME }}
CYPRESS_DH_E2E_USERNAME: ${{ vars.DH_E2E_U1_USERNAME }}
CYPRESS_DH_E2E_PASSWORD: ${{ secrets.DH_E2E_U1_PASSWORD }}
CYPRESS_DH_E2E_B2C_URL: https://b2cshresdevwe002.b2clogin.com
# See https://github.com/cypress-io/cypress/issues/25357
Expand Down
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"singleQuote": true,
"printWidth": 100,
"trailingComma": "es5",
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ depend on:
| Type | Contains | Name | Allowed Dependencies |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **`feature`** | Smart UI (with access to data sources) for specific business use cases or pages in an application. | `feature‑<name>` | `assets` `configuration` `feature` `ui` `data‑access` `domain` `util` `test‑util` `environments` |
| **`ui`** | Presentational logic (presentational components, pipes, presentational services, directives). | `ui‑<name>` | `ui` `util` `test-util` `domain` `assets` `styles` |
| **`ui`** | Presentational logic (presentational components, pipes, presentational services, directives). | `ui‑<name>` | `ui` `util` `test-util` `domain` `assets` `styles` `environments` |
| **`data‑access`** | Code for interacting with a back-end system. It also includes all the code related to state management, and HTTP interceptors. | `data‑access‑<name>` | `data-access` `util` `test-util` `domain` `environments` |
| **`util`** | Low-level utilities used by many libraries and applications (services, pure functions, contants). | `util‑<name>` | `util` `test-util` `environments` |
| **`test‑util`** | Stubs, jest matchers, testing modules and test library configuration. | `test‑util‑<name>` | `data-access` `util` `test-util` `domain` `configuration` `assets` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public async Task GetActorGridAreasAsync()
.Setup(x => x.ActorGetAsync(It.IsAny<CancellationToken>(), It.IsAny<string?>()))
.ReturnsAsync([]);

var result = await server.ExecuteRequestAsync(b => b.SetQuery(_actorByIdQuery));
var result = await server.ExecuteRequestAsync(b => b.SetDocument(_actorByIdQuery));

await result.MatchSnapshotAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public async Task GetFilteredActorsAsync(bool isFas)
.Setup(x => x.HttpContext)
.Returns(context);

var result = await server.ExecuteRequestAsync(b => b.SetQuery(_filteredActors));
var result = await server.ExecuteRequestAsync(b => b.SetDocument(_filteredActors));

await result.MatchSnapshotAsync($"GetFilteredActorsAsync-isFas-{isFas}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static async Task ExecuteTestAsync(string testname, DateTimeOffset valid
},
});

var result = await server.ExecuteRequestAsync(b => b.SetQuery(_actorByIdWithbalanceResponsibleAgreementsQuery));
var result = await server.ExecuteRequestAsync(b => b.SetDocument(_actorByIdWithbalanceResponsibleAgreementsQuery));

await result.MatchSnapshotAsync(testname);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task GetCalculationGridAreasAsync()
.Setup(x => x.ActorGetAsync(It.IsAny<CancellationToken>(), It.IsAny<string?>()))
.ReturnsAsync([]);

var result = await server.ExecuteRequestAsync(b => b.SetQuery(_calculationByIdQuery));
var result = await server.ExecuteRequestAsync(b => b.SetDocument(_calculationByIdQuery));

await result.MatchSnapshotAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static async Task ExecuteTestAsync(CalculationOrchestrationState orchest
OrchestrationState = orchestrationState,
});

var result = await server.ExecuteRequestAsync(b => b.SetQuery(_calculationByIdQuery));
var result = await server.ExecuteRequestAsync(b => b.SetDocument(_calculationByIdQuery));

await result.MatchSnapshotAsync($"{orchestrationState}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static async Task ExecuteTestAsync(CalculationOrchestrationState orchest
OrchestrationState = orchestrationState,
});

var result = await server.ExecuteRequestAsync(b => b.SetQuery(_calculationByIdQuery));
var result = await server.ExecuteRequestAsync(b => b.SetDocument(_calculationByIdQuery));

await result.MatchSnapshotAsync($"{orchestrationState}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task GetGridAreaWithStatusAsync()
.Setup(x => x.GridAreaGetAsync(It.IsAny<CancellationToken>(), It.IsAny<string?>()))
.ReturnsAsync(gridAreas);

var result = await server.ExecuteRequestAsync(b => b.SetQuery(_getGridAreasWithStatus));
var result = await server.ExecuteRequestAsync(b => b.SetDocument(_getGridAreasWithStatus));

await result.MatchSnapshotAsync($"GetGridAreasWithStatus");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright 2020 Energinet DataHub A/S
//
// Licensed under the Apache License, Version 2.0 (the "License2");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Energinet.DataHub.WebApi.Clients.MarketParticipant.v1;
using Energinet.DataHub.WebApi.Tests.Extensions;
using Energinet.DataHub.WebApi.Tests.TestServices;
using Moq;
using Xunit;

namespace Energinet.DataHub.WebApi.Tests.Integration.GraphQL.MessageDelegation;

public class MessageDelegationStatusTests
{
private static readonly Guid _actorId = new("9d1b5e2a-3c4e-4f8b-9a6e-7f2b6c8d9e1f");

private static readonly string _messageDelegationQuery =
$$"""
{
delegationsForActor(actorId: "{{_actorId}}") {
id
status
}
}
""";

private static readonly DateTimeOffset _sameDate = DateTimeOffset.Now.AddDays(5);
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.

public static IEnumerable<object[]> GetTestCases()
{
yield return new object[] { "Cancelled same date", _sameDate, _sameDate };
yield return new object[] { "Cancelled", DateTimeOffset.Now.AddDays(5), DateTimeOffset.Now.AddDays(4) };
yield return new object[] { "Active with end", DateTimeOffset.Now.AddDays(-5), DateTimeOffset.Now.AddDays(10) };
yield return new object[] { "Active without end", DateTimeOffset.Now.AddDays(-5), null };
yield return new object[] { "Expired", DateTimeOffset.Now.AddDays(-5), DateTimeOffset.Now.AddDays(-1) };
}

#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.

[Theory]
[MemberData(nameof(GetTestCases))]
public async Task MessageDelegationWithStatus(string testname, DateTimeOffset validFrom, DateTimeOffset? validTo) =>
await ExecuteTestAsync(testname, validFrom, validTo);

private static async Task ExecuteTestAsync(string testname, DateTimeOffset validFrom, DateTimeOffset? validTo)
{
var server = new GraphQLTestService();

server.MarketParticipantClientV1Mock
.Setup(x => x.ActorDelegationsGetAsync(_actorId, default))
.ReturnsAsync(new GetDelegationsForActorResponse()
{
Delegations = new[]
{
new ProcessDelegationDto()
{
Id = new("8d1b5e2a-3c4e-4f8b-9a6e-7f2b6c8d9e1f"),
DelegatedBy = Guid.NewGuid(),
Process = DelegatedProcess.ReceiveEnergyResults,
Periods = new[]
{
new DelegationPeriodDto()
{
DelegatedTo = Guid.NewGuid(),
GridAreaId = Guid.NewGuid(),
Id = Guid.NewGuid(),
StartsAt = validFrom,
StopsAt = validTo,
},
},
},
},
});

var result = await server.ExecuteRequestAsync(b => b.SetDocument(_messageDelegationQuery));

await result.MatchSnapshotAsync(testname);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"delegationsForActor": [
{
"id": "8d1b5e2a-3c4e-4f8b-9a6e-7f2b6c8d9e1f",
"status": "ACTIVE"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"delegationsForActor": [
{
"id": "8d1b5e2a-3c4e-4f8b-9a6e-7f2b6c8d9e1f",
"status": "ACTIVE"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"delegationsForActor": [
{
"id": "8d1b5e2a-3c4e-4f8b-9a6e-7f2b6c8d9e1f",
"status": "CANCELLED"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"delegationsForActor": [
{
"id": "8d1b5e2a-3c4e-4f8b-9a6e-7f2b6c8d9e1f",
"status": "CANCELLED"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"delegationsForActor": [
{
"id": "8d1b5e2a-3c4e-4f8b-9a6e-7f2b6c8d9e1f",
"status": "EXPIRED"
}
]
}
}
Loading

0 comments on commit 972fd8a

Please sign in to comment.