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-443 Added uploadANC front end #38

Merged
merged 6 commits into from
Sep 4, 2019
Merged

mrc-443 Added uploadANC front end #38

merged 6 commits into from
Sep 4, 2019

Conversation

EmmaLRussell
Copy link
Contributor

No description provided.

@@ -14,7 +14,7 @@ export interface RootState {
}

export interface StepState {
complete: boolean
complete: () => boolean
Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link

codecov bot commented Sep 3, 2019

Codecov Report

Merging #38 into master will increase coverage by 0.24%.
The diff coverage is 100%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
src/app/static/src/app/store/baseline/mutations.ts 100% <ø> (ø) 0 <0> (ø) ⬇️
src/app/static/src/app/main.ts 100% <ø> (ø) 0 <0> (ø) ⬇️
...in/kotlin/org/imperial/mrc/hint/models/Response.kt 100% <100%> (ø) 0 <0> (ø) ⬇️
...static/src/app/store/surveyAndProgram/mutations.ts 100% <100%> (ø) 0 <0> (ø) ⬇️
src/app/static/src/app/apiService.ts 100% <100%> (ø) 0 <0> (ø) ⬇️
src/app/static/src/app/store/baseline/baseline.ts 100% <100%> (ø) 0 <0> (ø) ⬇️
src/app/static/src/app/components/Stepper.vue 100% <100%> (ø) 0 <0> (ø) ⬇️
...c/tests/components/surveyAndProgram/fileUploads.ts 100% <100%> (ø) 0 <0> (ø) ⬇️
...p/static/src/app/store/surveyAndProgram/actions.ts 100% <100%> (ø) 0 <0> (ø) ⬇️
...src/app/store/surveyAndProgram/surveyAndProgram.ts 100% <100%> (ø) 0 <0> (ø) ⬇️
... and 1 more

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 91f449e...e5b42b0. Read the comment docs.

@@ -49,8 +53,10 @@ export function testUploadComponent(name: string, position: number) {

const successState = name == "survey" ? {
survey: response
} : {
} : name =="program" ? {
Copy link
Contributor

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

@@ -14,7 +14,7 @@ export interface RootState {
}

export interface StepState {
complete: boolean
complete: () => boolean
Copy link
Contributor

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

@EmmaLRussell
Copy link
Contributor Author

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
Would require declaring further interfaces. Anyway, I worked around it, but not sure how much it adds really!

mutations.PJNZUploaded(testState, {payload: mockPJNZResponse({data: {country: "Malawi"}}), type: "PJNZLoaded"});
expect(testState.complete()).toBe(true);

expect(complete(testState, null, testRootState, null)).toBe(true);
Copy link
Contributor Author

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!

return url.openStream().use {

val conn = url.openConnection() as HttpURLConnection
return BufferedReader(InputStreamReader(conn.getInputStream())).use {
Copy link
Contributor Author

@EmmaLRussell EmmaLRussell Sep 4, 2019

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...

@EmmaLRussell
Copy link
Contributor Author

I regenerated the types from HINTR, as latest master is now returning different response to before (errors as array rather than object).

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.

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice 🙌

@hillalex hillalex merged commit d4ec0fd into master Sep 4, 2019
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.

2 participants