Skip to content

Commit

Permalink
Added Cypress test for home page
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaileshParmar11 committed Aug 24, 2022
1 parent 4ec383a commit 001b27d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
47 changes: 47 additions & 0 deletions cypress/e2e/homePage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/// <reference types="cypress" />

import { CONTRIBUTORS_COUNT, TWEET_COUNT } from "../support/constant";

describe("Test home page", () => {
beforeEach(() => {
cy.visit("/");
});

it("Header component should render properly", () => {
cy.get('[data-testid="app-header"]').should("be.visible");
cy.get('[data-testid="app-logo"]').should("be.visible");
cy.get('[data-testid="plays-search-box-container"]').should("not.exist");
cy.get('[data-testid="header-links-container"]').should("be.visible");
cy.get('[data-testid="browse-btn"]').should("be.visible").as("browseBtn");
cy.get('[data-testid="create-btn"]').should("be.visible");
cy.get('[data-testid="ideas-btn"]').should("be.visible");
cy.get('[data-testid="github-btn"]').should("be.visible");
cy.get('[data-testid="twitter-btn"]').should("be.visible");
cy.get('[data-testid="share-btn"]').should("be.visible");

cy.get("@browseBtn").click();
cy.get('[data-testid="plays-search-box-container"]').should("be.visible");
});

it("Tweet section should render with all tweets", () => {
cy.intercept("GET", "https://cdn.syndication.twimg.com/*").as("tweets");
cy.wait("@tweets");
cy.get('[data-testid="tweet-container"]')
.scrollIntoView()
.should("be.visible");
cy.get('[data-testid="tweet-container"] [id*="twitter-widget"]').should(
"have.length",
TWEET_COUNT
);
cy.get('[data-testid="watch-svg"]').should("not.exist");
});

it("Contributors section should render with all contributors", () => {
cy.get('[data-testid="contributors-section"]')
.scrollIntoView()
.should("be.visible");
cy.get(
'[data-testid="contributors-section"] [data-testid*="contributor-"]'
).should("have.length", CONTRIBUTORS_COUNT);
});
});
2 changes: 2 additions & 0 deletions cypress/support/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const TWEET_COUNT = 10;
export const CONTRIBUTORS_COUNT = 29;

0 comments on commit 001b27d

Please sign in to comment.