@@ -251,14 +251,14 @@ public async Task SetupNetworkRequestMockAsyncTest()
251
251
MockSingleTestInstanceState . Setup ( x => x . GetTestSuiteDefinition ( ) ) . Returns ( testSuiteDefinition ) ;
252
252
MockFileSystem . Setup ( x => x . IsValidFilePath ( It . IsAny < string > ( ) ) ) . Returns ( true ) ;
253
253
MockBrowserContext . Setup ( x => x . NewPageAsync ( ) ) . Returns ( Task . FromResult ( MockPage . Object ) ) ;
254
- MockPage . Setup ( x => x . RouteAsync ( mock . RequestURL , It . IsAny < Func < IRoute , Task > > ( ) , It . IsAny < PageRouteOptions > ( ) ) ) . Returns ( Task . FromResult < IResponse ? > ( MockResponse . Object ) ) ;
254
+ MockPage . Setup ( x => x . RouteAsync ( mock . RequestURL , It . IsAny < Action < IRoute > > ( ) , It . IsAny < PageRouteOptions > ( ) ) ) . Returns ( Task . FromResult < IResponse ? > ( MockResponse . Object ) ) ;
255
255
256
256
var playwrightTestInfraFunctions = new PlaywrightTestInfraFunctions ( MockTestState . Object , MockSingleTestInstanceState . Object ,
257
257
MockFileSystem . Object , browserContext : MockBrowserContext . Object ) ;
258
258
await playwrightTestInfraFunctions . SetupNetworkRequestMockAsync ( ) ;
259
259
260
260
MockBrowserContext . Verify ( x => x . NewPageAsync ( ) , Times . Once ) ;
261
- MockPage . Verify ( x => x . RouteAsync ( mock . RequestURL , It . IsAny < Func < IRoute , Task > > ( ) , It . IsAny < PageRouteOptions > ( ) ) , Times . Once ) ;
261
+ MockPage . Verify ( x => x . RouteAsync ( mock . RequestURL , It . IsAny < Action < IRoute > > ( ) , It . IsAny < PageRouteOptions > ( ) ) , Times . Once ) ;
262
262
MockFileSystem . Verify ( x => x . IsValidFilePath ( mock . ResponseDataFile ) , Times . Once ( ) ) ;
263
263
}
264
264
@@ -618,100 +618,5 @@ public async Task RouteNetworkRequestTest()
618
618
MockRoute . Verify ( x => x . ContinueAsync ( It . IsAny < RouteContinueOptions > ( ) ) , Times . Once ) ;
619
619
}
620
620
621
- [ Fact ]
622
- public async Task HandleUserPasswordScreen ( )
623
- {
624
- string testSelector = "input:has-text('Password')" ;
625
- string testTextEntry = "*****" ;
626
- string desiredUrl = "https://make.powerapps.com" ;
627
-
628
- MockSingleTestInstanceState . Setup ( x => x . GetLogger ( ) ) . Returns ( MockLogger . Object ) ;
629
- LoggingTestHelper . SetupMock ( MockLogger ) ;
630
-
631
- var mockLocator = new Mock < ILocator > ( MockBehavior . Strict ) ;
632
- MockPage . Setup ( x => x . Locator ( It . IsAny < string > ( ) , null ) ) . Returns ( mockLocator . Object ) ;
633
- mockLocator . Setup ( x => x . WaitForAsync ( null ) ) . Returns ( Task . CompletedTask ) ;
634
-
635
- MockPage . Setup ( x => x . FillAsync ( testSelector , testTextEntry , null ) ) . Returns ( Task . CompletedTask ) ;
636
- MockPage . Setup ( x => x . ClickAsync ( "input[type=\" submit\" ]" , null ) ) . Returns ( Task . CompletedTask ) ;
637
- // Assume ask already logged in
638
- MockPage . Setup ( x => x . WaitForSelectorAsync ( "[id=\" KmsiCheckboxField\" ]" , It . IsAny < PageWaitForSelectorOptions > ( ) ) ) . Returns ( Task . FromResult ( MockElementHandle . Object ) ) ;
639
- // Simulate Click to stay signed in
640
- MockPage . Setup ( x => x . ClickAsync ( "[id=\" idBtn_Back\" ]" , null ) ) . Returns ( Task . CompletedTask ) ;
641
- // Wait until login is complete and redirect to desired page
642
- MockPage . Setup ( x => x . WaitForURLAsync ( desiredUrl , null ) ) . Returns ( Task . CompletedTask ) ;
643
-
644
- var playwrightTestInfraFunctions = new PlaywrightTestInfraFunctions ( MockTestState . Object , MockSingleTestInstanceState . Object ,
645
- MockFileSystem . Object , browserContext : MockBrowserContext . Object , page : MockPage . Object ) ;
646
-
647
- await playwrightTestInfraFunctions . HandleUserPasswordScreen ( testSelector , testTextEntry , desiredUrl ) ;
648
-
649
- MockPage . Verify ( x => x . Locator ( It . Is < string > ( v => v . Equals ( testSelector ) ) , null ) ) ;
650
- MockPage . Verify ( x => x . WaitForSelectorAsync ( "[id=\" KmsiCheckboxField\" ]" , It . Is < PageWaitForSelectorOptions > ( v => v . Timeout >= 8000 ) ) ) ;
651
- }
652
-
653
- [ Fact ]
654
- public async Task HandleUserPasswordScreenErrorEntry ( )
655
- {
656
- string testSelector = "input:has-text('Password')" ;
657
- string testTextEntry = "*****" ;
658
- string desiredUrl = "https://make.powerapps.com" ;
659
-
660
- MockSingleTestInstanceState . Setup ( x => x . GetLogger ( ) ) . Returns ( MockLogger . Object ) ;
661
- LoggingTestHelper . SetupMock ( MockLogger ) ;
662
-
663
- var mockLocator = new Mock < ILocator > ( MockBehavior . Strict ) ;
664
- MockPage . Setup ( x => x . Locator ( It . IsAny < string > ( ) , null ) ) . Returns ( mockLocator . Object ) ;
665
- mockLocator . Setup ( x => x . WaitForAsync ( null ) ) . Returns ( Task . CompletedTask ) ;
666
-
667
- MockPage . Setup ( x => x . FillAsync ( testSelector , testTextEntry , null ) ) . Returns ( Task . CompletedTask ) ;
668
- MockPage . Setup ( x => x . ClickAsync ( "input[type=\" submit\" ]" , null ) ) . Returns ( Task . CompletedTask ) ;
669
- // Not ask to sign in as selector not found
670
- MockPage . Setup ( x => x . WaitForSelectorAsync ( "[id=\" KmsiCheckboxField\" ]" , It . IsAny < PageWaitForSelectorOptions > ( ) ) ) . Throws ( new TimeoutException ( ) ) ;
671
- // Simulate error response for password error
672
- MockPage . Setup ( x => x . WaitForSelectorAsync ( "[id=\" passwordError\" ]" , It . IsAny < PageWaitForSelectorOptions > ( ) ) ) . Returns ( Task . FromResult ( MockElementHandle . Object ) ) ;
673
- // Throw exception as not make it to desired url
674
- MockPage . Setup ( x => x . WaitForURLAsync ( desiredUrl , null ) ) . Throws ( new TimeoutException ( ) ) ;
675
-
676
- var playwrightTestInfraFunctions = new PlaywrightTestInfraFunctions ( MockTestState . Object , MockSingleTestInstanceState . Object ,
677
- MockFileSystem . Object , browserContext : MockBrowserContext . Object , page : MockPage . Object ) ;
678
-
679
- await Assert . ThrowsAsync < InvalidOperationException > ( async ( ) => await playwrightTestInfraFunctions . HandleUserPasswordScreen ( testSelector , testTextEntry , desiredUrl ) ) ;
680
-
681
- MockPage . Verify ( x => x . Locator ( It . Is < string > ( v => v . Equals ( testSelector ) ) , null ) ) ;
682
- MockPage . Verify ( x => x . WaitForSelectorAsync ( "[id=\" passwordError\" ]" , It . Is < PageWaitForSelectorOptions > ( v => v . Timeout >= 2000 ) ) ) ;
683
- }
684
-
685
- [ Fact ]
686
- public async Task HandleUserPasswordScreenUnknownError ( )
687
- {
688
- string testSelector = "input:has-text('Password')" ;
689
- string testTextEntry = "*****" ;
690
- string desiredUrl = "https://make.powerapps.com" ;
691
-
692
- MockSingleTestInstanceState . Setup ( x => x . GetLogger ( ) ) . Returns ( MockLogger . Object ) ;
693
- LoggingTestHelper . SetupMock ( MockLogger ) ;
694
-
695
- var mockLocator = new Mock < ILocator > ( MockBehavior . Strict ) ;
696
- MockPage . Setup ( x => x . Locator ( It . IsAny < string > ( ) , null ) ) . Returns ( mockLocator . Object ) ;
697
- mockLocator . Setup ( x => x . WaitForAsync ( null ) ) . Returns ( Task . CompletedTask ) ;
698
-
699
- MockPage . Setup ( x => x . FillAsync ( testSelector , testTextEntry , null ) ) . Returns ( Task . CompletedTask ) ;
700
- MockPage . Setup ( x => x . ClickAsync ( "input[type=\" submit\" ]" , null ) ) . Returns ( Task . CompletedTask ) ;
701
- // Not ask to sign in as selector not found
702
- MockPage . Setup ( x => x . WaitForSelectorAsync ( "[id=\" KmsiCheckboxField\" ]" , null ) ) . Throws ( new TimeoutException ( ) ) ;
703
- // Also not able to find password error, must be some other error
704
- MockPage . Setup ( x => x . WaitForSelectorAsync ( "[id=\" passwordError\" ]" , It . IsAny < PageWaitForSelectorOptions > ( ) ) ) . Throws ( new TimeoutException ( ) ) ;
705
- // Throw exception as not make it to desired url
706
- MockPage . Setup ( x => x . WaitForURLAsync ( desiredUrl , null ) ) . Throws ( new TimeoutException ( ) ) ;
707
-
708
- var playwrightTestInfraFunctions = new PlaywrightTestInfraFunctions ( MockTestState . Object , MockSingleTestInstanceState . Object ,
709
- MockFileSystem . Object , browserContext : MockBrowserContext . Object , page : MockPage . Object ) ;
710
-
711
- await Assert . ThrowsAsync < TimeoutException > ( async ( ) => await playwrightTestInfraFunctions . HandleUserPasswordScreen ( testSelector , testTextEntry , desiredUrl ) ) ;
712
-
713
- MockPage . Verify ( x => x . Locator ( It . Is < string > ( v => v . Equals ( testSelector ) ) , null ) ) ;
714
- }
715
-
716
621
}
717
622
}
0 commit comments