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

mrc-2755 Move error reporting related mutations out of root mutations #611

Merged
merged 16 commits into from Nov 17, 2021

Conversation

Nicolas-Dolan
Copy link
Contributor

@Nicolas-Dolan Nicolas-Dolan commented Nov 12, 2021

Description

Moves error reporting-related state. mutations, and actions from the root module to the errors module so they can be shared with the data exploration mode. To test, check app loads up correctly and no issues with error reporting form.

Type of version change

Patches

Checklist

  • I have incremented version number, or version needs no increment
  • The build passed successfully, or failed because of ADR tests

@codecov
Copy link

codecov bot commented Nov 12, 2021

Codecov Report

Merging #611 (1a399b4) into master (31d1c4a) will increase coverage by 0%.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##             master   #611   +/-   ##
=======================================
  Coverage        98%    98%           
  Complexity      281    281           
=======================================
  Files           202    202           
  Lines          5862   5863    +1     
  Branches        812    812           
=======================================
+ Hits           5766   5767    +1     
  Misses           61     61           
  Partials         35     35           
Impacted Files Coverage Δ
src/app/static/src/app/root.ts 100% <ø> (ø)
...c/src/app/store/dataExploration/dataExploration.ts 100% <ø> (ø)
src/app/static/src/app/store/errors/errors.ts 100% <ø> (ø)
src/app/static/src/app/components/ErrorReport.vue 100% <100%> (ø)
src/app/static/src/app/hintVersion.ts 100% <100%> (ø)
src/app/static/src/app/store/errors/mutations.ts 100% <100%> (ø)
src/app/static/src/app/store/root/actions.ts 100% <100%> (ø)
src/app/static/src/app/store/root/mutations.ts 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31d1c4a...1a399b4. Read the comment docs.

@Nicolas-Dolan Nicolas-Dolan marked this pull request as ready for review November 12, 2021 17:07
@Nicolas-Dolan Nicolas-Dolan requested review from LekanAnni, hillalex, mwoodbri and EmmaLRussell and removed request for mwoodbri November 12, 2021 17:07
import {initialHintrVersionState} from "../../app/store/hintrVersion/hintrVersion";
import {actions} from "../../app/store/errors/actions";
import {ErrorReportManualDetails} from "../../app/store/errors/actions";
import {emptyState} from "../../app/root";

describe(`root actions`, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be error actions now

Copy link
Contributor

@LekanAnni LekanAnni left a comment

Choose a reason for hiding this comment

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

LGTM

Just a minor improvement

needs an update with master

@@ -16,5 +18,15 @@ export const mutations: MutationTree<ErrorsState> = {

[ErrorsMutation.DismissAll](state: ErrorsState, action: PayloadWithType<null>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[ErrorsMutation.DismissAll](state: ErrorsState, action: PayloadWithType<null>) {
[ErrorsMutation.DismissAll](state: ErrorsState) {

Copy link
Contributor

@EmmaLRussell EmmaLRussell left a comment

Choose a reason for hiding this comment

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

I'm getting this error when I submit an error report (from a project with no errors in state, at step 2):

{
  "data": {},
  "status": "failure",
  "errors": [
    {
      "detail": "An unexpected error occurred. If you see this message while you are using Naomi at a workshop, please contact your workshop technical support and show them this code: uro-ers-iqg. Otherwise please contact support at naomi-support@imperial.ac.uk and quote this code: uro-ers-iqg",
      "error": "OTHER_ERROR",
      "trace": [
        "JSON parse error: Instantiation of [simple type, class org.imperial.mrc.hint.models.ErrorReport] value failed for JSON property errors due to missing (therefore NULL) value for creator parameter errors which is a non-nullable type; nested exception is com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class org.imperial.mrc.hint.models.ErrorReport] value failed for JSON property errors due to missing (therefore NULL) value for creator parameter errors which is a non-nullable type\n at [Source: (PushbackInputStream); line: 1, column: 430] (through reference chain: org.imperial.mrc.hint.models.ErrorReport[\"errors\"])"
      ]
    }
  ]
}

Looking at the POSTed data, the `errors' field is indeed missing.

I think this is because the action is using getters.errors to generate the errors field - but this getter has not been moved out of root. So it either needs to use the getter in root, or move it into errors - I think it would probably make for it to stay in root. You should be able to use rootGetters in the context. Should be a test for this too.

const data = {
email: payload.email || rootState.currentUser,
country: rootState.baseline.country || "no associated country",
projectName: rootState.projects.currentProject?.name || "no associated project",
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I'm afraid this needs to remain in root actions, because it won't be re-usable - it references the projects module, which won't exist in the new app.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, so we'll need a separate action to generate the report for data exploration mode. I guess the alternative would be some ugly casting to any to check if state is actually a root state or not (has projects). But if we're going to have a separate dialog component for DE error reporting anyway, cleaner to have that as separate action.

Copy link
Contributor

@hillalex hillalex left a comment

Choose a reason for hiding this comment

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

I think it should only be the mutations and the ErrorReport interface moved out. The actions and getter should remain in root.

Copy link
Contributor

@hillalex hillalex left a comment

Choose a reason for hiding this comment

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

Looks great, thanks

@LekanAnni
Copy link
Contributor

@Nicolas-Dolan It would be nice if this ticket can be merged after update version.

@Nicolas-Dolan
Copy link
Contributor Author

@Nicolas-Dolan It would be nice if this ticket can be merged after update version.

@LekanAnni up to date now

@Nicolas-Dolan Nicolas-Dolan merged commit 581a615 into master Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants