-
Notifications
You must be signed in to change notification settings - Fork 4
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
James crt test updates #195
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6523ebb
update feeling thermometer text
JamesPHoughton cc3a24b
fix slider over anchoring
JamesPHoughton aceedc4
update test
JamesPHoughton 66eb3ab
Merge branch 'main' into james-feelingThermometerUpdates
JamesPHoughton a5061d0
Update scoring and labels
JamesPHoughton ab5c9be
Update package.json
JamesPHoughton a97aa75
Merge branch 'main' into james-feelingThermometerUpdates
JamesPHoughton e12f45b
Merge branch 'james-fix-RME-scoring'
JamesPHoughton 791925f
Merge branch 'main' into james-fix-RME-scoring
JamesPHoughton 201e64c
merge main
JamesPHoughton dba87b1
Delete screenshot.png
JamesPHoughton b1cd62b
update screenshots
JamesPHoughton c1bf245
Update CRT test
JamesPHoughton 3fbc4d8
Merge branch 'main' of https://github.com/Watts-Lab/surveys
JamesPHoughton 01e7c49
Merge branch 'main' into james-fix-CRT-Test
JamesPHoughton 04044b3
Update CRT test
amirrr 2f6997b
Add failing test
amirrr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,64 @@ | ||
import React from "react"; | ||
import { CRT } from "../../src/index"; | ||
|
||
const surveyJsonPath = "surveys/CRT/CRT.json"; | ||
|
||
// Initialize an empty answers object | ||
|
||
const dummy = { | ||
set(response) {}, | ||
}; | ||
|
||
describe("RMETTen", () => { | ||
it("completes the survey", () => { | ||
describe("CRT", () => { | ||
it("fail if not entered correctly", () => { | ||
cy.spy(dummy, "set").as("callback"); | ||
cy.mount(<CRT onComplete={dummy.set} />); | ||
cy.viewport("macbook-11"); | ||
|
||
cy.readFile(surveyJsonPath).then((surveyJson) => { | ||
surveyJson.pages.forEach((page) => { | ||
page.elements.forEach((element) => { | ||
const numberToEnter = 15; | ||
cy.get('[data-name="drill_hammer"] input[type="number"]').type(15); // correct | ||
cy.get('[data-name="rachel"] input[type="number"]').type(19); // correct | ||
cy.get('[data-name="toaster"] input[type="number"]').type(125); // correct | ||
cy.get('[data-name="apples"] input[type="number"]').type(-3); // wrong | ||
cy.get('[data-name="eggs"] input[type="number"]').type("cat"); // wrong | ||
cy.get('[data-name="dog_cat"] input[type="number"]').type(100000000000); // wrong | ||
|
||
cy.get( | ||
`[data-name="${element.name}"] input[type="${element.inputType}"]` | ||
).type(numberToEnter); | ||
|
||
cy.get( | ||
`[data-name="${element.name}"] input[type="${element.inputType}"]` | ||
).should("have.value", numberToEnter.toString()); | ||
}); | ||
cy.get("form") // submit surveyJS form | ||
.then(($form) => { | ||
cy.wrap($form.find('input[type="button"][value="Complete"]')).click(); | ||
}); | ||
|
||
cy.screenshot("CRT/screenshot", { | ||
overwrite: true, | ||
}); | ||
cy.get(".sv-body").should("exist"); | ||
|
||
cy.get("@callback").should("not.have.been.called"); | ||
}); | ||
|
||
it("completes the survey", () => { | ||
cy.spy(dummy, "set").as("callback"); | ||
cy.mount(<CRT onComplete={dummy.set} />); | ||
cy.viewport("macbook-11"); | ||
|
||
cy.get("form") // submit surveyJS form | ||
.then(($form) => { | ||
cy.wrap($form.find('input[type="button"][value="Complete"]')).click(); | ||
}); | ||
cy.get('[data-name="drill_hammer"] input[type="number"]').type(15); // correct | ||
cy.get('[data-name="rachel"] input[type="number"]').type(19); // correct | ||
cy.get('[data-name="toaster"] input[type="number"]').type(125); // correct | ||
cy.get('[data-name="apples"] input[type="number"]').type(-3); // wrong | ||
cy.get('[data-name="eggs"] input[type="number"]').type(10); // wrong | ||
cy.get('[data-name="dog_cat"] input[type="number"]').type(100000000000); // wrong | ||
|
||
cy.get(".sv-body").should("not.exist"); | ||
cy.screenshot("CRT/screenshot", { | ||
overwrite: true, | ||
}); | ||
|
||
cy.get("@callback").should("have.been.called"); | ||
cy.get("@callback").then((spy) => { | ||
const spyCall = spy.getCall(-1).args[0]; | ||
console.log(spyCall); | ||
expect(spyCall["result"]["score"]).to.eq(2.0); | ||
cy.get("form") // submit surveyJS form | ||
.then(($form) => { | ||
cy.wrap($form.find('input[type="button"][value="Complete"]')).click(); | ||
}); | ||
|
||
cy.get(".sv-body").should("not.exist"); | ||
|
||
cy.get("@callback").should("have.been.called"); | ||
cy.get("@callback").then((spy) => { | ||
const spyCall = spy.getCall(-1).args[0]; | ||
console.log(spyCall); | ||
expect(spyCall["result"]["score"]).to.eq(3); | ||
expect(spyCall["result"]["normScore"]).to.eq((0.5).toFixed(3)); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You are typing a string into a number field and still getting completion? That shouldn't be possible. I can see from the screenshot also that the field is empty when the test inputs
cat
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.
In other words, this part of the test should fail?