-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edc2202
commit 8257665
Showing
7 changed files
with
57 additions
and
72 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,5 +35,6 @@ yarn-error.log* | |
next-env.d.ts | ||
|
||
cypress/videos | ||
cypress/screenshots | ||
|
||
/test-results |
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,44 +1,31 @@ | ||
describe("Use cases of the Generation Page", () => { | ||
it("when initiated the generation page should display the page info", () => { | ||
cy.visit(`${Cypress.config().baseUrl}/generation/1`); | ||
cy.contains("Region"); | ||
cy.contains("Pokemons: 151"); | ||
cy.contains("Region").should("exist"); | ||
cy.contains("Pokemons: 151").should("exist"); | ||
cy.percySnapshot(); | ||
}); | ||
|
||
it("when clicked in a pokemon in the listing should redirect to pokemon page", () => { | ||
cy.visit(`${Cypress.config().baseUrl}/generation/1`); | ||
cy.get("[data-testid=pokemon-details-section]").should("not.exist"); | ||
|
||
cy.get("[data-testid=pokemon-listing]").within(() => { | ||
cy.get("a").contains("bulbasaur").click(); | ||
}); | ||
|
||
cy.get("[data-testid=pokemon-listing] a").contains("bulbasaur").click(); | ||
cy.get("[data-testid=pokemon-details-section]").should("exist"); | ||
|
||
cy.url().should("be.equal", `${Cypress.config().baseUrl}/generation/1/pokemon/bulbasaur`); | ||
cy.url().should("eq", `${Cypress.config().baseUrl}/generation/1/pokemon/bulbasaur`); | ||
}); | ||
|
||
it("when searching for a pokemon should display the correct one in the listing", () => { | ||
cy.visit(`${Cypress.config().baseUrl}/generation/1`); | ||
|
||
cy.get("[data-testid=pokemon-listing]").within(() => { | ||
cy.get("#search-input").type("but"); | ||
|
||
cy.get("a").should("have.length", 3); | ||
cy.get("a").contains("kabuto"); | ||
cy.get("a").contains("butterfree"); | ||
cy.get("a").contains("kabutops"); | ||
}); | ||
cy.get("#search-input").type("but"); | ||
cy.get("[data-testid=pokemon-listing] a").should("have.length", 3); | ||
cy.get("[data-testid=pokemon-listing] a").contains("kabuto").should("exist"); | ||
cy.get("[data-testid=pokemon-listing] a").contains("butterfree").should("exist"); | ||
cy.get("[data-testid=pokemon-listing] a").contains("kabutops").should("exist"); | ||
}); | ||
|
||
it("when searching for an unknown pokemon should display nothing in the listing", () => { | ||
cy.visit(`${Cypress.config().baseUrl}/generation/1`); | ||
|
||
cy.get("[data-testid=pokemon-listing]").within(() => { | ||
cy.get("#search-input").type("bbb"); | ||
|
||
cy.get("a").should("have.length", 0); | ||
}); | ||
cy.get("#search-input").type("bbb"); | ||
cy.get("[data-testid=pokemon-listing] a").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 |
---|---|---|
@@ -1,21 +1,18 @@ | ||
describe("Use cases of the initial page (Generations Page)", () => { | ||
it("when initiated should render the generations page", () => { | ||
cy.visit(Cypress.config().baseUrl); | ||
cy.get("a").contains("Generation I"); | ||
cy.get("a").contains("Generation I").should("exist"); | ||
cy.percySnapshot(); | ||
}); | ||
|
||
it("when tried to access an invalid route should display an error message", () => { | ||
cy.visit(`${Cypress.config().baseUrl}/test`); | ||
|
||
cy.contains("Page Not Found"); | ||
cy.contains("Page Not Found").should("exist"); | ||
}); | ||
|
||
it("when clicked in a generation link should redirect to generation page", () => { | ||
cy.visit(Cypress.config().baseUrl); | ||
|
||
cy.get("a").contains("Generation I").click(); | ||
|
||
cy.url().should("be.equal", `${Cypress.config().baseUrl}/generation/1`); | ||
cy.url().should("eq", `${Cypress.config().baseUrl}/generation/1`); | ||
}); | ||
}); |
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,33 +1,16 @@ | ||
/* eslint-disable */ | ||
// Disable ESLint to prevent failing linting inside the Next.js repo. | ||
// If you're using ESLint on your project, we recommend installing the ESLint Cypress plugin instead: | ||
// https://github.com/cypress-io/eslint-plugin-cypress | ||
|
||
// Cypress E2E Test | ||
describe("Use cases of the Header", () => { | ||
it("when back button is clicked should return to the previous page", () => { | ||
// Start from the index page | ||
cy.visit(Cypress.config().baseUrl); | ||
|
||
cy.get("h1").contains("PokeSearch"); | ||
|
||
cy.get("h1").contains("PokeSearch").should("exist"); | ||
cy.get("a").contains("Generation I").click(); | ||
|
||
cy.url().should("be.equal", `${Cypress.config().baseUrl}/generation/1`); | ||
|
||
cy.url().should("eq", `${Cypress.config().baseUrl}/generation/1`); | ||
cy.get("button").contains("Back").click(); | ||
|
||
cy.url().should("be.equal", `${Cypress.config().baseUrl}/`); | ||
cy.url().should("eq", `${Cypress.config().baseUrl}/`); | ||
}); | ||
|
||
it("when changed the lang selector should change the language of the page", () => { | ||
cy.visit(Cypress.config().baseUrl); | ||
|
||
cy.get("[data-testid=lang-select]").select("fr"); | ||
|
||
cy.contains("Créé par Claudivan"); | ||
cy.contains("Créé par Claudivan").should("exist"); | ||
}); | ||
}); | ||
|
||
// Prevent TypeScript from reading file as legacy script | ||
export {}; |
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,35 +1,22 @@ | ||
describe("Use cases of the Pokemon Page", () => { | ||
it("when initiated the Pokemon Page should display the pokemon info", () => { | ||
cy.visit(`${Cypress.config().baseUrl}/generation/1/pokemon/bulbasaur`); | ||
|
||
cy.get("[data-testid=pokemon-header]").within(() => { | ||
cy.get("[alt=bulbasaur]").should("exist"); | ||
}); | ||
|
||
cy.get("[data-testid=pokemon-details-section]").within(() => { | ||
cy.get("[data-testid=pokemon-evolution-stages]").should("exist"); | ||
cy.get("[data-testid=pokemon-stats]").should("exist"); | ||
cy.get("[data-testid=pokemon-header]").should("exist"); | ||
}); | ||
|
||
cy.get("[data-testid=pokemon-header] [alt=bulbasaur]").should("exist"); | ||
cy.get("[data-testid=pokemon-evolution-stages]").should("exist"); | ||
cy.get("[data-testid=pokemon-stats]").should("exist"); | ||
cy.get("[data-testid=pokemon-header]").should("exist"); | ||
cy.percySnapshot(); | ||
}); | ||
|
||
it("when initiated the Pokemon Page with error should display the error message", () => { | ||
cy.visit(`${Cypress.config().baseUrl}/generation/1/pokemon/bulbasaur2`); | ||
|
||
cy.contains("Pokemon Not Found"); | ||
cy.contains("Pokemon Not Found").should("exist"); | ||
}); | ||
|
||
it("when clicked in the pokemon evolution should change the page to the clicked pokemon", () => { | ||
cy.visit(`${Cypress.config().baseUrl}/generation/1/pokemon/bulbasaur`); | ||
|
||
cy.get("[data-testid=pokemon-evolution-stages]").within(() => { | ||
cy.get("a").should("have.length", 3); | ||
|
||
cy.get("a").eq(1).click(); | ||
|
||
cy.url().should("be.equal", `${Cypress.config().baseUrl}/generation/1/pokemon/ivysaur`); | ||
}); | ||
cy.get("[data-testid=pokemon-evolution-stages] a").should("have.length", 3); | ||
cy.get("[data-testid=pokemon-evolution-stages] a").eq(1).click(); | ||
cy.url().should("eq", `${Cypress.config().baseUrl}/generation/1/pokemon/ivysaur`); | ||
}); | ||
}); |
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
15 changes: 15 additions & 0 deletions
15
src/app/[locale]/generation/[generationId]/pokemon/[pokemonName]/page.tsx
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
8257665
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
next-ssg-portfolio-app – ./
next-ssg-portfolio-app-claudivanfilho.vercel.app
next-ssg-portfolio-app.vercel.app
next-ssg-portfolio-app-git-master-claudivanfilho.vercel.app