-
Notifications
You must be signed in to change notification settings - Fork 2
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-443 Added uploadANC front end #38
Conversation
src/app/static/src/app/main.ts
Outdated
@@ -14,7 +14,7 @@ export interface RootState { | |||
} | |||
|
|||
export interface StepState { | |||
complete: boolean | |||
complete: () => boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered if this would work better as a function, since it's likely to be a value derived from other properties in the state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work? I don't think the function will be automatically executed when the underlying data changes. This could/should be tested by instantiating the component with incomplete data, then triggering the action/mutation which makes the stage complete, then checking whether the continue button is enabled.
It looks like vue does have a concept of "getters" aka computed properties for the store which I think are what you're after here: https://vuex.vuejs.org/guide/getters.html
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
===========================================
+ Coverage 96.46% 96.7% +0.24%
Complexity 73 73
===========================================
Files 51 51
Lines 565 607 +42
Branches 55 62 +7
===========================================
+ Hits 545 587 +42
Misses 15 15
Partials 5 5
Continue to review full report at Codecov.
|
@@ -49,8 +53,10 @@ export function testUploadComponent(name: string, position: number) { | |||
|
|||
const successState = name == "survey" ? { | |||
survey: response | |||
} : { | |||
} : name =="program" ? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a switch statement would be more readable here now! And above
src/app/static/src/app/main.ts
Outdated
@@ -14,7 +14,7 @@ export interface RootState { | |||
} | |||
|
|||
export interface StepState { | |||
complete: boolean | |||
complete: () => boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work? I don't think the function will be automatically executed when the underlying data changes. This could/should be tested by instantiating the component with incomplete data, then triggering the action/mutation which makes the stage complete, then checking whether the continue button is enabled.
It looks like vue does have a concept of "getters" aka computed properties for the store which I think are what you're after here: https://vuex.vuejs.org/guide/getters.html
I've tried using getters, which turned out to be slightly painful, primarily because I couldn't get mapGetters to work (compile kept failing as it wouldn't recognise the mapped getters as computed properties). Updated Babel to no avail. Possible that this is a bug and related to the fact that we're using modules. There's an open PR which may be relevant. vuejs/vuex#1121 |
mutations.PJNZUploaded(testState, {payload: mockPJNZResponse({data: {country: "Malawi"}}), type: "PJNZLoaded"}); | ||
expect(testState.complete()).toBe(true); | ||
|
||
expect(complete(testState, null, testRootState, null)).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getters really needs four parameters, but ours only use the first one!
…onnection rather than openStream
return url.openStream().use { | ||
|
||
val conn = url.openConnection() as HttpURLConnection | ||
return BufferedReader(InputStreamReader(conn.getInputStream())).use { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holy hell, this was annoying. This randomly started throwing errors when running locally, when attempting to use the blameless ValidateInputResponse schema (it was claiming the schema was invalid). Eventually worked out it appeared to always fail at the same character index, so presumably it wasn't managing to read the whole file over a certain length). Changing from url.openStream to url.openConnection seemed to fix this...
I regenerated the types from HINTR, as latest master is now returning different response to before (errors as array rather than object). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, what a faff, sorry! If it's any consolation I really like the use of getters here, I think it does make things easier to reason about
@@ -111,4 +114,23 @@ describe("Stepper component", () => { | |||
expect(steps.at(1).props().active).toBe(true); | |||
}); | |||
|
|||
it("updates from completed state when active step data is populated", (done) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 🙌
No description provided.