Skip to content

chore: 🤖 migrate cypress to use typescript #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

6 changes: 6 additions & 0 deletions cypress/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
parserOptions: {
tsconfigRootDir: __dirname,
project: "./tsconfig.json",
},
};
File renamed without changes.
11 changes: 11 additions & 0 deletions cypress/integration/about/about.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe("About", () => {
it("should not have broken links", () => {
cy.visit(`${Cypress.env("hostUrl")}/sobre`);

cy.getByDataTest("accordion-container").within(() => {
cy.findAllByRole("link").each((link) => {
cy.request(link.prop("href")).its("status").should("eq", 200);
});
});
});
});
22 changes: 0 additions & 22 deletions cypress/integration/header/header.spec.js

This file was deleted.

11 changes: 11 additions & 0 deletions cypress/integration/header/header.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe("Header", () => {
it("should not have broken links", () => {
cy.visit(Cypress.env("hostUrl"));

cy.getByDataTest("header-container").within(() => {
cy.findAllByRole("link").each((link) => {
cy.request(link.prop("href")).its("status").should("eq", 200);
});
});
});
});
93 changes: 0 additions & 93 deletions cypress/integration/home/filter.spec.js

This file was deleted.

68 changes: 68 additions & 0 deletions cypress/integration/home/filter.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { streamsRegex, tagsRegex, vodsRegex } from "../../consts/urlRegexes";

describe("Home > Filter", () => {
beforeEach(() => {
cy.intercept(streamsRegex, {
statusCode: 200,
fixture: "streams",
}).as("streams");
cy.intercept(tagsRegex, {
statusCode: 200,
fixture: "tags",
}).as("tags");
cy.intercept(vodsRegex, {
statusCode: 200,
fixture: "vods",
}).as("vods");
});

it("should filter out streams by tags change the URL", () => {
const PROGRAMMING_TEXT = "Programação";
const JAVASCRIPT_TEXT = "JavaScript";
const LGBTQIA_TEXT = "LGBTQIA+";

cy.visit(Cypress.env("hostUrl"));
cy.wait(["@streams", "@tags", "@vods"]);

cy.getByDataTest("card-online").should("have.length", 13);

cy.filterByTag(PROGRAMMING_TEXT);
cy.shouldUrlContainTags(PROGRAMMING_TEXT);
cy.getByDataTest("card-online").should("have.length", 2);

cy.unFilterByTag(PROGRAMMING_TEXT);
cy.getByDataTest("card-online").should("have.length", 13);

cy.filterByTag(PROGRAMMING_TEXT);
cy.filterByTag(JAVASCRIPT_TEXT);
cy.shouldUrlContainTags(PROGRAMMING_TEXT, JAVASCRIPT_TEXT);
cy.getByDataTest("card-online").should("have.length", 1);

cy.filterByTag(LGBTQIA_TEXT);
cy.shouldUrlContainTags(PROGRAMMING_TEXT, JAVASCRIPT_TEXT, LGBTQIA_TEXT);
cy.getByDataTest("card-online").should("have.length", 0);

cy.unFilterByTag(LGBTQIA_TEXT);
cy.getByDataTest("card-online").should("have.length", 1);

cy.unFilterByTag(JAVASCRIPT_TEXT);
cy.getByDataTest("card-online").should("have.length", 2);

cy.unFilterByTag(PROGRAMMING_TEXT);
cy.getByDataTest("card-online").should("have.length", 13);
});

it("should accept the tag query string to filter out streams", () => {
const JAVASCRIPT_TEXT = "JavaScript";

cy.visit(`http://localhost:3000/?tags=${JAVASCRIPT_TEXT}`);
cy.wait(["@streams", "@tags", "@vods"]);

cy.getByDataTest("tag-filter")
.contains(JAVASCRIPT_TEXT)
.should("have.css", "backgroundColor", "rgb(139, 61, 255)")
.should("have.length", 1);

cy.getByDataTest("card-online").should("have.length", 3);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { streamsRegex, tagsRegex, vodsRegex } from "../../consts/urlRegexes";

describe("Home > Raid", () => {
it("Copy raid command to clipboard", () => {
it("should copy raid command to clipboard", () => {
const COPIED_TEXT = "/raid emersongarrido";

cy.intercept(streamsRegex, {
Expand Down Expand Up @@ -41,11 +41,13 @@ describe("Home > Raid", () => {

cy.wait(["@streams", "@tags", "@vods"]);

cy.getByData("raid-button").first().click();
cy.window().its("navigator.clipboard").invoke("readText").should("equal", COPIED_TEXT);
cy.getByDataTest("card-online")
.first()
.within(() => {
cy.findByRole("button", { name: "Raid" }).click();
cy.window().its("navigator.clipboard").invoke("readText").should("equal", COPIED_TEXT);
});

cy.get(".chakra-alert").within(() => {
cy.get(".chakra-alert__title").contains(`Comando "${COPIED_TEXT}" copiado!`);
});
cy.findByRole("alert", { name: `Comando "${COPIED_TEXT}" copiado!` }).should("have.length", 1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("Home > Refetch", () => {
cy.visit(Cypress.env("hostUrl"));
cy.wait(["@streams", "@tags", "@vods"]);

cy.getByData("card-online").should("have.length", 13);
cy.getByDataTest("card-online").should("have.length", 13);

cy.intercept(streamsRegex, {
statusCode: 200,
Expand All @@ -27,6 +27,6 @@ describe("Home > Refetch", () => {
cy.tick(120 * 1000)
cy.wait(["@streams", "@tags", "@vods"]);

cy.getByData("card-online").should("have.length", 2);
cy.getByDataTest("card-online").should("have.length", 2);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ describe("Home > Simultaneous", () => {
cy.visit(Cypress.env("hostUrl"));
cy.wait(["@streams", "@tags", "@vods"]);

cy.getByData("simultaneous-button").click();
cy.getByData("start-simultaneous-button").click();
cy.get(".chakra-toast")
.should("have.length", 1)
.contains("Você deve selecionar pelo menos duas streams");
cy.getByDataTest("simultaneous-button").click();
cy.getByDataTest("start-simultaneous-button").click();

cy.findByRole("alert", { name: "Você deve selecionar pelo menos duas streams" }).should(
"have.length",
1,
);
});
});
22 changes: 0 additions & 22 deletions cypress/plugins/index.js

This file was deleted.

10 changes: 10 additions & 0 deletions cypress/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {
on("task", {
log(message) {
console.log(message);
return null;
},
});

return config;
};
7 changes: 7 additions & 0 deletions cypress/support/@types/selectors.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type Selectors =
| "accordion-container"
| "card-online"
| "header-container"
| "simultaneous-button"
| "start-simultaneous-button"
| "tag-filter"
31 changes: 0 additions & 31 deletions cypress/support/commands.js

This file was deleted.

Loading