File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
IoTHub.Portal.Client/Pages/Planning
IoTHub.Portal.Tests.Unit/Client/Pages/Planning Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 55@attribute [Authorize]
66
77<AuthorizedContent IsLoading =" @IsLoading" IsAuthorized =" @IsAuthorized" >
8- <EditPlanning planning =@Planning scheduleList =@ScheduleList mode =" New" CanWrite =" @canWrite " />
8+ <EditPlanning planning =@Planning scheduleList =@ScheduleList mode =" New" CanWrite =" true " />
99</AuthorizedContent >
1010
1111@code {
1212 // Specify which permissions are required for this page
1313 protected override PortalPermissions [] RequiredPermissions { get ; } = { PortalPermissions .PlanningWrite };
14- private bool canWrite ;
1514
1615 public List <ScheduleDto > ScheduleList { get ; set ; } = new List <ScheduleDto > { };
1716 public PlanningDto Planning { get ; set ; } = new PlanningDto ();
2221
2322 Planning .DayOff = DaysEnumFlag .DaysOfWeek .Saturday | DaysEnumFlag .DaysOfWeek .Sunday ;
2423 ScheduleList .Add (new ScheduleDto { Start = " 00:00" });
25-
26- // Check if user has write permission for conditional UI elements
27- canWrite = await HasPermissionAsync (PortalPermissions .PlanningWrite );
2824 }
2925}
Original file line number Diff line number Diff line change @@ -55,5 +55,28 @@ public void OnInitializedAsync_CreatePlanningPage()
5555 Assert . AreEqual ( cut . Instance . ScheduleList [ 0 ] . Start , "00:00" ) ;
5656 cut . WaitForAssertion ( ( ) => MockRepository . VerifyAll ( ) ) ;
5757 }
58+
59+ [ Test ]
60+ public void CreatePlanningPage_SaveButtonIsDisplayed ( )
61+ {
62+ _ = this . mockLayerClientService . Setup ( service => service . GetLayers ( ) )
63+ . ReturnsAsync ( new List < LayerDto > ( ) ) ;
64+
65+ _ = this . mockDeviceModelsClientService . Setup ( service => service . GetDeviceModelsAsync ( It . IsAny < DeviceModelFilter > ( ) ) )
66+ . ReturnsAsync ( new PaginationResult < DeviceModelDto >
67+ {
68+ Items = new List < DeviceModelDto > ( )
69+ } ) ;
70+
71+ // Act
72+ var cut = RenderComponent < CreatePlanningsPage > ( ) ;
73+
74+ // Wait for the save button to be rendered
75+ var saveButton = cut . WaitForElement ( "#saveButton" ) ;
76+
77+ // Assert
78+ Assert . IsNotNull ( saveButton ) ;
79+ cut . WaitForAssertion ( ( ) => MockRepository . VerifyAll ( ) ) ;
80+ }
5881 }
5982}
You can’t perform that action at this time.
0 commit comments