Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
frontend
Commits
f869d05e
Commit
f869d05e
authored
10 months ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
add login to error data
parent
3001bc4e
No related branches found
No related tags found
2 merge requests
!223
reset the pin numbers before search results are fetch (so the results will be...
,
!199
Resolve "[MIN-321] form for reporting errors in minerva"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utils/error-report/errorReporting.test.ts
+32
-0
32 additions, 0 deletions
src/utils/error-report/errorReporting.test.ts
src/utils/error-report/errorReporting.ts
+8
-1
8 additions, 1 deletion
src/utils/error-report/errorReporting.ts
with
40 additions
and
1 deletion
src/utils/error-report/errorReporting.test.ts
+
32
−
0
View file @
f869d05e
/* eslint-disable no-magic-numbers */
import
{
createErrorData
}
from
'
@/utils/error-report/errorReporting
'
;
import
{
apiPath
}
from
'
@/redux/apiPath
'
;
import
{
HttpStatusCode
}
from
'
axios
'
;
import
{
loginFixture
}
from
'
@/models/fixtures/loginFixture
'
;
import
{
userPrivilegesFixture
}
from
'
@/models/fixtures/userPrivilegesFixture
'
;
import
{
login
}
from
'
@/redux/user/user.thunks
'
;
import
{
mockNetworkResponse
}
from
'
@/utils/mockNetworkResponse
'
;
import
{
store
}
from
'
@/redux/store
'
;
const
mockedAxiosClient
=
mockNetworkResponse
();
const
CREDENTIALS
=
{
login
:
'
test
'
,
password
:
'
password
'
,
};
describe
(
'
createErrorData
'
,
()
=>
{
it
(
'
should add stacktrace
'
,
()
=>
{
const
error
=
createErrorData
(
new
Error
(
'
hello
'
));
expect
(
error
.
stacktrace
).
not
.
toEqual
(
''
);
});
it
(
'
should add url
'
,
()
=>
{
const
error
=
createErrorData
(
new
Error
(
'
hello
'
));
expect
(
error
.
url
).
not
.
toBeNull
();
});
it
(
'
should add guest login when not logged
'
,
()
=>
{
const
error
=
createErrorData
(
new
Error
(
'
hello
'
));
expect
(
error
.
login
).
toBe
(
'
anonymous
'
);
});
it
(
'
should add login when logged
'
,
async
()
=>
{
mockedAxiosClient
.
onPost
(
apiPath
.
postLogin
()).
reply
(
HttpStatusCode
.
Ok
,
loginFixture
);
mockedAxiosClient
.
onGet
(
apiPath
.
userPrivileges
(
loginFixture
.
login
))
.
reply
(
HttpStatusCode
.
Ok
,
userPrivilegesFixture
);
await
store
.
dispatch
(
login
(
CREDENTIALS
));
const
error
=
createErrorData
(
new
Error
(
'
hello
'
));
expect
(
error
.
login
).
not
.
toBe
(
'
anonymous
'
);
expect
(
error
.
login
).
toBe
(
loginFixture
.
login
);
});
});
This diff is collapsed.
Click to expand it.
src/utils/error-report/errorReporting.ts
+
8
−
1
View file @
f869d05e
/* eslint-disable no-console */
import
{
ErrorData
}
from
'
@/utils/error-report/ErrorData
'
;
import
{
SerializedError
}
from
'
@reduxjs/toolkit
'
;
// eslint-disable-next-line import/no-cycle
import
{
store
}
from
'
@/redux/store
'
;
export
const
createErrorData
=
(
error
:
Error
|
SerializedError
|
undefined
):
ErrorData
=>
{
let
stacktrace
=
''
;
...
...
@@ -8,9 +10,14 @@ export const createErrorData = (error: Error | SerializedError | undefined): Err
stacktrace
=
error
.
stack
!==
undefined
?
error
.
stack
:
''
;
}
let
{
login
}
=
store
.
getState
().
user
;
if
(
!
login
)
{
login
=
'
anonymous
'
;
}
const
errorData
:
ErrorData
=
{
url
:
window
.
location
.
href
,
login
:
null
,
// TODO provide user login
login
,
browser
:
null
,
// TODO
comment
:
null
,
email
:
null
,
// TODO
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment