Skip to content

Commit

Permalink
Changed actors graphql, so include the data needed for the new list (#…
Browse files Browse the repository at this point in the history
…1937)

* Changed actors graphql, so include the data needed for the new list

* Run login on u1

* Use U1 user for E2E
  • Loading branch information
mimse authored Aug 8, 2023
1 parent 80e30ec commit 1dea4b1
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 48 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ env:

# DH E2E
# Note: Cypress automatically removes the "CYPRESS_" prefix in CI
CYPRESS_DH_E2E_USERNAME: ${{ secrets.DH_E2E_USERNAME }}
CYPRESS_DH_E2E_PASSWORD: ${{ secrets.DH_E2E_PASSWORD }}
CYPRESS_DH_E2E_B2C_URL: https://dev002DataHubB2C.b2clogin.com
CYPRESS_DH_E2E_USERNAME: ${{ secrets.DH_E2E_U1_USERNAME }}
CYPRESS_DH_E2E_PASSWORD: ${{ secrets.DH_E2E_U1_PASSWORD }}
CYPRESS_DH_E2E_B2C_URL: https://devDataHubB2C.b2clogin.com
# See https://github.com/cypress-io/cypress/issues/25357
ELECTRON_EXTRA_LAUNCH_ARGS: --disable-gpu
on:
Expand Down
11 changes: 7 additions & 4 deletions apps/dh/api-dh/source/DataHub.WebApi/GraphQL/GraphQLQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,19 @@ public GraphQLQuery()
y.EicFunction is EicFunction.EnergySupplier or EicFunction.GridAccessProvider));
}
var accessibleActors = actors.Select(x => new Actor(x.ActorNumber.Value)
var accessibleActors = actors.Select(x => new Actor(x.ActorId, x.Name.Value, x.ActorNumber.Value)
{
Id = x.ActorId,
Name = x.Name.Value,
Number = x.ActorNumber.Value,
GridAreaCodes = x.MarketRoles
GlnOrEicNumber = x.ActorNumber.Value,
GridAreas = x.MarketRoles
.SelectMany(marketRole => marketRole.GridAreas.Select(gridArea => gridArea.Id))
.Distinct()
.Select(gridAreaId => gridAreaLookup[gridAreaId].Code)
.Select(gridAreaId => gridAreaLookup[gridAreaId])
.ToArray(),
MarketRole = x.MarketRoles.FirstOrDefault()?.EicFunction,
Status = x.Status,
});
// TODO: Is this the right place to filter this list?
Expand Down
19 changes: 13 additions & 6 deletions apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/Actor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,29 @@
// limitations under the License.

using System;
using Energinet.DataHub.MarketParticipant.Client.Models;

namespace Energinet.DataHub.WebApi.GraphQL
{
public class Actor
{
public Guid Id { get; set; } = Guid.Empty;
public Guid Id { get; set; }

public string Name { get; set; } = string.Empty;
public string Name { get; set; }

public string Number { get; set; }
public string GlnOrEicNumber { get; set; }

public string[] GridAreaCodes { get; set; } = Array.Empty<string>();
public EicFunction? MarketRole { get; set; }

public Actor(string number)
public GridAreaDto[] GridAreas { get; set; } = Array.Empty<GridAreaDto>();

public ActorStatus Status { get; set; }

public Actor(Guid id, string name, string glnOrEicNumber)
{
Number = number;
Id = id;
Name = name;
GlnOrEicNumber = glnOrEicNumber;
}
}
}
18 changes: 13 additions & 5 deletions apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/ActorDtoType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ public ActorDtoType()
Name = "Actor";

Field(x => x.Id).Description("The id of the actor.");
Field(x => x.Number).Description("The number of the actor.");
Field(x => x.GlnOrEicNumber).Description("The gln or eic number of the actor.");
Field(x => x.Name).Description("The name of the actor.");
Field<NonNullGraphType<ListGraphType<NonNullGraphType<StringGraphType>>>>("GridAreaCodes")
.Resolve(x => x.Source.GridAreaCodes)
.Description("The grid areas the actor belongs to.");

Field<NonNullGraphType<ListGraphType<NonNullGraphType<GridAreaType>>>>("gridAreas")
.Resolve(x => x.Source.GridAreas)
.Description("The grid areas the actor belongs to.");

Field<EicFunctionEnum>("marketRole")
.Resolve(x => x.Source.MarketRole)
.Description("The market role of the actor.");

Field<ActorStatusEnum>("status")
.Resolve(x => x.Source.Status)
.Description("The status of the actor.");

// Below are commented out since the actor number is currently
// the only field that market participant and wholesale have in common
Expand All @@ -38,7 +47,6 @@ public ActorDtoType()
// Field(x => x.ExternalActorId, nullable: true).Description("The external id of the actor.");
// Field(x => x.Name).Description("The name of the actor.");
// Field(x => x.Status).Description("The status of the actor.");
// Field(x => x.MarketRoles).Description("The market roles of the actor.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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 Energinet.DataHub.MarketParticipant.Client.Models;

namespace Energinet.DataHub.WebApi.GraphQL
{
public class ActorStatusEnum : AsIsCaseEnumerationGraphType<ActorStatus>
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

using Energinet.DataHub.MarketParticipant.Client.Models;
using GraphQL.Types;

namespace Energinet.DataHub.WebApi.GraphQL
{
Expand Down
7 changes: 6 additions & 1 deletion apps/dh/app-dh/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true,
"allowedCommonJsDependencies": ["date-fns", "inputmask", "flat"]
"allowedCommonJsDependencies": [
"date-fns",
"inputmask",
"flat",
"msw"
]
},
"mocked": {
"buildOptimizer": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"clientId": "4281f496-ce5b-4b04-b655-505e834c2f6e",
"scopeUri": "https://dev002DataHubB2C.onmicrosoft.com/backend-bff/api",
"authority": "https://dev002DataHubB2C.b2clogin.com/dev002DataHubB2C.onmicrosoft.com/B2C_1_SignInFlow",
"clientId": "bf76fc24-cfec-498f-8979-ab4123792472",
"scopeUri": "https://devDataHubB2C.onmicrosoft.com/backend-bff/api",
"authority": "https://devDataHubB2C.b2clogin.com/devDataHubB2C.onmicrosoft.com/B2C_1_SignInFlow",
"mitIdInviteFlowUri": "https://devDataHubB2C.b2clogin.com/devDataHubB2C.onmicrosoft.com/B2C_1_MitID_InvitationFlow",
"knownAuthorities": ["dev002DataHubB2C.b2clogin.com"]
"knownAuthorities": ["devDataHubB2C.b2clogin.com"]
}
18 changes: 9 additions & 9 deletions libs/dh/shared/data-access-msw/src/lib/mocks/wholesale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,51 +244,51 @@ const mockedFilteredActors: ActorFilter = [
{
value: '10',
displayValue: 'EnergySupplier (805)',
gridAreaCodes: ['805'],
gridAreas: [{ code: '805' }],
},
{
value: '20',
displayValue: 'GridAccessProvider (806)',
gridAreaCodes: ['806'],
gridAreas: [{ code: '806' }],
},
{
value: '30',
displayValue: 'EnergySupplier (805, 806)',
gridAreaCodes: ['805', '806'],
gridAreas: [{ code: '805' }, { code: '806' }],
},
{
value: '40',
displayValue: 'GridAccessProvider (805, 806)',
gridAreaCodes: ['805', '806'],
gridAreas: [{ code: '805' }, { code: '806' }],
},
// No grid areas found
{
value: '50',
displayValue: 'GridAccessProvider (807, 808)',
gridAreaCodes: ['807', '808'],
gridAreas: [{ code: '807' }, { code: '808' }],
},
];

const mockedActorsForSettlementReport: ActorFilter = [
{
value: '10',
displayValue: 'Energy Go - EnergySupplier (805)',
gridAreaCodes: ['805'],
gridAreas: [{ code: '805' }],
},
{
value: '20',
displayValue: 'Nordlys - GridAccessProvider (806)',
gridAreaCodes: ['806'],
gridAreas: [{ code: '806' }],
},
{
value: '30',
displayValue: 'Mod Strøm - EnergySupplier (807, 808)',
gridAreaCodes: ['805', '806'],
gridAreas: [{ code: '805' }, { code: '806' }],
},
{
value: '40',
displayValue: 'Stor Strøm - GridAccessProvider (807, 808)',
gridAreaCodes: ['805', '806'],
gridAreas: [{ code: '807' }, { code: '808' }],
},
];

Expand Down
Loading

0 comments on commit 1dea4b1

Please sign in to comment.