-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/1.0-page-object' into main
Implemented page objects patterns with reporting results.
- Loading branch information
Showing
20 changed files
with
487 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,29 @@ | ||
# cypress-with-patterns | ||
Using Cypress to handle testing implementing Page Objects and | ||
# Cypress.io with Patterns | ||
|
||
Using Cypress to handle automation tests implementing Page Objects and Screenplay patterns. | ||
|
||
## BDD Features with Gherkin | ||
|
||
The goal was to develop automation tests to the simple list app available at http://repo-listing.web.app | ||
|
||
To achieve that, Gherkin features lead the way of thinking the core features of that system. Given/When/Then strategy was used here: | ||
|
||
* [_adicionar.feature_](./features/adicionar.feature) | ||
* [_remover.feature_](./features/remover.feature) | ||
|
||
## Page objects pattern | ||
|
||
Development with this pattern was done under the branch [feature/page-objects](https://github.com/thiagojacinto/cypress-with-patterns/tree/feature/page-objects). | ||
|
||
> Objeto _Home_: | ||
* [support/](./cypress/support) | ||
* [pageObjects/](./cypress/support/pageObjects) | ||
* [Home/](./cypress/support/pageObjects/Home) | ||
* [elements.components.js](./cypress/support/pageObjects/Home/elements.components.js) | ||
* [index.js](./cypress/support/pageObjects/Home/index.js) | ||
|
||
> Testes: | ||
* [integration/](./cypress/integration) | ||
* [page-objects/](./cypress/integration/page-objects) | ||
* [adicionar.spec.js](./cypress/integration/page-objects/adicionar.spec.js) | ||
* [remover.spec.js](./cypress/integration/page-objects/remover.spec.js) |
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,5 +1,16 @@ | ||
{ | ||
"video": false, | ||
"nodeVersion": "system", | ||
"baseUrl": "https://repo-listing.web.app" | ||
"baseUrl": "https://repo-listing.web.app", | ||
"testFiles": "page-objects/**.spec.js", | ||
|
||
"reporter": "mochawesome", | ||
"reporterOptions": { | ||
"reportDir": "results/reports-mochawesome", | ||
"overwrite": false, | ||
"html": false, | ||
"json": true, | ||
"quiet": true, | ||
"charts": true | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/// <reference types="cypress" /> | ||
|
||
import myHome from "../../support/pageObjects/Home" | ||
|
||
describe("Adicionar", () => { | ||
|
||
beforeEach(() => { | ||
cy.viewport("samsung-note9"); | ||
myHome.acessar(); | ||
}); | ||
|
||
it("Adicionar repositório a lista", () => { | ||
myHome.inserir("thiagojacinto/es6-review") | ||
myHome.clicarAdicionar() | ||
myHome.selecionarLista().children().should("contain.text", "es6-review"); | ||
myHome.selecionarItemsDaLista().should("have.length", 1) | ||
}); | ||
|
||
it("Adicionar mais de um repositório", () => { | ||
myHome.inserir("thiagojacinto/es6-review"); | ||
myHome.clicarAdicionar(); | ||
myHome.selecionarItemsDaLista().should("have.length", 1); | ||
myHome.inserir("cypress-io/cypress-example-recipes"); | ||
myHome.clicarAdicionar(); | ||
myHome.selecionarItemsDaLista().should("have.length", 2); | ||
myHome.inserir("rust-lang/rust"); | ||
myHome.clicarAdicionar(); | ||
myHome.selecionarItemsDaLista().should("have.length", 3); | ||
}); | ||
|
||
it('Tentar adicionar sem inserir nome', () => { | ||
myHome.clicarAdicionar(); | ||
myHome.selecionarItemsDaLista().should("have.length", 0); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/// <reference types="cypress" /> | ||
|
||
import myHome from "../../support/pageObjects/Home" | ||
|
||
describe("Remover", () => { | ||
beforeEach(() => { | ||
cy.viewport("iphone-xr"); | ||
}); | ||
|
||
describe("Lista com itens na home", () => { | ||
|
||
beforeEach(() => { | ||
myHome.acessar(); | ||
myHome.popularLista(170); | ||
}); | ||
|
||
it("Remover um dos repositórios da lista", () => { | ||
myHome.removerPrimeiroItem(); | ||
myHome.selecionarItemsDaLista().should("have.length", 2); | ||
}); | ||
|
||
it("Remover mais de um dos repositórios da lista", () => { | ||
myHome.removerPrimeiroItem(); | ||
myHome.removerPrimeiroItem(); | ||
myHome.selecionarItemsDaLista().should("have.length", 1); | ||
}); | ||
|
||
it("Limpar a lista", () => { | ||
myHome.limparLista(); | ||
myHome.selecionarItemsDaLista().should("not.exist"); | ||
}); | ||
}); | ||
|
||
it("Tentar limpar uma lista vazia", () => { | ||
myHome.acessar(); | ||
myHome.limparLista(); | ||
myHome.selecionarItemsDaLista() | ||
.should("not.exist"); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const ELEMENTS = { | ||
input: "input#repository__input", | ||
submitButton: "button#btn__add", | ||
clearButton: "button#btn__clear_all", | ||
unorderedList: "ul#repo__list", | ||
listItems: "ul#repo__list li", | ||
listItemRemoveButton: `[name="btn__remove"]` | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { ELEMENTS } from "./elements.components"; | ||
|
||
class Home { | ||
acessar() { | ||
return cy.visit(""); | ||
} | ||
|
||
inserir(repositorio = "cypress-io/cypress-example-recipes") { | ||
return cy.get(ELEMENTS.input).type(repositorio); | ||
} | ||
|
||
clicarAdicionar() { | ||
return cy.get(ELEMENTS.submitButton).focus().click(); | ||
} | ||
|
||
clicarLimpar() { | ||
return cy.get(ELEMENTS.clearButton).click(); | ||
} | ||
|
||
selecionarLista() { | ||
return cy.get(ELEMENTS.unorderedList, { timeout: 3000 }); | ||
} | ||
|
||
selecionarItemsDaLista() { | ||
return cy.get(ELEMENTS.listItems, { timeout: 3000 }); | ||
} | ||
|
||
selecionarPrimeiroBotaoRemover() { | ||
return this.selecionarItemsDaLista().within(() => { | ||
return cy.get(`[name="btn__remove"]`).first() | ||
}); | ||
} | ||
|
||
removerPrimeiroItem() { | ||
return this.selecionarPrimeiroBotaoRemover().click(); | ||
} | ||
|
||
popularLista(waitFor = 200) { | ||
this.inserir("rust-lang/rust"); | ||
this.clicarAdicionar(); | ||
this.selecionarItemsDaLista().wait(waitFor); | ||
this.inserir("reactjs/reactjs.org"); | ||
this.clicarAdicionar(); | ||
this.selecionarItemsDaLista().wait(waitFor); | ||
this.inserir("thiagojacinto/es6-review"); | ||
this.clicarAdicionar(); | ||
this.selecionarItemsDaLista().wait(waitFor); | ||
} | ||
|
||
limparLista() { | ||
return cy.get(ELEMENTS.clearButton).click(); | ||
} | ||
|
||
} | ||
|
||
export default new Home(); |
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
Binary file not shown.
Binary file not shown.
Oops, something went wrong.