-
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 pull request #75 from wizelineacademy/tests-caro
Added Tests Caro
- Loading branch information
Showing
10 changed files
with
372 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//E2E test for the compare one card functionality - Carolina González A01284948 | ||
|
||
describe("Load one card", () => { | ||
it("passes", () => { | ||
// Prepare the database | ||
cy.request("http://localhost:3000/api/testing") | ||
cy.login() | ||
cy.wait(8000) | ||
cy.visit("http://localhost:3000/") | ||
|
||
cy.setCookie( | ||
"compareData", | ||
"%7B%22categories%22%3A%5B%22Description%22%2C%22Price%22%2C%22Sound%20quality%22%2C%22Brand%20reputation%22%2C%22Design%22%2C%22Key%20action%22%5D%2C%22results%22%3A%5B%7B%22Name%22%3A%22Steinway%20%26%20Sons%22%2C%22Description%22%3A%22Handcrafted%20pianos%20with%20a%20focus%20on%20quality%20and%20tradition.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22High%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Excellent%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Iconic%20and%20renowned%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Elegant%20and%20timeless%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Superb%22%7D%5D%7D%2C%7B%22Name%22%3A%22Yamaha%22%2C%22Description%22%3A%22Japanese%20manufacturer%20known%20for%20innovation%2C%20reliability%2C%20and%20versatility.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22Moderate%20to%20high%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Very%20good%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Renowned%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Modern%20and%20sleek%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Excellent%22%7D%5D%7D%2C%7B%22Name%22%3A%22Bechstein%22%2C%22Description%22%3A%22German%20manufacturer%20known%20for%20craftsmanship%20and%20rich%2C%20powerful%20sound.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22High%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Excellent%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Renowned%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Elegant%20and%20luxurious%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Superb%22%7D%5D%7D%2C%7B%22Name%22%3A%22Kawai%22%2C%22Description%22%3A%22Japanese%20manufacturer%20known%20for%20quality%2C%20innovation%2C%20and%20value.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22Moderate%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Very%20good%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Distinguished%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Modern%20and%20stylish%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Excellent%22%7D%5D%7D%2C%7B%22Name%22%3A%22Grotrian-Steinweg%22%2C%22Description%22%3A%22German%20manufacturer%20known%20for%20craftsmanship%2C%20sound%20quality%2C%20and%20tradition.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22High%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Excellent%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Renowned%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Elegant%20and%20luxurious%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Superb%22%7D%5D%7D%2C%7B%22Name%22%3A%22Baldwin%22%2C%22Description%22%3A%22American%20manufacturer%20known%20for%20quality%20and%20affordability.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22Moderate%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Good%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Distinguished%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Traditional%20and%20classic%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Very%20good%22%7D%5D%7D%5D%7D", | ||
) | ||
cy.visit("http://localhost:3000/dashboard/phase3") | ||
cy.wait(8000) | ||
|
||
cy.get("table").should("exist") | ||
cy.contains( | ||
"Handcrafted pianos with a focus on quality and tradition.", | ||
).click() | ||
|
||
cy.get("button").contains("Compare").click() | ||
|
||
cy.get("h2").contains("Steinway & Sons") | ||
}) | ||
}) |
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,35 @@ | ||
//E2E test for the compare two cards functionality - Carolina González A01284948 | ||
|
||
describe("Load three cards", () => { | ||
it("passes", () => { | ||
// Prepare the database | ||
cy.request("http://localhost:3000/api/testing") | ||
cy.login() | ||
cy.wait(8000) | ||
cy.visit("http://localhost:3000/") | ||
|
||
cy.setCookie( | ||
"compareData", | ||
"%7B%22categories%22%3A%5B%22Description%22%2C%22Price%22%2C%22Sound%20quality%22%2C%22Brand%20reputation%22%2C%22Design%22%2C%22Key%20action%22%5D%2C%22results%22%3A%5B%7B%22Name%22%3A%22Steinway%20%26%20Sons%22%2C%22Description%22%3A%22Handcrafted%20pianos%20with%20a%20focus%20on%20quality%20and%20tradition.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22High%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Excellent%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Iconic%20and%20renowned%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Elegant%20and%20timeless%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Superb%22%7D%5D%7D%2C%7B%22Name%22%3A%22Yamaha%22%2C%22Description%22%3A%22Japanese%20manufacturer%20known%20for%20innovation%2C%20reliability%2C%20and%20versatility.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22Moderate%20to%20high%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Very%20good%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Renowned%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Modern%20and%20sleek%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Excellent%22%7D%5D%7D%2C%7B%22Name%22%3A%22Bechstein%22%2C%22Description%22%3A%22German%20manufacturer%20known%20for%20craftsmanship%20and%20rich%2C%20powerful%20sound.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22High%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Excellent%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Renowned%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Elegant%20and%20luxurious%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Superb%22%7D%5D%7D%2C%7B%22Name%22%3A%22Kawai%22%2C%22Description%22%3A%22Japanese%20manufacturer%20known%20for%20quality%2C%20innovation%2C%20and%20value.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22Moderate%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Very%20good%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Distinguished%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Modern%20and%20stylish%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Excellent%22%7D%5D%7D%2C%7B%22Name%22%3A%22Grotrian-Steinweg%22%2C%22Description%22%3A%22German%20manufacturer%20known%20for%20craftsmanship%2C%20sound%20quality%2C%20and%20tradition.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22High%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Excellent%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Renowned%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Elegant%20and%20luxurious%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Superb%22%7D%5D%7D%2C%7B%22Name%22%3A%22Baldwin%22%2C%22Description%22%3A%22American%20manufacturer%20known%20for%20quality%20and%20affordability.%22%2C%22Categories%22%3A%5B%7B%22Name%22%3A%22Price%22%2C%22Value%22%3A%22Moderate%22%7D%2C%7B%22Name%22%3A%22Sound%20quality%22%2C%22Value%22%3A%22Good%22%7D%2C%7B%22Name%22%3A%22Brand%20reputation%22%2C%22Value%22%3A%22Distinguished%22%7D%2C%7B%22Name%22%3A%22Design%22%2C%22Value%22%3A%22Traditional%20and%20classic%22%7D%2C%7B%22Name%22%3A%22Key%20action%22%2C%22Value%22%3A%22Very%20good%22%7D%5D%7D%5D%7D", | ||
) | ||
cy.visit("http://localhost:3000/dashboard/phase3") | ||
cy.wait(8000) | ||
|
||
cy.get("table").should("exist") | ||
cy.contains( | ||
"Handcrafted pianos with a focus on quality and tradition.", | ||
).click() | ||
cy.contains( | ||
"Japanese manufacturer known for innovation, reliability, and versatility.", | ||
).click() | ||
cy.contains( | ||
"German manufacturer known for craftsmanship and rich, powerful sound.", | ||
).click() | ||
|
||
cy.get("button").contains("Compare").click() | ||
|
||
cy.get("h2").contains("Steinway & Sons") | ||
cy.get("h2").contains("Yamaha") | ||
cy.get("h2").contains("Bechstein") | ||
}) | ||
}) |
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,21 @@ | ||
//E2E test for the Log out functionality - Carolina González A01284948 | ||
describe("Sign out", () => { | ||
it("passes", () => { | ||
// Prepare the database | ||
cy.request("http://localhost:3000/api/testing") | ||
cy.login() | ||
cy.wait(8000) | ||
cy.visit("http://localhost:3000/") | ||
cy.get("#dropdown-btn-icon").click() | ||
cy.get("button").contains("Sign out").click() | ||
cy.wait(8000) | ||
|
||
// Check that the user is logged out | ||
cy.get("button").should("contain", "Sign in with Email") | ||
cy.wait(8000) | ||
|
||
cy.visit("http://localhost:3000/") | ||
cy.wait(8000) | ||
cy.get("button").should("contain", "Sign in with Email") | ||
}) | ||
}) |
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
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,63 @@ | ||
//Test for the render of the list of titles - Carolina González A01284948 | ||
import { test, expect } from "vitest" | ||
import { screen, render } from "@testing-library/react" | ||
import { mockCardProps } from "../mocks/mock" | ||
import { act } from "react" | ||
import { Compare_Card } from "@/components/Compare/Compare_Card" | ||
|
||
test("Compare Card Titles Render Test", async () => { | ||
render( | ||
<Compare_Card | ||
initialTitle={mockCardProps.initialTitle} | ||
initialDescription={mockCardProps.initialDescription} | ||
initialData={mockCardProps.initialData} | ||
titles={mockCardProps.titles} | ||
allData={mockCardProps.allData} | ||
/>, | ||
) | ||
|
||
expect(screen.getByText("test")).toBeVisible() | ||
|
||
act(() => { | ||
screen | ||
.getByRole("button", { | ||
name: /test/i, | ||
}) | ||
.click() | ||
}) | ||
|
||
expect(screen.getByText("titles2")).toBeVisible() | ||
}) | ||
|
||
/*test("Compare Card Information Change", async () => { | ||
render( | ||
<Compare_Card | ||
initialTitle={mockCardProps.initialTitle} | ||
initialDescription={mockCardProps.initialDescription} | ||
initialData={mockCardProps.initialData} | ||
titles={mockCardProps.titles} | ||
allData={mockCardProps.allData} | ||
/>, | ||
) | ||
expect(screen.getByText("InitialDescription")).toBeVisible() | ||
act(() => { | ||
screen | ||
.getByRole("button", { | ||
name: /test/i, | ||
}) | ||
.click() | ||
}) | ||
act(() => { | ||
screen | ||
.getByRole("menuitem", { | ||
name: /titles2/i, | ||
}) | ||
.click() | ||
}) | ||
expect(screen.getByText("Description2")).toBeVisible() | ||
}) | ||
*/ |
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,77 @@ | ||
//Test for the render and functionality of the history component - Carolina González A01284948 | ||
import { test, expect, vi } from "vitest" | ||
import { screen, render } from "@testing-library/react" | ||
import { mockHistoryTest } from "../mocks/mock" | ||
import { act } from "react" | ||
import InputBar from "@/components/Dashboard/InputBar" | ||
import { fireEvent } from "@testing-library/react" | ||
|
||
const mockLink = vi.fn() | ||
|
||
const mockRouter = { | ||
push: vi.fn(), | ||
} | ||
vi.mock("next/navigation", () => ({ | ||
useRouter: () => mockRouter, | ||
})) | ||
|
||
vi.mock("@/actions/redirect", () => ({ | ||
navigate: (url: string) => mockLink(url), | ||
})) | ||
|
||
vi.mock("@/actions/search", () => ({ | ||
initialSearchAction: async (query: string) => { | ||
return query | ||
}, | ||
clearSearches: () => {}, | ||
})) | ||
|
||
test("Render History and Search PopUp Test", async () => { | ||
render(<InputBar history={mockHistoryTest} />) | ||
|
||
fireEvent.change(screen.getByPlaceholderText("Search for a topic..."), { | ||
target: { value: "test" }, | ||
}) | ||
|
||
act(() => { | ||
screen.getByRole("listitem", { name: "" }).click() | ||
}) | ||
|
||
expect(screen.getByText("Historial")).toBeInTheDocument() | ||
expect(screen.getByText("Nueva busqueda")).toBeInTheDocument() | ||
}) | ||
|
||
test("Search History Click Test", async () => { | ||
render(<InputBar history={mockHistoryTest} />) | ||
|
||
fireEvent.change(screen.getByPlaceholderText("Search for a topic..."), { | ||
target: { value: "test" }, | ||
}) | ||
|
||
act(() => { | ||
screen.getByRole("listitem", { name: "" }).click() | ||
}) | ||
|
||
act(() => { | ||
screen.getByText("Historial").click() | ||
}) | ||
|
||
expect(mockRouter.push).toHaveBeenCalledWith("/history/1") | ||
}) | ||
test("New Search Click Test", async () => { | ||
render(<InputBar history={mockHistoryTest} />) | ||
|
||
fireEvent.change(screen.getByPlaceholderText("Search for a topic..."), { | ||
target: { value: "test" }, | ||
}) | ||
|
||
act(() => { | ||
screen.getByRole("listitem", { name: "" }).click() | ||
}) | ||
|
||
act(() => { | ||
screen.getByText("Nueva busqueda").click() | ||
}) | ||
|
||
expect(mockLink).toHaveBeenCalledWith("test") | ||
}) |
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,50 @@ | ||
//Test for the render and redirect correct options on the UserMenu - Carolina González A01284948 | ||
import { test, expect } from "vitest" | ||
import { screen, render } from "@testing-library/react" | ||
import Header from "@/components/Header" | ||
import { act } from "react" | ||
import { SessionProvider } from "next-auth/react" | ||
|
||
test("Check User Menu on Dashboard", async () => { | ||
render( | ||
<SessionProvider | ||
session={{ | ||
user: { | ||
email: "[email protected]", | ||
name: "Test User", | ||
}, | ||
expires: "", | ||
}} | ||
> | ||
<Header isDashboard={true} /> | ||
</SessionProvider>, | ||
) | ||
|
||
act(() => { | ||
screen.getByRole("button", { name: "" }).click() | ||
}) | ||
|
||
expect(screen.getByText("History")).toBeVisible() | ||
}) | ||
|
||
test("Check User Menu on History", async () => { | ||
render( | ||
<SessionProvider | ||
session={{ | ||
user: { | ||
email: "[email protected]", | ||
name: "Test User", | ||
}, | ||
expires: "", | ||
}} | ||
> | ||
<Header isDashboard={false} /> | ||
</SessionProvider>, | ||
) | ||
|
||
act(() => { | ||
screen.getByRole("button", { name: "" }).click() | ||
}) | ||
|
||
expect(screen.getByText("Dashboard")).toBeVisible() | ||
}) |
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,32 @@ | ||
//Test for the render of a new column in the results table - Carolina González A01284948 | ||
import { test, expect } from "vitest" | ||
import { screen, render } from "@testing-library/react" | ||
import { mockResultsTable } from "../mocks/mock" | ||
import P3_ResultsTable from "@/components/Phase3/P3_ResultsTable" | ||
import { act } from "react" | ||
|
||
vi.mock("@/actions/compare", () => ({ | ||
toggleCompares: () => { | ||
return | ||
}, | ||
})) | ||
|
||
test("Show new column render test ", async () => { | ||
render(<P3_ResultsTable incoming_results={mockResultsTable.results} />) | ||
|
||
expect(screen.getByText("Columns")).toBeVisible() | ||
|
||
act(() => { | ||
screen.getByRole("button", { name: /columns/i }).click() | ||
}) | ||
|
||
act(() => { | ||
screen | ||
.getByRole("menuitemcheckbox", { | ||
name: /NewColumn/i, | ||
}) | ||
.click() | ||
}) | ||
|
||
expect(screen.getByText("NewColumn")).toBeInTheDocument() | ||
}) |