diff --git a/README.md b/README.md
index 669478e..b066b39 100644
--- a/README.md
+++ b/README.md
@@ -131,6 +131,7 @@ npm test
* [Lendo o localStorage do navegador](https://github.com/jalussa-santos/cypress-example/issues/81)
* [Simulando um atraso na chamada à API](https://github.com/jalussa-santos/cypress-example/issues/83)
* [Validando requisições em cache](https://github.com/jalussa-santos/cypress-example/issues/85)
+ * [Análise de código e refatoração com standardjs](https://github.com/jalussa-santos/cypress-example/issues/88)
* **Teste de regressão visual**
diff --git a/cypress/integration/exemploAvancado/hackerNewsSearch.spec.js b/cypress/integration/exemploAvancado/hackerNewsSearch.spec.js
index 7988664..676c599 100644
--- a/cypress/integration/exemploAvancado/hackerNewsSearch.spec.js
+++ b/cypress/integration/exemploAvancado/hackerNewsSearch.spec.js
@@ -1,41 +1,41 @@
describe('Hacker News Search', () => {
- const termo = 'cypress.io'
-
- beforeEach(() => {
- cy.intercept(
- '**/search?query=redux&page=0&hitsPerPage=100',
- { fixture: 'empty'}
- ).as('empty')
- cy.intercept(
+ const termo = 'cypress.io'
+
+ beforeEach(() => {
+ cy.intercept(
+ '**/search?query=redux&page=0&hitsPerPage=100',
+ { fixture: 'empty' }
+ ).as('empty')
+ cy.intercept(
`**/search?query=${termo}&page=0&hitsPerPage=100`,
- { fixture: 'stories'}
- ).as('stories')
-
- cy.visit('https://infinite-savannah-93746.herokuapp.com/')
- cy.wait('@empty')
- })
-
- it('armazena em cache os resultados corretamente', () => {
- const faker = require('faker')
- const palavraRandomica =faker.random.word()
- let count = 0
-
- cy.intercept(`**/search?query=${palavraRandomica}**`, req => {
- count +=1
- req.reply({fixture: 'empty'})
- }).as('random')
-
+ { fixture: 'stories' }
+ ).as('stories')
+
+ cy.visit('https://infinite-savannah-93746.herokuapp.com/')
+ cy.wait('@empty')
+ })
+
+ it('armazena em cache os resultados corretamente', () => {
+ const faker = require('faker')
+ const palavraRandomica = faker.random.word()
+ let count = 0
+
+ cy.intercept(`**/search?query=${palavraRandomica}**`, req => {
+ count += 1
+ req.reply({ fixture: 'empty' })
+ }).as('random')
+
+ cy.search(palavraRandomica).then(() => {
+ expect(count, `network calls to fetch ${palavraRandomica}`).to.equal(1)
+
+ cy.wait('@random')
+
+ cy.search(termo)
+ cy.wait('@stories')
+
cy.search(palavraRandomica).then(() => {
expect(count, `network calls to fetch ${palavraRandomica}`).to.equal(1)
-
- cy.wait('@random')
-
- cy.search(termo)
- cy.wait('@stories')
-
- cy.search(palavraRandomica).then(() => {
- expect(count, `network calls to fetch ${palavraRandomica}`).to.equal(1)
- })
})
})
- })
\ No newline at end of file
+ })
+})
diff --git a/cypress/integration/exemploAvancado/hackerStories.spec.js b/cypress/integration/exemploAvancado/hackerStories.spec.js
index 825fce8..a41ffbc 100644
--- a/cypress/integration/exemploAvancado/hackerStories.spec.js
+++ b/cypress/integration/exemploAvancado/hackerStories.spec.js
@@ -1,8 +1,8 @@
describe('Hacker Stories', () => {
const initialTerm = 'React'
const newTerm = 'Cypress'
-
- context('Chamando a API real',() => {
+
+ context('Chamando a API real', () => {
beforeEach(() => {
cy.intercept({
method: 'GET',
@@ -69,10 +69,9 @@ describe('Hacker Stories', () => {
cy.get(`button:contains(${newTerm})`)
.should('be.visible')
})
+ })
- })
-
- context('Mockando a API',() => {
+ context('Mockando a API', () => {
context('Rodapé e lista de histórias', () => {
beforeEach(() => {
cy.intercept({
@@ -80,23 +79,24 @@ describe('Hacker Stories', () => {
pathname: '**/search',
query: {
query: initialTerm,
- page: '0',
- }},
- {fixture: 'stories'}
+ page: '0'
+ }
+ },
+ { fixture: 'stories' }
).as('getStories')
cy.visit('https://wlsf82-hacker-stories.web.app')
cy.wait('@getStories')
})
-
+
it('shows the footer', () => {
cy.get('footer')
.should('be.visible')
.and('contain', 'Icons made by Freepik from www.flaticon.com')
})
-
+
context('Lista de histórias', () => {
const stories = require('../../fixtures/stories')
- it('mostra os dados corretos para todas as histórias renderizadas', () => {
+ it('mostra os dados corretos para todas as histórias renderizadas', () => {
cy.get('.item')
.first()
.should('be.visible')
@@ -117,121 +117,120 @@ describe('Hacker Stories', () => {
cy.get(`.item a:contains(${stories.hits[1].title})`)
.should('have.attr', 'href', stories.hits[1].url)
})
-
+
it('mostra uma história a menos após descartar a primeira história', () => {
cy.get('.button-small')
.first()
.should('be.visible')
.click()
-
+
cy.get('.item').should('have.length', 1)
})
-
+
context('Ordernar por', () => {
it('Ordernar por título', () => {
cy.get('.list-header-button:contains(Title)')
- .as('titleHeader')
- .should('be.visible')
- .click()
-
- cy.get('.item')
- .first()
- .should('be.visible')
- .and('contain', stories.hits[0].title)
- cy.get(`.item a:contains(${stories.hits[0].title})`)
- .should('have.attr', 'href', stories.hits[0].url)
-
- cy.get('@titleHeader')
- .click()
-
- cy.get('.item')
- .first()
- .should('be.visible')
- .and('contain', stories.hits[1].title)
- cy.get(`.item a:contains(${stories.hits[1].title})`)
- .should('have.attr', 'href', stories.hits[1].url)
- })
+ .as('titleHeader')
+ .should('be.visible')
+ .click()
+
+ cy.get('.item')
+ .first()
+ .should('be.visible')
+ .and('contain', stories.hits[0].title)
+ cy.get(`.item a:contains(${stories.hits[0].title})`)
+ .should('have.attr', 'href', stories.hits[0].url)
+
+ cy.get('@titleHeader')
+ .click()
+
+ cy.get('.item')
+ .first()
+ .should('be.visible')
+ .and('contain', stories.hits[1].title)
+ cy.get(`.item a:contains(${stories.hits[1].title})`)
+ .should('have.attr', 'href', stories.hits[1].url)
+ })
- it('Ordernar por autor', () => {
- cy.get('.list-header-button:contains(Author)')
- .as('authorHeader')
- .should('be.visible')
- .click()
+ it('Ordernar por autor', () => {
+ cy.get('.list-header-button:contains(Author)')
+ .as('authorHeader')
+ .should('be.visible')
+ .click()
- cy.get('.item')
- .first()
- .should('be.visible')
- .and('contain', stories.hits[0].author)
+ cy.get('.item')
+ .first()
+ .should('be.visible')
+ .and('contain', stories.hits[0].author)
- cy.get('@authorHeader')
- .click()
+ cy.get('@authorHeader')
+ .click()
- cy.get('.item')
- .first()
- .should('be.visible')
- .and('contain', stories.hits[1].author)
- })
+ cy.get('.item')
+ .first()
+ .should('be.visible')
+ .and('contain', stories.hits[1].author)
+ })
- it('Ordernar por comentários', () => {
- cy.get('.list-header-button:contains(Comments)')
- .as('commentsHeader')
- .should('be.visible')
- .click()
+ it('Ordernar por comentários', () => {
+ cy.get('.list-header-button:contains(Comments)')
+ .as('commentsHeader')
+ .should('be.visible')
+ .click()
- cy.get('.item')
- .first()
- .should('be.visible')
- .and('contain', stories.hits[1].num_comments)
+ cy.get('.item')
+ .first()
+ .should('be.visible')
+ .and('contain', stories.hits[1].num_comments)
- cy.get('@commentsHeader')
- .click()
+ cy.get('@commentsHeader')
+ .click()
- cy.get('.item')
- .first()
- .should('be.visible')
- .and('contain', stories.hits[0].num_comments)
- })
+ cy.get('.item')
+ .first()
+ .should('be.visible')
+ .and('contain', stories.hits[0].num_comments)
+ })
- it('Ordernar por pontos', () => {
- cy.get('.list-header-button:contains(Points)')
- .as('pointsHeader')
- .should('be.visible')
- .click()
+ it('Ordernar por pontos', () => {
+ cy.get('.list-header-button:contains(Points)')
+ .as('pointsHeader')
+ .should('be.visible')
+ .click()
- cy.get('.item')
- .first()
- .should('be.visible')
- .and('contain', stories.hits[1].points)
+ cy.get('.item')
+ .first()
+ .should('be.visible')
+ .and('contain', stories.hits[1].points)
- cy.get('@pointsHeader')
- .click()
+ cy.get('@pointsHeader')
+ .click()
- cy.get('.item')
- .first()
- .should('be.visible')
- .and('contain', stories.hits[0].points)
+ cy.get('.item')
+ .first()
+ .should('be.visible')
+ .and('contain', stories.hits[0].points)
+ })
})
})
})
- })
context('Pesquisa', () => {
beforeEach(() => {
cy.intercept(
'GET',
`**/search?query=${initialTerm}&page=0`,
- {fixture:'empty'}
+ { fixture: 'empty' }
).as('getEmptyStories')
-
cy.intercept(
'GET',
`**/search?query=${newTerm}&page=0`,
- {fixture:'stories'}
+ { fixture: 'stories' }
).as('getStories')
cy.visit('https://wlsf82-hacker-stories.web.app')
cy.wait('@getEmptyStories')
-
+
cy.get('#search')
.should('be.visible')
.clear()
@@ -240,22 +239,22 @@ describe('Hacker Stories', () => {
it('não mostra nenhuma história quando nenhuma é retornada', () => {
cy.get('.item').should('not.exist')
})
-
+
it('digita e pressiona ENTER', () => {
cy.get('#search')
.should('be.visible')
.type(`${newTerm}{enter}`)
-
+
cy.wait('@getStories')
cy.getLocalStorage('search')
.should('be.equal', newTerm)
-
+
cy.get('.item').should('have.length', 2)
cy.get(`button:contains(${initialTerm})`)
.should('be.visible')
})
-
+
it('digita e clica no botão enviar', () => {
cy.get('#search')
.should('be.visible')
@@ -263,45 +262,44 @@ describe('Hacker Stories', () => {
cy.contains('Submit')
.should('be.visible')
.click()
-
+
cy.wait('@getStories')
cy.getLocalStorage('search')
.should('be.equal', newTerm)
-
+
cy.get('.item').should('have.length', 2)
cy.get(`button:contains(${initialTerm})`)
.should('be.visible')
})
-
+
context('Últimas buscas', () => {
-
it('mostra no máximo 5 botões para os últimos termos pesquisados', () => {
const faker = require('faker')
-
+
cy.intercept(
'GET',
'**/search**',
- {fixture : 'empty'}
+ { fixture: 'empty' }
).as('getRandomStories')
-
+
Cypress._.times(7, () => {
const palavraRandomica = faker.random.word()
-
+
cy.get('#search')
.clear()
.type(`${palavraRandomica}{enter}`)
- cy.wait('@getRandomStories')
+ cy.wait('@getRandomStories')
cy.getLocalStorage('search')
.should('be.equal', palavraRandomica)
})
-
+
cy.get('.last-searches')
.within(() => {
cy.get('button')
.should('have.length', 5)
- })
+ })
})
})
})
@@ -312,48 +310,48 @@ describe('Hacker Stories', () => {
'GET',
'**/search**',
{
- delay:1000,
- fixture:'stories'
+ delay: 1000,
+ fixture: 'stories'
}
- ).as('getAtrasoStories')
+ ).as('getAtrasoStories')
cy.visit('https://wlsf82-hacker-stories.web.app')
-
+
cy.assertLoadingIsShownAndHidden()
cy.wait('@getAtrasoStories')
-
+
cy.get('.item').should('have.length', 2)
})
})
})
- })
+})
context('Erros', () => {
it('Mostra "Algo deu errado ..." em caso de erro do servidor ', () => {
cy.intercept(
'GET',
'**/search**',
- {statusCode: 500}
+ { statusCode: 500 }
).as('getServidorComFalha')
-
+
cy.visit('https://wlsf82-hacker-stories.web.app')
cy.wait('@getServidorComFalha')
cy.get('p:contains(Something went wrong ...)')
- .should('be.visible')
+ .should('be.visible')
})
it('Mostra "Algo deu errado ..." no caso de um erro de rede', () => {
cy.intercept(
'GET',
'**/search**',
- {forceNetworkError: true}
+ { forceNetworkError: true }
).as('getRedeComFalha')
cy.visit('https://wlsf82-hacker-stories.web.app')
cy.wait('@getRedeComFalha')
cy.get('p:contains(Something went wrong ...)')
- .should('be.visible')
+ .should('be.visible')
})
-})
\ No newline at end of file
+})
diff --git a/cypress/integration/exemploBasico/tickets.spec.js b/cypress/integration/exemploBasico/tickets.spec.js
index 204e724..e8b4fc6 100644
--- a/cypress/integration/exemploBasico/tickets.spec.js
+++ b/cypress/integration/exemploBasico/tickets.spec.js
@@ -1,98 +1,96 @@
-describe("Tickets",() =>{
- beforeEach(() => cy.visit("https://ticket-box.s3.eu-central-1.amazonaws.com/index.html"));
-
-
- it("Preencher todos os campos de texto",()=>{
-
- const firstName = "Teste";
- const lastName = "Cypress";
-
- cy.get('#first-name').type(firstName);
- cy.get("#last-name").type(lastName);
- cy.get("#email").type("testecypress@testes.com.br");
- cy.get("#requests").type("testes123");
- cy.get("#signature").type(`${firstName} ${lastName}`);
- });
-
- it("Selecionar 2 tickets",() => {
- cy.get("#ticket-quantity").select("2");
- });
-
- it("Selecionando tipo de ticket 'vip'",() =>{
- cy.get("#vip").check();
- });
-
- it("Selecionar 'social media' checkbox",() =>{
- cy.get("#social-media").check();
- });
-
- it("Selecionar 'friend' e 'publication, e desmarcar 'friend'",() =>{
- cy.get("#friend").check();
- cy.get("#publication").check();
- cy.get("#friend").uncheck();
- });
-
- it("Contém 'TICKETBOX' no header",() =>{
- cy.get("header h1").should("contain","TICKETBOX")
- });
-
- it("Existe/Não Existe alerta para e-mail inválido", () => {
- cy.get("#email")
- .as("email")
- .type("teste-gmail.com");
-
- cy.get("#email.invalid").should("exist");
-
- cy.get("@email")
- .clear()
- .type("teste@gmail.com");
-
- cy.get("#email.invalid").should("not.exist");
- });
-
- it("Preencher e resetar formulário", () => {
- const firstName = "Teste";
- const lastName = "Cypress";
- const fullname = `${firstName} ${lastName}`;
-
- cy.get('#first-name').type(firstName);
- cy.get("#last-name").type(lastName);
- cy.get("#email").type("testecypress@testes.com.br");
- cy.get("#ticket-quantity").select("2");
- cy.get("#vip").check();
- cy.get("#friend").check();
- cy.get("#requests").type("testes123");
-
- cy.get(".agreement p")
- .should("contain", `I, ${fullname}, wish to buy 2 VIP tickets.`);
-
- cy.get("#agree").click();
- cy.get("#signature").type(fullname);
-
- cy.get("button[type='submit']")
- .as("submitButton")
- .should("not.be.disabled");
-
- cy.get("button[type='reset']").click();
-
- cy.get("@submitButton").should("be.disabled");
- });
-
- it("Preenche campos obrigatórios com comandos customizados", () => {
- const customer = {
- firstName: "João",
- lastName: "Silva",
- email: "joaosilva@example.com"
- };
-
- cy.preencheCamposObrigatorios(customer);
-
- cy.get("button[type='submit']")
- .as("submitButton")
- .should("not.be.disabled");
-
- cy.get("#agree").uncheck();
-
- cy.get("@submitButton").should("be.disabled");
- });
-});
\ No newline at end of file
+describe('Tickets', () => {
+ beforeEach(() => cy.visit('https://ticket-box.s3.eu-central-1.amazonaws.com/index.html'))
+
+ it('Preencher todos os campos de texto', () => {
+ const firstName = 'Teste'
+ const lastName = 'Cypress'
+
+ cy.get('#first-name').type(firstName)
+ cy.get('#last-name').type(lastName)
+ cy.get('#email').type('testecypress@testes.com.br')
+ cy.get('#requests').type('testes123')
+ cy.get('#signature').type(`${firstName} ${lastName}`)
+ })
+
+ it('Selecionar 2 tickets', () => {
+ cy.get('#ticket-quantity').select('2')
+ })
+
+ it("Selecionando tipo de ticket 'vip'", () => {
+ cy.get('#vip').check()
+ })
+
+ it("Selecionar 'social media' checkbox", () => {
+ cy.get('#social-media').check()
+ })
+
+ it("Selecionar 'friend' e 'publication, e desmarcar 'friend'", () => {
+ cy.get('#friend').check()
+ cy.get('#publication').check()
+ cy.get('#friend').uncheck()
+ })
+
+ it("Contém 'TICKETBOX' no header", () => {
+ cy.get('header h1').should('contain', 'TICKETBOX')
+ })
+
+ it('Existe/Não Existe alerta para e-mail inválido', () => {
+ cy.get('#email')
+ .as('email')
+ .type('teste-gmail.com')
+
+ cy.get('#email.invalid').should('exist')
+
+ cy.get('@email')
+ .clear()
+ .type('teste@gmail.com')
+
+ cy.get('#email.invalid').should('not.exist')
+ })
+
+ it('Preencher e resetar formulário', () => {
+ const firstName = 'Teste'
+ const lastName = 'Cypress'
+ const fullname = `${firstName} ${lastName}`
+
+ cy.get('#first-name').type(firstName)
+ cy.get('#last-name').type(lastName)
+ cy.get('#email').type('testecypress@testes.com.br')
+ cy.get('#ticket-quantity').select('2')
+ cy.get('#vip').check()
+ cy.get('#friend').check()
+ cy.get('#requests').type('testes123')
+
+ cy.get('.agreement p')
+ .should('contain', `I, ${fullname}, wish to buy 2 VIP tickets.`)
+
+ cy.get('#agree').click()
+ cy.get('#signature').type(fullname)
+
+ cy.get("button[type='submit']")
+ .as('submitButton')
+ .should('not.be.disabled')
+
+ cy.get("button[type='reset']").click()
+
+ cy.get('@submitButton').should('be.disabled')
+ })
+
+ it('Preenche campos obrigatórios com comandos customizados', () => {
+ const customer = {
+ firstName: 'João',
+ lastName: 'Silva',
+ email: 'joaosilva@example.com'
+ }
+
+ cy.preencheCamposObrigatorios(customer)
+
+ cy.get("button[type='submit']")
+ .as('submitButton')
+ .should('not.be.disabled')
+
+ cy.get('#agree').uncheck()
+
+ cy.get('@submitButton').should('be.disabled')
+ })
+})
diff --git a/cypress/integration/exemploIntermediario/api/createIssue.spec.js b/cypress/integration/exemploIntermediario/api/createIssue.spec.js
index aec3b49..6c56fdb 100644
--- a/cypress/integration/exemploIntermediario/api/createIssue.spec.js
+++ b/cypress/integration/exemploIntermediario/api/createIssue.spec.js
@@ -1,17 +1,17 @@
///
-const faker = require('faker');
+const faker = require('faker')
describe('Criar Issue', () => {
- it('sucesso', ()=>{
- const issue = {
- title: `issue-${faker.random.uuid()}`,
- description: faker.random.words(3),
-
- project: {
- name: `project-${faker.random.uuid()}`,
- description: faker.random.words(5)
- }
+ it('sucesso', () => {
+ const issue = {
+ title: `issue-${faker.random.uuid()}`,
+ description: faker.random.words(3),
+
+ project: {
+ name: `project-${faker.random.uuid()}`,
+ description: faker.random.words(5)
+ }
}
cy.api_createIssue(issue)
@@ -19,6 +19,6 @@ describe('Criar Issue', () => {
expect(response.status).to.equal(201)
expect(response.body.title).to.equal(issue.title)
expect(response.body.description).to.equal(issue.description)
- })
- })
-});
\ No newline at end of file
+ })
+ })
+})
diff --git a/cypress/integration/exemploIntermediario/api/createProject.spec.js b/cypress/integration/exemploIntermediario/api/createProject.spec.js
index 446dac4..4057918 100644
--- a/cypress/integration/exemploIntermediario/api/createProject.spec.js
+++ b/cypress/integration/exemploIntermediario/api/createProject.spec.js
@@ -1,19 +1,19 @@
///
-const faker = require('faker');
+const faker = require('faker')
describe('Criar Projeto', () => {
- it('sucesso', ()=>{
+ it('sucesso', () => {
const project = {
- name: `project-${faker.random.uuid()}`,
- description: faker.random.words(5)
+ name: `project-${faker.random.uuid()}`,
+ description: faker.random.words(5)
}
-
+
cy.api_createProject(project)
.then(response => {
expect(response.status).to.equal(201)
expect(response.body.name).to.equal(project.name)
expect(response.body.description).to.equal(project.description)
- });
-});
-});
\ No newline at end of file
+ })
+ })
+})
diff --git a/cypress/integration/exemploIntermediario/cli/gitClone.spec.js b/cypress/integration/exemploIntermediario/cli/gitClone.spec.js
index da9fc7f..6b6512a 100644
--- a/cypress/integration/exemploIntermediario/cli/gitClone.spec.js
+++ b/cypress/integration/exemploIntermediario/cli/gitClone.spec.js
@@ -17,4 +17,4 @@ describe('Clonar repositório git', () => {
.should('contain', `# ${project.name}`)
.and('contain', project.description)
})
-})
\ No newline at end of file
+})
diff --git a/cypress/integration/exemploIntermediario/gui/createIssue.spec.js b/cypress/integration/exemploIntermediario/gui/createIssue.spec.js
index 1a2c247..12d1a42 100644
--- a/cypress/integration/exemploIntermediario/gui/createIssue.spec.js
+++ b/cypress/integration/exemploIntermediario/gui/createIssue.spec.js
@@ -1,28 +1,28 @@
///
-const faker = require('faker');
+const faker = require('faker')
describe('Criar Issue', () => {
- const issue = {
- title: `issue-${faker.random.uuid()}`,
- description: faker.random.words(3),
+ const issue = {
+ title: `issue-${faker.random.uuid()}`,
+ description: faker.random.words(3),
- project: {
- name: `project-${faker.random.uuid()}`,
- description: faker.random.words(5)
- }
+ project: {
+ name: `project-${faker.random.uuid()}`,
+ description: faker.random.words(5)
}
+ }
- before(() => {
- cy.login()
- cy.api_createProject(issue.project)
- });
+ before(() => {
+ cy.login()
+ cy.api_createProject(issue.project)
+ })
- it('sucesso', ()=>{
- cy.gui_createIssue(issue);
+ it('sucesso', () => {
+ cy.gui_createIssue(issue)
cy.get('.issue-details')
- .should('contain',issue.title)
- .and('contain',issue.description)
- })
-});
\ No newline at end of file
+ .should('contain', issue.title)
+ .and('contain', issue.description)
+ })
+})
diff --git a/cypress/integration/exemploIntermediario/gui/createProject.spec.js b/cypress/integration/exemploIntermediario/gui/createProject.spec.js
index eeead38..fd1e802 100644
--- a/cypress/integration/exemploIntermediario/gui/createProject.spec.js
+++ b/cypress/integration/exemploIntermediario/gui/createProject.spec.js
@@ -1,19 +1,19 @@
///
-const faker = require('faker');
+const faker = require('faker')
describe('Criar Projeto', () => {
- before(() => cy.login());
+ before(() => cy.login())
- it('sucesso', ()=>{
+ it('sucesso', () => {
const project = {
- name: `project-${faker.random.uuid()}`,
- description: faker.random.words(5)
+ name: `project-${faker.random.uuid()}`,
+ description: faker.random.words(5)
}
- cy.gui_createProject(project);
- cy.url().should('be.equal',`${Cypress.config('baseUrl')}${Cypress.env('user_name')}/${project.name}`);
- cy.contains(project.name).should('be.visible');
- cy.contains(project.description).should('be.visible');
- });
-});
\ No newline at end of file
+ cy.gui_createProject(project)
+ cy.url().should('be.equal', `${Cypress.config('baseUrl')}${Cypress.env('user_name')}/${project.name}`)
+ cy.contains(project.name).should('be.visible')
+ cy.contains(project.description).should('be.visible')
+ })
+})
diff --git a/cypress/integration/exemploIntermediario/gui/login.spec.js b/cypress/integration/exemploIntermediario/gui/login.spec.js
index 0dcb62e..2dde980 100644
--- a/cypress/integration/exemploIntermediario/gui/login.spec.js
+++ b/cypress/integration/exemploIntermediario/gui/login.spec.js
@@ -1,9 +1,9 @@
///
describe('Login', () => {
- it('sucesso', () => {
- cy.login();
+ it('sucesso', () => {
+ cy.login()
- cy.get('.qa-user-avatar').should('exist');
- })
-});
\ No newline at end of file
+ cy.get('.qa-user-avatar').should('exist')
+ })
+})
diff --git a/cypress/integration/exemploIntermediario/gui/logout.spec.js b/cypress/integration/exemploIntermediario/gui/logout.spec.js
index 7511d3f..37686cc 100644
--- a/cypress/integration/exemploIntermediario/gui/logout.spec.js
+++ b/cypress/integration/exemploIntermediario/gui/logout.spec.js
@@ -1,12 +1,11 @@
///
describe('Logout', () => {
+ beforeEach(() => cy.login())
- beforeEach(() => cy.login());
+ it('sucesso', () => {
+ cy.logout()
- it('sucesso', () => {
- cy.logout();
-
- cy.url().should('be.equal',`${Cypress.config('baseUrl')}users/sign_in`);
- })
-});
\ No newline at end of file
+ cy.url().should('be.equal', `${Cypress.config('baseUrl')}users/sign_in`)
+ })
+})
diff --git a/cypress/integration/exemploIntermediario/gui/setLabelOnissue.spec.js b/cypress/integration/exemploIntermediario/gui/setLabelOnissue.spec.js
index ce304ca..6430144 100644
--- a/cypress/integration/exemploIntermediario/gui/setLabelOnissue.spec.js
+++ b/cypress/integration/exemploIntermediario/gui/setLabelOnissue.spec.js
@@ -1,38 +1,36 @@
///
-const faker = require('faker');
+const faker = require('faker')
describe('Setar label na issue', () => {
-
- const issue = {
- title: `issue-${faker.random.uuid()}`,
- description: faker.random.words(3),
- project: {
- name: `project-${faker.random.uuid()}`,
- description: faker.random.words(5)
- }
- }
-
- const label = {
- name: `label-${faker.random.word()}`,
- color: '#ffaabb'
- }
+ const issue = {
+ title: `issue-${faker.random.uuid()}`,
+ description: faker.random.words(3),
+ project: {
+ name: `project-${faker.random.uuid()}`,
+ description: faker.random.words(5)
+ }
+ }
- beforeEach(() => {
- cy.login()
- cy.api_createIssue(issue)
- .then(response => {
- cy.api_createLabel(response.body.project_id, label)
- cy.visit(`${Cypress.env('user_name')}/${issue.project.name}/issues/${response.body.iid}`)
- })
- });
+ const label = {
+ name: `label-${faker.random.word()}`,
+ color: '#ffaabb'
+ }
-
- it('Com sucesso', () => {
- cy.gui_setLabelOnIssue(label)
-
- cy.get('.qa-labels-block').should('contain', label.name)
- cy.get('.qa-labels-block span')
- .should('have.attr', 'style', `background-color: ${label.color}; color: #333333;`)
- });
-});
\ No newline at end of file
+ beforeEach(() => {
+ cy.login()
+ cy.api_createIssue(issue)
+ .then(response => {
+ cy.api_createLabel(response.body.project_id, label)
+ cy.visit(`${Cypress.env('user_name')}/${issue.project.name}/issues/${response.body.iid}`)
+ })
+ })
+
+ it('Com sucesso', () => {
+ cy.gui_setLabelOnIssue(label)
+
+ cy.get('.qa-labels-block').should('contain', label.name)
+ cy.get('.qa-labels-block span')
+ .should('have.attr', 'style', `background-color: ${label.color}; color: #333333;`)
+ })
+})
diff --git a/cypress/integration/exemploIntermediario/gui/setMilestoneOnIssue.spec.js b/cypress/integration/exemploIntermediario/gui/setMilestoneOnIssue.spec.js
index c084f2c..87f1c09 100644
--- a/cypress/integration/exemploIntermediario/gui/setMilestoneOnIssue.spec.js
+++ b/cypress/integration/exemploIntermediario/gui/setMilestoneOnIssue.spec.js
@@ -30,4 +30,4 @@ describe('Inserindo milestone na issue', () => {
cy.get('.block.milestone').should('contain', milestone.title)
})
-})
\ No newline at end of file
+})
diff --git a/cypress/integration/exemploTesteRegressaoVisualPercy/ticketBox.spec.js b/cypress/integration/exemploTesteRegressaoVisualPercy/ticketBox.spec.js
index 01aa7d2..daeea5e 100644
--- a/cypress/integration/exemploTesteRegressaoVisualPercy/ticketBox.spec.js
+++ b/cypress/integration/exemploTesteRegressaoVisualPercy/ticketBox.spec.js
@@ -1,49 +1,49 @@
describe('Ticketbox', () => {
- beforeEach(() => cy.visit("https://ticket-box.s3.eu-central-1.amazonaws.com/index.html"));
- it('Checar o estado inicial da aplicação', () => {
- cy.percySnapshot();
- });
+ beforeEach(() => cy.visit('https://ticket-box.s3.eu-central-1.amazonaws.com/index.html'))
+ it('Checar o estado inicial da aplicação', () => {
+ cy.percySnapshot()
+ })
- it('Checar estado com e-mail inválido', () => {
- cy.get('#email').type('teste.com');
- cy.percySnapshot();
- });
+ it('Checar estado com e-mail inválido', () => {
+ cy.get('#email').type('teste.com')
+ cy.percySnapshot()
+ })
- it('Checar estado com todos os campos obrigatórios preenchidos', () => {
- const customer = {
- firstName: "João",
- lastName: "Silva",
- email: "joaosilva@example.com"
- };
+ it('Checar estado com todos os campos obrigatórios preenchidos', () => {
+ const customer = {
+ firstName: 'João',
+ lastName: 'Silva',
+ email: 'joaosilva@example.com'
+ }
- cy.preencheCamposObrigatorios(customer);
- cy.percySnapshot();
- });
+ cy.preencheCamposObrigatorios(customer)
+ cy.percySnapshot()
+ })
- it('Checar estado com nome completo, quantidade de tickets e tipo preenchidos', () => {
- const customer = {
- firstName: "João",
- lastName: "Silva",
- };
+ it('Checar estado com nome completo, quantidade de tickets e tipo preenchidos', () => {
+ const customer = {
+ firstName: 'João',
+ lastName: 'Silva'
+ }
- cy.get('#first-name').type(customer.firstName);
- cy.get("#last-name").type(customer.lastName);
- cy.get("#ticket-quantity").select("2");
- cy.get("#vip").check();
- cy.percySnapshot();
- });
+ cy.get('#first-name').type(customer.firstName)
+ cy.get('#last-name').type(customer.lastName)
+ cy.get('#ticket-quantity').select('2')
+ cy.get('#vip').check()
+ cy.percySnapshot()
+ })
- const sucessoEnvioFormulario = 'Checar mensagem de sucesso ao enviar formulário'
- it(sucessoEnvioFormulario, () => {
- const customer = {
- firstName: "João",
- lastName: "Silva",
- email: "joaosilva@example.com"
- };
+ const sucessoEnvioFormulario = 'Checar mensagem de sucesso ao enviar formulário'
+ it(sucessoEnvioFormulario, () => {
+ const customer = {
+ firstName: 'João',
+ lastName: 'Silva',
+ email: 'joaosilva@example.com'
+ }
- cy.preencheCamposObrigatorios(customer);
- cy.percySnapshot(sucessoEnvioFormulario, {
- percyCSS: `.success span { display: none; }`
- })
- });
-});
\ No newline at end of file
+ cy.preencheCamposObrigatorios(customer)
+ cy.percySnapshot(sucessoEnvioFormulario, {
+ percyCSS: '.success span { display: none; }'
+ })
+ })
+})
diff --git a/cypress/integration/exemploTesteRegressaoVisualPlugin/ticketBox_Plugin.spec.js b/cypress/integration/exemploTesteRegressaoVisualPlugin/ticketBox_Plugin.spec.js
index 202f8e4..d465a93 100644
--- a/cypress/integration/exemploTesteRegressaoVisualPlugin/ticketBox_Plugin.spec.js
+++ b/cypress/integration/exemploTesteRegressaoVisualPlugin/ticketBox_Plugin.spec.js
@@ -1,11 +1,8 @@
describe('Ticketbox', () => {
-
- beforeEach(() => cy.visit("https://ticket-box.s3.eu-central-1.amazonaws.com/index.html"));
+ beforeEach(() => cy.visit('https://ticket-box.s3.eu-central-1.amazonaws.com/index.html'))
it.only('Checar estado com e-mail inválido', () => {
-
- cy.get('#email').type('teste@teste.com');
- cy.document().toMatchImageSnapshot();
- });
-
-});
\ No newline at end of file
+ cy.get('#email').type('teste@teste.com')
+ cy.document().toMatchImageSnapshot()
+ })
+})
diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js
index 6069cb6..57367f9 100644
--- a/cypress/plugins/index.js
+++ b/cypress/plugins/index.js
@@ -21,9 +21,9 @@ module.exports = (on, config) => {
// `config` is the resolved Cypress config
}
-const { initPlugin } = require('cypress-plugin-snapshots/plugin');
+const { initPlugin } = require('cypress-plugin-snapshots/plugin')
module.exports = (on, config) => {
- initPlugin(on, config);
- return config;
-}
\ No newline at end of file
+ initPlugin(on, config)
+ return config
+}
diff --git a/cypress/support/commandsExemploAvancado/commands.js b/cypress/support/commandsExemploAvancado/commands.js
index d6390eb..af3f543 100644
--- a/cypress/support/commandsExemploAvancado/commands.js
+++ b/cypress/support/commandsExemploAvancado/commands.js
@@ -1,13 +1,13 @@
import 'cypress-localstorage-commands'
Cypress.Commands.add('assertLoadingIsShownAndHidden', () => {
- cy.contains('Loading ...').should('be.visible')
- cy.contains('Loading ...').should('not.exist')
- })
+ cy.contains('Loading ...').should('be.visible')
+ cy.contains('Loading ...').should('not.exist')
+})
- Cypress.Commands.add('search', term => {
- cy.get('input[type="text"]')
- .should('be.visible')
- .clear()
- .type(`${term}{enter}`)
- })
\ No newline at end of file
+Cypress.Commands.add('search', term => {
+ cy.get('input[type="text"]')
+ .should('be.visible')
+ .clear()
+ .type(`${term}{enter}`)
+})
diff --git a/cypress/support/commandsExemploBasico/commands.js b/cypress/support/commandsExemploBasico/commands.js
index 9ef78c7..51ae2d8 100644
--- a/cypress/support/commandsExemploBasico/commands.js
+++ b/cypress/support/commandsExemploBasico/commands.js
@@ -24,9 +24,9 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
-Cypress.Commands.add("preencheCamposObrigatorios", data => {
- cy.get('#first-name').type(data.firstName);
- cy.get("#last-name").type(data.lastName);
- cy.get("#email").type(data.email);
- cy.get("#agree").check();
-});
\ No newline at end of file
+Cypress.Commands.add('preencheCamposObrigatorios', data => {
+ cy.get('#first-name').type(data.firstName)
+ cy.get('#last-name').type(data.lastName)
+ cy.get('#email').type(data.email)
+ cy.get('#agree').check()
+})
diff --git a/cypress/support/commandsExemploIntermediario/api_commands.js b/cypress/support/commandsExemploIntermediario/api_commands.js
index 3601bcf..960c92c 100644
--- a/cypress/support/commandsExemploIntermediario/api_commands.js
+++ b/cypress/support/commandsExemploIntermediario/api_commands.js
@@ -15,16 +15,16 @@ Cypress.Commands.add('api_createProject', project => {
})
Cypress.Commands.add('api_createIssue', issue => {
- cy.api_createProject(issue.project)
- .then(response => {
- cy.request({
- method: 'POST',
- url: `/api/v4/projects/${response.body.id}/issues?private_token=${accessToken}`,
- body: {
- title: issue.title,
- description: issue.description
- }
- })
+ cy.api_createProject(issue.project)
+ .then(response => {
+ cy.request({
+ method: 'POST',
+ url: `/api/v4/projects/${response.body.id}/issues?private_token=${accessToken}`,
+ body: {
+ title: issue.title,
+ description: issue.description
+ }
+ })
})
})
@@ -45,4 +45,4 @@ Cypress.Commands.add('api_createMilestone', (projectId, milestone) => {
url: `/api/v4/projects/${projectId}/milestones?private_token=${accessToken}`,
body: { title: milestone.title }
})
-})
\ No newline at end of file
+})
diff --git a/cypress/support/commandsExemploIntermediario/cli_commands.js b/cypress/support/commandsExemploIntermediario/cli_commands.js
index a836abc..34297bc 100644
--- a/cypress/support/commandsExemploIntermediario/cli_commands.js
+++ b/cypress/support/commandsExemploIntermediario/cli_commands.js
@@ -1,7 +1,7 @@
///
Cypress.Commands.add('cloneViaHttp', project => {
- const domain = Cypress.config('baseUrl').replace('http://', '').replace('/', '')
-
- cy.exec(`cd temp/ && git clone http://${domain}/${Cypress.env('user_name')}/${project.name}.git`)
- })
\ No newline at end of file
+ const domain = Cypress.config('baseUrl').replace('http://', '').replace('/', '')
+
+ cy.exec(`cd temp/ && git clone http://${domain}/${Cypress.env('user_name')}/${project.name}.git`)
+})
diff --git a/cypress/support/commandsExemploIntermediario/gui_commands.js b/cypress/support/commandsExemploIntermediario/gui_commands.js
index a5c6d2c..54199df 100644
--- a/cypress/support/commandsExemploIntermediario/gui_commands.js
+++ b/cypress/support/commandsExemploIntermediario/gui_commands.js
@@ -1,41 +1,41 @@
///
-Cypress.Commands.add('login',() =>{
- cy.visit('users/sign_in');
- cy.get('[data-qa-selector="login_field"]').type(Cypress.env('user_name'));
- cy.get('[data-qa-selector="password_field"]').type(Cypress.env('user_password'));
- cy.get('[data-qa-selector="sign_in_button"]').click();
-});
-
-Cypress.Commands.add('logout',() =>{
- cy.get('.qa-user-avatar').click();
- cy.contains('Sign out').click();
-});
-
-Cypress.Commands.add('gui_createProject',project => {
- cy.visit('projects/new');
-
- cy.get('#project_name').type(project.name);
- cy.get('#project_description').type(project.description);
- cy.get('.qa-initialize-with-readme-checkbox').check();
- cy.contains('Create project').click();
-});
+Cypress.Commands.add('login', () => {
+ cy.visit('users/sign_in')
+ cy.get('[data-qa-selector="login_field"]').type(Cypress.env('user_name'))
+ cy.get('[data-qa-selector="password_field"]').type(Cypress.env('user_password'))
+ cy.get('[data-qa-selector="sign_in_button"]').click()
+})
+
+Cypress.Commands.add('logout', () => {
+ cy.get('.qa-user-avatar').click()
+ cy.contains('Sign out').click()
+})
+
+Cypress.Commands.add('gui_createProject', project => {
+ cy.visit('projects/new')
+
+ cy.get('#project_name').type(project.name)
+ cy.get('#project_description').type(project.description)
+ cy.get('.qa-initialize-with-readme-checkbox').check()
+ cy.contains('Create project').click()
+})
Cypress.Commands.add('gui_createIssue', issue => {
- cy.visit(`${Cypress.env('user_name')}/${issue.project.name}/issues/new`)
-
- cy.get('.qa-issuable-form-title').type(issue.title)
- cy.get('.qa-issuable-form-description').type(issue.description)
- cy.contains('Submit issue').click()
- });
-
- Cypress.Commands.add('gui_setLabelOnIssue', label => {
- cy.get('.qa-edit-link-labels').click()
- cy.contains(label.name).click()
- cy.get('body').click()
- })
-
- Cypress.Commands.add('gui_setMilestoneOnIssue', milestone => {
- cy.get('.block.milestone .edit-link').click()
- cy.contains(milestone.title).click()
- })
\ No newline at end of file
+ cy.visit(`${Cypress.env('user_name')}/${issue.project.name}/issues/new`)
+
+ cy.get('.qa-issuable-form-title').type(issue.title)
+ cy.get('.qa-issuable-form-description').type(issue.description)
+ cy.contains('Submit issue').click()
+})
+
+Cypress.Commands.add('gui_setLabelOnIssue', label => {
+ cy.get('.qa-edit-link-labels').click()
+ cy.contains(label.name).click()
+ cy.get('body').click()
+})
+
+Cypress.Commands.add('gui_setMilestoneOnIssue', milestone => {
+ cy.get('.block.milestone .edit-link').click()
+ cy.contains(milestone.title).click()
+})
diff --git a/cypress/support/index.js b/cypress/support/index.js
index 5cf5f76..7c5d6f3 100644
--- a/cypress/support/index.js
+++ b/cypress/support/index.js
@@ -3,5 +3,5 @@ import './commandsExemploIntermediario/gui_commands'
import './commandsExemploIntermediario/api_commands'
import './commandsExemploIntermediario/cli_commands'
import './commandsExemploAvancado/commands'
-import '@percy/cypress';
-import 'cypress-plugin-snapshots/commands'
\ No newline at end of file
+import '@percy/cypress'
+import 'cypress-plugin-snapshots/commands'