-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from suissa/develop
Develop - Cypress new test pattern for all
- Loading branch information
Showing
24 changed files
with
3,582 additions
and
1,303 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 |
---|---|---|
|
@@ -35,4 +35,5 @@ yarn-error.log* | |
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
src/config.ts | ||
cypress/screenshots |
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,47 +1,53 @@ | ||
describe("Página de Empresas", () => { | ||
// const ENV = "development" | ||
const ENV = "production" | ||
const BASE_URL_DEV = "http://localhost" | ||
const BASE_URL_PROD = "http://137.184.81.207" | ||
const BASE_URL = ENV == "development" ? BASE_URL_DEV : BASE_URL_PROD | ||
const LOGIN_URL = `${BASE_URL}:9000/login` | ||
const API_URL = `${BASE_URL}:9000/companies` | ||
const TEST_URL = `${BASE_URL}:3000/companies` | ||
const BUTTON = "Nova Empresa" | ||
const ENTITY = { _id: "1", name: "Empresa 1", phone: "123456789", status: "Ativo", dueDate: "16/01/2024", recurrence: "Mensal"} | ||
const ENTITY_PLURAL_NAME = "Mensagens" | ||
const TEST_NAME = `Página de ${ENTITY_PLURAL_NAME}` | ||
|
||
describe(TEST_NAME, () => { | ||
beforeEach(() => { | ||
|
||
cy.fixture("token").then((token) => { | ||
console.log(token); | ||
cy.intercept("POST", "http://137.184.81.207:9000/login", { | ||
cy.intercept("POST", `${LOGIN_URL}`, { | ||
statusCode: 200, | ||
body: { | ||
token: token.token | ||
} | ||
body: { token: token.token } | ||
}); | ||
|
||
cy.intercept("GET", "http://137.184.81.207:9000/companies", { | ||
cy.intercept("GET", `${API_URL}`, { | ||
statusCode: 200, | ||
body: [ | ||
{ _id: "1", name: "Empresa 1", phone: "123456789", status: "Ativo", dueDate: "16/01/2024", recurrence: "Mensal"}, | ||
] | ||
}).as("getCompanies"); | ||
body: [ ENTITY ] | ||
}).as("getPlans"); | ||
|
||
localStorage.setItem("token", token.token); | ||
cy.visit("http://137.184.81.207:3000/companies"); | ||
|
||
cy.wait("@getCompanies"); | ||
cy.visit(`${TEST_URL}`); | ||
}) | ||
|
||
}); | ||
|
||
it("deve exibir uma lista de empresas", () => { | ||
it(`deve exibir uma lista de ${ENTITY_PLURAL_NAME}`, () => { | ||
cy.get("table").should("exist"); | ||
cy.get("table tbody tr").should("have.length.at.least", 1); | ||
}); | ||
|
||
it("deve mudar da tabela para o formulário ao clicar em Nova Empresa", () => { | ||
cy.get("button").contains("Nova Empresa").click(); | ||
it(`deve mudar da tabela para o formulário ao clicar em ${BUTTON}`, () => { | ||
cy.get("button").contains(BUTTON).click(); | ||
cy.get("form").should("exist"); | ||
cy.get("table").should("not.exist"); | ||
}); | ||
|
||
it("deve mudar do formulário para a tabela ao clicar em Cancelar", () => { | ||
cy.get("button").contains("Nova Empresa").click(); | ||
cy.get("button").contains(BUTTON).click(); | ||
cy.get("form").should("exist"); | ||
cy.get("table").should("not.exist"); | ||
cy.get("button").contains("Cancelar").click(); | ||
cy.get("table").should("exist"); | ||
cy.get("form").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 |
---|---|---|
@@ -1,49 +1,53 @@ | ||
describe("Página de Conexões", () => { | ||
beforeEach(() => { | ||
// const ENV = "development" | ||
const ENV = "production" | ||
const BASE_URL_DEV = "http://localhost" | ||
const BASE_URL_PROD = "http://137.184.81.207" | ||
const BASE_URL = ENV == "development" ? BASE_URL_DEV : BASE_URL_PROD | ||
const LOGIN_URL = `${BASE_URL}:9000/login` | ||
const API_URL = `${BASE_URL}:9000/connections` | ||
const TEST_URL = `${BASE_URL}:3000/connections` | ||
const BUTTON = "Nova Conexão" | ||
const ENTITY = { _id: "1", name: "Conexão 1", phone: "123456789", instanceName: "Conexao_1-123456789" } | ||
const ENTITY_PLURAL_NAME = "Mensagens" | ||
const TEST_NAME = `Página de ${ENTITY_PLURAL_NAME}` | ||
|
||
|
||
describe(TEST_NAME, () => { | ||
beforeEach(() => { | ||
cy.fixture("token").then((token) => { | ||
console.log(token); | ||
cy.intercept("POST", "http://137.184.81.207:9000/auth/login", { | ||
cy.intercept("POST", `${LOGIN_URL}`, { | ||
statusCode: 200, | ||
body: { | ||
token: token.token | ||
} | ||
body: { token: token.token } | ||
}); | ||
|
||
cy.intercept("GET", "http://137.184.81.207:9000/connections", { | ||
cy.intercept("GET", `${API_URL}`, { | ||
statusCode: 200, | ||
body: [ | ||
{ _id: "1", name: "Conexão 1", phone: "123456789", instanceName: "Conexao_1-123456789" }, | ||
] | ||
}).as("getConnections"); | ||
body: [ ENTITY ] | ||
}).as("getPlans"); | ||
|
||
localStorage.setItem("token", token.token); | ||
cy.visit("http://137.184.81.207:3000/connections"); | ||
|
||
// Espera a requisição GET /api/connections ser chamada | ||
cy.wait("@getConnections", { timeout: 10000 }); | ||
}); | ||
cy.visit(`${TEST_URL}`); | ||
}) | ||
}); | ||
|
||
it("deve exibir uma lista de connections", () => { | ||
it(`deve exibir uma lista de ${ENTITY_PLURAL_NAME}`, () => { | ||
cy.get("table").should("exist"); | ||
cy.get("table tbody tr").should("have.length.at.least", 1); | ||
}); | ||
|
||
it("deve mudar da tabela para o formulário ao clicar em Nova Conexão", () => { | ||
cy.get("button").contains("Nova Conexão").click(); | ||
cy.wait(1000); | ||
it(`deve mudar da tabela para o formulário ao clicar em ${BUTTON}`, () => { | ||
cy.get("button").contains(BUTTON).click(); | ||
cy.get("form").should("exist"); | ||
cy.get("table").should("not.exist"); | ||
}); | ||
|
||
it("deve mudar do formulário para a tabela ao clicar em Cancelar", () => { | ||
cy.get("button").contains("Nova Conexão").click(); | ||
cy.get("button").contains(BUTTON).click(); | ||
cy.get("form").should("exist"); | ||
cy.get("table").should("not.exist"); | ||
cy.get("button").contains("Cancelar").click(); | ||
cy.get("table").should("exist"); | ||
cy.get("form").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 |
---|---|---|
@@ -1,46 +1,52 @@ | ||
describe("Página de Contatos", () => { | ||
beforeEach(() => { | ||
// const ENV = "development" | ||
const ENV = "production" | ||
const BASE_URL_DEV = "http://localhost" | ||
const BASE_URL_PROD = "http://137.184.81.207" | ||
const BASE_URL = ENV == "development" ? BASE_URL_DEV : BASE_URL_PROD | ||
const LOGIN_URL = `${BASE_URL}:9000/login` | ||
const API_URL = `${BASE_URL}:9000/contacts` | ||
const TEST_URL = `${BASE_URL}:3000/contacts` | ||
const BUTTON = "Novo Contato" | ||
const ENTITY = { _id: "1", name: "Contato 1", phone: "123456789"} | ||
const ENTITY_PLURAL_NAME = "Mensagens" | ||
const TEST_NAME = `Página de ${ENTITY_PLURAL_NAME}` | ||
|
||
describe(TEST_NAME, () => { | ||
beforeEach(() => { | ||
cy.fixture("token").then((token) => { | ||
console.log(token); | ||
// Mock da resposta da API de login (se necessário) | ||
cy.intercept("POST", "http://137.184.81.207:9000/login", { | ||
cy.intercept("POST", `${LOGIN_URL}`, { | ||
statusCode: 200, | ||
body: { | ||
token: token.token | ||
} | ||
body: { token: token.token } | ||
}); | ||
|
||
cy.fixture("contacts").then((contacts) => { | ||
console.log(contacts); | ||
}) | ||
cy.intercept("GET", "http://137.184.81.207:9000/contacts", { | ||
cy.intercept("GET", `${API_URL}`, { | ||
statusCode: 200, | ||
body: [ | ||
{ _id: "1", name: "Contato 1", phone: "123456789"}, | ||
] | ||
}).as("getContacts"); | ||
body: [ ENTITY ] | ||
}).as("getPlans"); | ||
|
||
localStorage.setItem("token", token.token); | ||
cy.visit("http://137.184.81.207:3000/contacts"); | ||
|
||
cy.wait("@getContacts"); | ||
cy.visit(`${TEST_URL}`); | ||
}) | ||
|
||
}); | ||
|
||
Cypress.on("uncaught:exception", (err, runnable) => { | ||
console.log("uncaught:exception:", err); | ||
return false; | ||
}); | ||
it("deve exibir uma lista de contatos", () => { | ||
it(`deve exibir uma lista de ${ENTITY_PLURAL_NAME}`, () => { | ||
cy.get("table").should("exist"); | ||
cy.get("table tbody tr").should("have.length.at.least", 1); | ||
}); | ||
|
||
it("deve mudar da tabela para o formulário ao clicar em Novo Contato", () => { | ||
cy.get("button").contains("Novo Contato").click(); | ||
it(`deve mudar da tabela para o formulário ao clicar em ${BUTTON}`, () => { | ||
cy.get("button").contains(BUTTON).click(); | ||
cy.get("form").should("exist"); | ||
cy.get("table").should("not.exist"); | ||
}); | ||
}); | ||
|
||
it("deve mudar do formulário para a tabela ao clicar em Cancelar", () => { | ||
cy.get("button").contains(BUTTON).click(); | ||
cy.get("form").should("exist"); | ||
cy.get("table").should("not.exist"); | ||
cy.get("button").contains("Cancelar").click(); | ||
cy.get("table").should("exist"); | ||
cy.get("form").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,48 @@ | ||
// describe("Teste do Kanban com Cypress", () => { | ||
// beforeEach(() => { | ||
// // Antes de cada teste, você pode realizar configurações iniciais, como visitar a página. | ||
// cy.visit("http://www.zapzapticket.online:3000/kanban"); // Certifique-se de ajustar o URL conforme necessário. | ||
// Cypress.Commands.add('dragTo', {prevSubject: 'element'}, (subject, targetEl) => { | ||
// cy.wrap(subject).trigger('mousedown', {which: 1}); | ||
// cy.get(targetEl).trigger('mousemove').trigger('mouseup', {force: true}); | ||
// }); | ||
// }); | ||
|
||
// it("Deve arrastar e soltar um cartão no Kanban", () => { | ||
// return true; | ||
// // Exemplo fictício: | ||
// // cy.get(".smooth-dnd-draggable-wrapper article header > span").first().dragTo(".react-trello-lane"); | ||
// // cy.get(".react-trello-lane").should("have.length", 1); | ||
// }); | ||
// }); | ||
|
||
describe("Página de Kanban", () => { | ||
beforeEach(() => { | ||
|
||
cy.fixture("token").then((token) => { | ||
console.log(token); | ||
// Mock da resposta da API de login (se necessário) | ||
cy.intercept("POST", "http://137.184.81.207:9000/login", { | ||
statusCode: 200, | ||
body: { | ||
token: token.token | ||
} | ||
}); | ||
|
||
localStorage.setItem("token", token.token); | ||
cy.visit("http://137.184.81.207:3000/kanban"); | ||
|
||
}) | ||
|
||
}); | ||
|
||
Cypress.on("uncaught:exception", (err, runnable) => { | ||
console.log("uncaught:exception:", err); | ||
return false; | ||
}); | ||
it("deve exibir pelo menos 2 lanes", () => { | ||
cy.get(".react-trello-lane").should("exist"); | ||
cy.get(".react-trello-lane").should("have.length.at.least", 2); | ||
}); | ||
|
||
}); |
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
Oops, something went wrong.