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
e2e: Proposal Create mock structure. #2676
e2e: Proposal Create mock structure. #2676
Conversation
@victorgcramos can you review this pr? |
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.
records/v1/new
endpoint mock looks good, mate. Thanks! Left some inline comments.
Good to remind that mocking the records/new endpoint does not close the full issue, as It expected the whole proposal/create flow to be mocked so we don't need to be connected to the backend.
teste2e/cypress/support/core/api.js
Outdated
export function newRecordSummaryReply({ requestParams: { tokens = [] } }) { | ||
const summaries = tokens.reduce((sum, token) => { | ||
sum[token] = { status: "unvetted" }; | ||
return sum; | ||
}, {}); | ||
return { summaries }; | ||
} |
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.
records summaries does not exist. Could you remove it, please?
import { | ||
PROPOSAL_SUMMARY_STATUS_ACTIVE, | ||
PROPOSAL_SUMMARY_STATUS_UNVETTED | ||
} from "../../utils"; |
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.
Unused variables
@@ -336,6 +339,8 @@ const ProposalForm = React.memo(function ProposalForm({ | |||
)} | |||
<SelectField | |||
name="domain" | |||
id="domain-selector" | |||
dataTestid="domain-selector" |
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.
is this used elsewhere?
This commit adds the `verifyIdentity` option to user login and me requests, and improves the proposal create tests to avoid reaching any backend endpoints.
Improvements for Proposal Create mock
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.
Looking better now. Tests are working as expected, and thanks for adding an extra test case.
I have some small observations regarding the test cases descriptions: they should start with "should". Left one inline suggestion regarding it, which you should replicate for all test cases you create.
Left some other inline suggestions 😁
cy.findByRole("button", { name: /submit/i }).click(); | ||
// needs more time in general to complete this request so we increase the | ||
// responseTimeout | ||
cy.wait("@newProposal", { timeout: 10000 }).should((xhr) => { |
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.
try using cy.wait("@records.new")
instead, and see if you can decrease this timeout. 10s timeout is too much.
@@ -336,6 +337,7 @@ const ProposalForm = React.memo(function ProposalForm({ | |||
)} | |||
<SelectField | |||
name="domain" | |||
id="domain-selector" |
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.
id="domain-selector" | |
id="proposal-domain-selector" |
teste2e/cypress/support/commands.js
Outdated
@@ -149,22 +158,24 @@ Cypress.Commands.add("approveProposal", ({ token }) => | |||
Cypress.Commands.add("typeCreateProposal", (proposal) => { | |||
cy.server(); | |||
cy.findByTestId("proposal-name").type(proposal.name); | |||
cy.findByTestId("text-area").type(proposal.description); | |||
cy.findByTestId("proposal-amount").type(String(proposal.amount / 100)); // get dollars from cents. |
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.
Prettier: 80 max char per line.
teste2e/cypress/support/core/api.js
Outdated
@@ -101,7 +101,32 @@ export function detailsReply({ | |||
return { record }; | |||
} | |||
|
|||
/** | |||
* newRecordReply is the reply to the new command. It returns a new record for the | |||
* request data with given `files`, `publickey`, `signature` and `author` testParams. |
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.
The parameters from this replier doc is different from the replier's parameters.
teste2e/cypress/support/core/api.js
Outdated
@@ -1,4 +1,4 @@ | |||
import { Record, File, Inventory } from "./generate"; | |||
import { Record, File, Inventory, Proposal } from "./generate"; |
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.
Proposal
is never used and does not exist on generate scope.
describe("Proposal Create", () => { | ||
// XXX This test needs changes in the Datepicker and (probably) the Select | ||
// components, in order to fill the new form fields such as: start & end dates | ||
// and amount - issue to track <insert issue link> | ||
// | ||
/*it("Paid user can create proposals manually", () => { | ||
it("Paid user can create proposals manually", () => { |
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.
it("Paid user can create proposals manually", () => { | |
it("should be able to create proposals", () => { |
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.
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.
Looking really good. Left just one minor inline comment, and we should be good to go! Nice job @vibros68
publickey: user.publickey, | ||
signature, | ||
publickey: publickey || user.publickey, | ||
recordSignature, |
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.
Noticed some issues here. RecordMetadata has no recordSignature
field. Actually, it's signature
. Also, the signature should have a default value.
@@ -15,7 +15,7 @@ describe("Proposal Create", () => { | |||
// components, in order to fill the new form fields such as: start & end dates | |||
// and amount - issue to track <insert issue link> | |||
// | |||
it("Paid user can create proposals manually", () => { | |||
it("should be able to create proposals", () => { |
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.
it("should be able to create proposals", () => { | |
it("should allow paid user to create proposals", () => { |
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.
tACK!
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.
LGTM
Closes #2644
This diff create mock data for
record/new
endpoint. So when creatingproposal e2e test is running. The test will not send the request to the
server. And complete the e2e test for creating normal proposal. Include
select domain and pickup datepickers