Skip to content

Commit eb04e43

Browse files
committed
✅ Add login form validation test
1 parent 5716537 commit eb04e43

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
describe("Page Login", function() {
2+
let $emailField, $passwordField, $submitButton;
3+
4+
before(function() {
5+
cy.visit("/auth/login");
6+
$emailField = cy.get("label[for=email]");
7+
$passwordField = cy.get("label[for=password]");
8+
$submitButton = cy.get("button[content=Entrar]");
9+
});
10+
11+
it("Verify if exist the fields: E-mail and Password", function() {
12+
$emailField.contains("E-mail:").get("input[name=email]");
13+
$passwordField.contains("Senha:").get("input[name=password]");
14+
});
15+
16+
it("Send form without filling in the inputs", function() {
17+
$submitButton.click();
18+
19+
$emailField.get("span:last-of-type").contains("E-mail é obrigatório");
20+
$passwordField.get("span:last-of-type").contains("Senha é obrigatória");
21+
});
22+
23+
it("Send form with email invalid", function() {
24+
$emailField.get("input[name=email]").type("santiael");
25+
26+
$submitButton.click();
27+
28+
$emailField.get("span:last-of-type").contains("Preencha com email válido");
29+
});
30+
31+
it("Send form with password invalid", function() {
32+
$passwordField.get("input[name=password]").type("1234567");
33+
34+
$submitButton.click();
35+
$passwordField
36+
.get("span:last-of-type")
37+
.contains("Senha tem que ter 8 ou mais caracteres");
38+
});
39+
40+
it("Send form with all fields valid", function() {
41+
$emailField.get("input[name=email]").type("rafaelsantiagods@gmail.com");
42+
$passwordField.get("input[name=password]").type("12345678");
43+
44+
$submitButton.click();
45+
46+
$emailField.get("span").should("have.length", 1);
47+
$passwordField.get("span").should("have.length", 1);
48+
});
49+
});

0 commit comments

Comments
 (0)