@@ -79,6 +79,158 @@ await _page.Locator("#loginButton").WaitForAsync(new LocatorWaitForOptions
7979 } , nameof ( AssertEstateInfoPageVisibleAsync ) ) ;
8080 }
8181
82+ public async Task OpenOperatorManagementScreenAsync ( )
83+ {
84+ await RunWithFailureArtifactsAsync ( async ( ) =>
85+ {
86+ var operatorLink = _page . Locator ( "#operatorsLink" ) ;
87+ if ( await operatorLink . CountAsync ( ) > 0 && await operatorLink . First . IsVisibleAsync ( ) )
88+ {
89+ await operatorLink . First . ClickAsync ( new LocatorClickOptions { NoWaitAfter = true } ) ;
90+ }
91+ else
92+ {
93+ await _page . GotoAsync ( ResolveEstateManagementBaseUrl ( ) + "/operators" ) ;
94+ }
95+
96+ await _page . WaitForLoadStateAsync ( LoadState . NetworkIdle ) ;
97+ } , nameof ( OpenOperatorManagementScreenAsync ) ) ;
98+ }
99+
100+ public async Task AssertOperatorManagementHeadingVisibleAsync ( )
101+ {
102+ await RunWithFailureArtifactsAsync ( async ( ) =>
103+ {
104+ await WaitForOperatorManagementAsync ( ) ;
105+ ( await _page . GetByRole ( AriaRole . Heading , new ( ) { Name = "Operator Management" } ) . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
106+ } , nameof ( AssertOperatorManagementHeadingVisibleAsync ) ) ;
107+ }
108+
109+ public async Task AssertOperatorListContainsAsync ( string operatorName )
110+ {
111+ await RunWithFailureArtifactsAsync ( async ( ) =>
112+ {
113+ var operatorRow = GetOperatorRow ( operatorName ) ;
114+ await operatorRow . WaitForAsync ( new LocatorWaitForOptions
115+ {
116+ State = WaitForSelectorState . Visible ,
117+ Timeout = 10000
118+ } ) ;
119+
120+ ( await operatorRow . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
121+ } , nameof ( AssertOperatorListContainsAsync ) ) ;
122+ }
123+
124+ public async Task OpenOperatorViewAsync ( string operatorName )
125+ {
126+ await RunWithFailureArtifactsAsync ( async ( ) =>
127+ {
128+ var operatorRow = GetOperatorRow ( operatorName ) ;
129+ await operatorRow . WaitForAsync ( new LocatorWaitForOptions
130+ {
131+ State = WaitForSelectorState . Visible ,
132+ Timeout = 10000
133+ } ) ;
134+
135+ await operatorRow . ClickAsync ( ) ;
136+ } , nameof ( OpenOperatorViewAsync ) ) ;
137+ }
138+
139+ public async Task AssertOperatorViewVisibleAsync ( string operatorName )
140+ {
141+ await RunWithFailureArtifactsAsync ( async ( ) =>
142+ {
143+ var heading = _page . GetByRole ( AriaRole . Heading , new ( ) { Name = $ "View Operator: { operatorName } " } ) ;
144+ await heading . WaitForAsync ( new LocatorWaitForOptions
145+ {
146+ State = WaitForSelectorState . Visible ,
147+ Timeout = 10000
148+ } ) ;
149+
150+ ( await heading . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
151+ ( await _page . GetByRole ( AriaRole . Heading , new ( ) { Name = "Operator Details" } ) . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
152+ ( await _page . GetByRole ( AriaRole . Button , new ( ) { Name = "Back to List" } ) . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
153+ } , nameof ( AssertOperatorViewVisibleAsync ) ) ;
154+ }
155+
156+ public async Task BackToOperatorListFromViewAsync ( )
157+ {
158+ await RunWithFailureArtifactsAsync ( async ( ) =>
159+ {
160+ await _page . GetByRole ( AriaRole . Button , new ( ) { Name = "Back to List" } ) . ClickAsync ( ) ;
161+ await _page . WaitForLoadStateAsync ( LoadState . NetworkIdle ) ;
162+ } , nameof ( BackToOperatorListFromViewAsync ) ) ;
163+ }
164+
165+ public async Task OpenOperatorEditAsync ( string operatorName )
166+ {
167+ await RunWithFailureArtifactsAsync ( async ( ) =>
168+ {
169+ var editButton = GetOperatorRow ( operatorName ) . GetByRole ( AriaRole . Button , new ( ) { Name = "Edit" } ) ;
170+ await editButton . WaitForAsync ( new LocatorWaitForOptions
171+ {
172+ State = WaitForSelectorState . Visible ,
173+ Timeout = 10000
174+ } ) ;
175+
176+ await editButton . ClickAsync ( ) ;
177+ } , nameof ( OpenOperatorEditAsync ) ) ;
178+ }
179+
180+ public async Task AssertOperatorEditVisibleAsync ( string operatorName )
181+ {
182+ await RunWithFailureArtifactsAsync ( async ( ) =>
183+ {
184+ var heading = _page . GetByRole ( AriaRole . Heading , new ( ) { Name = $ "Edit Operator: { operatorName } " } ) ;
185+ await heading . WaitForAsync ( new LocatorWaitForOptions
186+ {
187+ State = WaitForSelectorState . Visible ,
188+ Timeout = 10000
189+ } ) ;
190+
191+ ( await heading . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
192+ ( await _page . Locator ( "input[placeholder='Enter operator name']" ) . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
193+ ( await _page . GetByRole ( AriaRole . Button , new ( ) { Name = "Update Operator" } ) . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
194+ } , nameof ( AssertOperatorEditVisibleAsync ) ) ;
195+ }
196+
197+ public async Task CancelOperatorEditAsync ( )
198+ {
199+ await RunWithFailureArtifactsAsync ( async ( ) =>
200+ {
201+ await _page . GetByRole ( AriaRole . Button , new ( ) { Name = "Cancel" } ) . ClickAsync ( ) ;
202+ await _page . WaitForLoadStateAsync ( LoadState . NetworkIdle ) ;
203+ } , nameof ( CancelOperatorEditAsync ) ) ;
204+ }
205+
206+ public async Task OpenNewOperatorScreenAsync ( )
207+ {
208+ await RunWithFailureArtifactsAsync ( async ( ) =>
209+ {
210+ await _page . Locator ( "#newOperatorButton" ) . ClickAsync ( ) ;
211+ await _page . WaitForLoadStateAsync ( LoadState . NetworkIdle ) ;
212+ } , nameof ( OpenNewOperatorScreenAsync ) ) ;
213+ }
214+
215+ public async Task AssertNewOperatorScreenVisibleAsync ( )
216+ {
217+ await RunWithFailureArtifactsAsync ( async ( ) =>
218+ {
219+ ( await _page . GetByRole ( AriaRole . Heading , new ( ) { Name = "Create New Operator" } ) . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
220+ ( await _page . Locator ( "input[placeholder='Enter operator name']" ) . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
221+ ( await _page . Locator ( "#createOperatorButton" ) . IsVisibleAsync ( ) ) . ShouldBeTrue ( ) ;
222+ } , nameof ( AssertNewOperatorScreenVisibleAsync ) ) ;
223+ }
224+
225+ public async Task CreateOperatorAsync ( string operatorName )
226+ {
227+ await RunWithFailureArtifactsAsync ( async ( ) =>
228+ {
229+ await _page . Locator ( "input[placeholder='Enter operator name']" ) . FillAsync ( operatorName ) ;
230+ await _page . Locator ( "#createOperatorButton" ) . ClickAsync ( ) ;
231+ } , nameof ( CreateOperatorAsync ) ) ;
232+ }
233+
82234 public async Task ClickSignInButtonAsync ( )
83235 {
84236 await RunWithFailureArtifactsAsync ( async ( ) =>
@@ -492,12 +644,30 @@ await _page.Locator(".animate-spin").WaitForAsync(new LocatorWaitForOptions
492644 } ) ;
493645 }
494646
647+ private async Task WaitForOperatorManagementAsync ( )
648+ {
649+ var spinner = _page . Locator ( ".animate-spin" ) ;
650+ if ( await spinner . CountAsync ( ) > 0 )
651+ {
652+ await spinner . First . WaitForAsync ( new LocatorWaitForOptions
653+ {
654+ State = WaitForSelectorState . Hidden ,
655+ Timeout = 10000
656+ } ) ;
657+ }
658+ }
659+
495660 private ILocator GetAssignedOperatorRow ( string operatorName )
496661 {
497662 return _page . Locator ( "div.flex.items-center.justify-between.p-3.bg-gray-50.rounded-lg" )
498663 . Filter ( new ( ) { HasText = operatorName } ) ;
499664 }
500665
666+ private ILocator GetOperatorRow ( string operatorName )
667+ {
668+ return _page . Locator ( "tbody tr" ) . Filter ( new ( ) { HasText = operatorName } ) ;
669+ }
670+
501671 private async Task < bool > IsAnyVisibleAsync ( params string [ ] selectors )
502672 {
503673 foreach ( var selector in selectors )
0 commit comments