Просмотр исходного кода

Merge pull request #14565 from overleaf/jpa-add-error-context

[web] add response context to errors of failed logout/login action in CI

GitOrigin-RevId: 9b2e23e243541f87476f8cc71687f9492f615b4d
Jakob Ackermann 3 лет назад
Родитель
Сommit
3d9e9f6aeb
1 измененных файлов с 17 добавлено и 3 удалено
  1. 17 3
      services/web/test/acceptance/src/helpers/UserHelper.js

+ 17 - 3
services/web/test/acceptance/src/helpers/UserHelper.js

@@ -142,7 +142,14 @@ class UserHelper {
       response.status !== 302 ||
       !response.headers.get('location').includes('/login')
     ) {
-      throw new Error('logout failed')
+      const body = await response.text()
+      throw new Error(
+        `logout failed: status=${response.status} body=${JSON.stringify(
+          body
+        )} headers=${JSON.stringify(
+          Object.fromEntries(response.headers.entries())
+        )}`
+      )
     }
     // after logout CSRF token becomes invalid
     this._csrfToken = ''
@@ -258,14 +265,21 @@ class UserHelper {
       }),
     })
     if (!response.ok) {
-      const error = new Error('login failed')
+      const body = await response.text()
+      const error = new Error(
+        `login failed: status=${response.status} body=${JSON.stringify(body)}`
+      )
       error.response = response
       throw error
     }
 
     const body = await response.json()
     if (body.redir !== '/project') {
-      const error = new Error('login failed')
+      const error = new Error(
+        `login should redirect to /project: status=${
+          response.status
+        } body=${JSON.stringify(body)}`
+      )
       error.response = response
       throw error
     }