Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: 348 make Playwright detect 500s #358

Conversation

myieye
Copy link
Contributor

@myieye myieye commented Oct 31, 2023

Resolves #348
Resolves #349

Status code handling is further improved in a draft PR (#357) that is waiting for this one to be merged.

Here's what the output looks like for the tests that were getting 500s. It's still a lot to parse, but at least there's a 500 in there:

EmailWorkflowTests.RegisterVerifyUpdateVerifyEmailAdress

[xUnit.net 00:00:40.47] Testing.Browser.EmailWorkflowTests.RegisterVerifyUpdateVerifyEmailAdre ss [FAIL] Failed Testing.Browser.EmailWorkflowTests.RegisterVerifyUpdateVerifyEmailAdress [37 s] Error Message: System.AggregateException : One or more errors occurred. (Timeout 30000ms exceeded. =========================== logs =========================== waiting for navigation to "/user" until "NetworkIdle" ============================================================) (One or more errors occurred. (Unexp ected response: Internal Server Error (500). URL: http://localhost/api/login/verifyEmail?jwt=***** &returnTo=%2Fuser%3FemailResult%3DverifiedEmail&email=54fb1b67-e426-4367-928a-f863514b1159@mailina tor.com.)) ---- System.TimeoutException : Timeout 30000ms exceeded. =========================== logs =========================== waiting for navigation to "/user" until "NetworkIdle" ============================================================ -------- System.TimeoutException : Timeout 30000ms exceeded. ---- System.AggregateException : One or more errors occurred. (Unexpected response: Internal Serve r Error (500). URL: http://localhost/api/login/verifyEmail?jwt=*****&returnTo=%2Fuser%3FemailResul t%3DverifiedEmail&[email protected].) -------- Testing.Browser.Base.UnexpectedResponseException : Unexpected response: Internal Server E rror (500). URL: http://localhost/api/login/verifyEmail?jwt=*****&returnTo=%2Fuser%3FemailResult%3 DverifiedEmail&[email protected]. Stack Trace:

----- Inner Stack Trace #1 (System.TimeoutException) -----
at Microsoft.Playwright.Core.Waiter.WaitForPromiseAsync[T](Task1 task, Action dispose) in /_/s rc/Playwright/Core/Waiter.cs:line 219 at Microsoft.Playwright.Core.Frame.WaitForNavigationInternalAsync(Waiter waiter, String url, Fu nc2 urlFunc, Regex urlRegex, String urlString, Nullable1 waitUntil) in /_/src/Playwright/Core/Fr ame.cs:line 257 at Microsoft.Playwright.Core.Frame.RunAndWaitForNavigationAsync(Func1 action, FrameRunAndWaitF
orNavigationOptions options) in //src/Playwright/Core/Frame.cs:line 225
at Testing.Browser.Page.BasePage1.WaitFor() in D:\code\languageforge-lexbox\backend\Testing\Br owser\Page\BasePage.cs:line 39 at Testing.Browser.EmailWorkflowTests.RegisterVerifyUpdateVerifyEmailAdress() in D:\code\langua geforge-lexbox\backend\Testing\Browser\EmailWorkflowTests.cs:line 31 at Testing.Browser.EmailWorkflowTests.RegisterVerifyUpdateVerifyEmailAdress() in D:\code\langua geforge-lexbox\backend\Testing\Browser\EmailWorkflowTests.cs:line 63 --- End of stack trace from previous location --- ----- Inner Stack Trace ----- at Microsoft.Playwright.Helpers.TaskHelper.<>c__DisplayClass2_0.<WithTimeout>b__0() in /_/src/P laywright/Helpers/TaskHelper.cs:line 73 at Microsoft.Playwright.Helpers.TaskHelper.WithTimeout(Task task, Func1 timeoutAction, TimeSpa
n timeout, CancellationToken cancellationToken) in /
/src/Playwright/Helpers/TaskHelper.cs:line 10
9
at Microsoft.Playwright.Core.Waiter.WaitForPromiseAsync[T](Task`1 task, Action dispose) in /_/s
rc/Playwright/Core/Waiter.cs:line 211
----- Inner Stack Trace #2 (System.AggregateException) -----
at Testing.Browser.Base.PageTest.DisposeAsync() in D:\code\languageforge-lexbox\backend\Testing
\Browser\Base\PageTest.cs:line 91
----- Inner Stack Trace -----

EmailWorkflowTests.ForgotPassword

[xUnit.net 00:00:43.78] Testing.Browser.EmailWorkflowTests.ForgotPassword [FAIL] Failed Testing.Browser.EmailWorkflowTests.ForgotPassword [40 s] Error Message: System.AggregateException : One or more errors occurred. (response.Status should be 200 but was 403

Additional Info:
code was 403 (Forbidden)) (One or more errors occurred. (Unexpected response: Internal Server
Error (500). URL: http://localhost/api/login/resetPassword.))
---- Shouldly.ShouldAssertException : response.Status
should be
200
but was
403

Additional Info:
code was 403 (Forbidden)
---- System.AggregateException : One or more errors occurred. (Unexpected response: Internal Serve
r Error (500). URL: http://localhost/api/login/resetPassword.)
-------- Testing.Browser.Base.UnexpectedResponseException : Unexpected response: Internal Server E
rror (500). URL: http://localhost/api/login/resetPassword.
Stack Trace:

----- Inner Stack Trace #1 (Shouldly.ShouldAssertException) -----
at Testing.Browser.Util.HttpUtils.ExecuteGql(IPage page, String gql, Boolean expectGqlError) in
D:\code\languageforge-lexbox\backend\Testing\Browser\Util\HttpUtils.cs:line 16
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task tas
k)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Testing.Browser.Page.TempUserDashboardPage.DisposeAsync() in D:\code\languageforge-lexbox\ba
ckend\Testing\Browser\Page\TempUserDashboardPage.cs:line 17
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task tas
k)
at Testing.Browser.EmailWorkflowTests.ForgotPassword() in D:\code\languageforge-lexbox\backend
Testing\Browser\EmailWorkflowTests.cs:line 96
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task tas
k)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task tas
k)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task tas
k)
----- Inner Stack Trace #2 (System.AggregateException) -----
at Testing.Browser.Base.PageTest.DisposeAsync() in D:\code\languageforge-lexbox\backend\Testing
\Browser\Base\PageTest.cs:line 91
----- Inner Stack Trace -----

Here's the error dialog that will now be shown if "Reset password" gets a 500 response:
image

@github-actions
Copy link

github-actions bot commented Oct 31, 2023

UI unit Tests

1 tests  ±0   1 ✔️ ±0   0s ⏱️ ±0s
1 suites ±0   0 💤 ±0 
1 files   ±0   0 ±0 

Results for commit def31a5. ± Comparison against base commit 08f4ee1.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 31, 2023

C# Unit Tests

34 tests   34 ✔️  13s ⏱️
  6 suites    0 💤
  1 files      0

Results for commit def31a5.

♻️ This comment has been updated with latest results.

@myieye myieye force-pushed the test/348-write-playwright-test-that-verifies-an-error-is-shown-when-the-server-returns-a-500 branch from f5eb31b to 6a7f17e Compare October 31, 2023 10:40
@myieye myieye marked this pull request as ready for review October 31, 2023 10:42
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, I like storing the errors and throwing them later if none were expected.

backend/Testing/Browser/Base/PageTest.cs Outdated Show resolved Hide resolved
backend/Testing/Browser/Base/PageTest.cs Outdated Show resolved Hide resolved
backend/Testing/Browser/Base/PageTest.cs Outdated Show resolved Hide resolved
@myieye myieye force-pushed the test/348-write-playwright-test-that-verifies-an-error-is-shown-when-the-server-returns-a-500 branch 2 times, most recently from 2f9d07e to eb1eb4a Compare November 2, 2023 10:21
@myieye myieye force-pushed the test/348-write-playwright-test-that-verifies-an-error-is-shown-when-the-server-returns-a-500 branch from eb1eb4a to def31a5 Compare November 6, 2023 10:47
@myieye myieye merged commit 0c2097f into develop Nov 6, 2023
11 checks passed
@myieye myieye deleted the test/348-write-playwright-test-that-verifies-an-error-is-shown-when-the-server-returns-a-500 branch November 6, 2023 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants