Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e: Proposal Create mock structure.
- Loading branch information
Showing
11 changed files
with
166 additions
and
52 deletions.
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
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
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,41 +1,69 @@ | ||
import { buildProposal } from "../../support/generate"; | ||
|
||
beforeEach(function mockApiCalls() { | ||
// currently mocking pi and ticketvote summaries calls with any status, since | ||
// they aren't used for assertions. | ||
cy.useTicketvoteApi(); | ||
cy.useRecordsApi(); | ||
cy.usePiApi(); | ||
cy.useWwwApi(); | ||
cy.useCommentsApi(); | ||
}); | ||
|
||
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("should allow paid user to create proposals", () => { | ||
// paid user with proposal credits | ||
const user = { | ||
email: "adminuser@example.com", | ||
username: "adminuser", | ||
password: "password" | ||
}; | ||
cy.userEnvironment("user", { verifyIdentity: true }); | ||
const proposal = buildProposal(); | ||
cy.login(user); | ||
cy.visit("/"); | ||
cy.identity(); | ||
cy.recordsMiddleware("new", {}); | ||
cy.visit("/record/new"); | ||
cy.typeCreateProposal(proposal); | ||
});*/ | ||
cy.findByRole("button", { name: /submit/i }).click(); | ||
// needs more time in general to complete this request so we increase the | ||
// responseTimeout | ||
cy.wait("@newProposal").should((xhr) => { | ||
expect(xhr.status).to.equal(200); | ||
cy.piMiddleware("summaries", { amountByStatus: { unvetted: 1 } }); | ||
const token = xhr.response.body.record.censorshiprecord.token; | ||
cy.assertProposalPage({ | ||
...proposal, | ||
token: token | ||
}); | ||
cy.wait("@pi.summaries", { timeout: 500 }); | ||
cy.findByTestId("record-title").should("have.text", proposal.name); | ||
}); | ||
}); | ||
|
||
it("Non-paid user can not create proposals", () => { | ||
const user = { | ||
email: "user3@example.com", | ||
username: "user3", | ||
password: "password" | ||
}; | ||
cy.login(user); | ||
it("should not be able to create proposals without fill the input", () => { | ||
// paid user with proposal credits | ||
cy.userEnvironment("user", { verifyIdentity: true }); | ||
cy.recordsMiddleware("new", {}); | ||
cy.visit("/record/new"); | ||
cy.findByRole("button", { name: /submit/i }).click(); | ||
cy.findByTestId("proposal-name").parent().find("p").contains("Required"); | ||
cy.findByTestId("proposal-amount").parent().find("p").contains("Required"); | ||
cy.get("[data-testid=datepicker]:eq(0)") | ||
.find("p") | ||
.contains("Please pick a start date"); | ||
cy.get("[data-testid=datepicker]:eq(1)") | ||
.find("p") | ||
.contains("Please pick an end date"); | ||
}); | ||
|
||
it("should not be able create proposals with non-paid user", () => { | ||
cy.userEnvironment("unpaid", { verifyIdentity: true }); | ||
cy.visit("/"); | ||
cy.findByText(/new proposal/i).should("be.disabled"); | ||
const proposal = buildProposal(); | ||
cy.visit("/record/new"); | ||
cy.typeCreateProposal(proposal); | ||
cy.findByText( | ||
/you won't be able to submit comments or proposals before paying the paywall/i | ||
).should("be.visible"); | ||
const proposal = buildProposal(); | ||
cy.findByTestId("proposal-name").should("be.visible").type(proposal.name); | ||
cy.findByTestId("text-area").type(proposal.description); | ||
cy.findByRole("button", { name: /submit/i }).should("be.disabled"); | ||
}); | ||
}); |
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
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
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
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
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
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
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
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