Skip to content

Commit

Permalink
Merge pull request #2 from feroline/home
Browse files Browse the repository at this point in the history
Home
  • Loading branch information
feroline authored Jul 3, 2024
2 parents be8ecaa + 0c13f36 commit 29f3d02
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 33 deletions.
30 changes: 15 additions & 15 deletions cypress/e2e/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import HomeLinks from "../support/Enum/links/Home"

const Home = new HomePage()


//TODO: retirar os get dos métodos que não são get
beforeEach(() => {
cy.visit("/")
});
Expand All @@ -12,41 +12,41 @@ describe("Teste de Home", () => {
describe("Verificando Visibilidade", () => {
it("Banner", () => {
Home.setLink(HomeLinks.BANNER)
Home.getBanner().should("be.visible")
Home.banner().should("be.visible")
})


it("Elements", () => {
Home.getElements().should("be.visible")
Home.elements().should("be.visible")
})

it("Forms", () => {
Home.getForms().should("be.visible")
Home.forms().should("be.visible")
})

it("Alerts, Frames & Windows", () => {
Home.getAlertsFramesWindows().should("be.visible")
Home.alertsFramesWindows().should("be.visible")
})

it("Widgets", () => {
Home.getWidgets().should("be.visible")
Home.widgets().should("be.visible")
})

it("Interactions", () => {

Home.getInteractions().should("be.visible")
Home.interactions().should("be.visible")
})

it("Book Store", () => {
Home.getBookStore().should("be.visible")
Home.bookStore().should("be.visible")
})

});

describe("Verificando Redirecionamento", () => {
it("Banner", () => {
Home.setLink(HomeLinks.BANNER)
Home.getBanner()
Home.banner()
.should("exist")
.click()
.then(() => {
Expand All @@ -56,37 +56,37 @@ describe("Teste de Home", () => {

it("Elements", () => {
Home.setLink(HomeLinks.ELEMENTS);
Home.getElements().click();
Home.elements().click();
cy.url().should("contains", Home.getLink())
})

it("Forms", () => {
Home.setLink(HomeLinks.FORMS)
Home.getForms().click()
Home.forms().click()
cy.url().should("contains", Home.getLink())
})

it("Alerts, Frames & Windows", () => {
Home.setLink(HomeLinks.ALERTS_FRAMES_WINDOWS)
Home.getAlertsFramesWindows().click()
Home.alertsFramesWindows().click()
cy.url().should("contains", Home.getLink())
})

it("Widgets", () => {
Home.setLink(HomeLinks.WIDGETS)
Home.getWidgets().click()
Home.widgets().click()
cy.url().should("contains", Home.getLink())
})

it("Interactions", () => {
Home.setLink(HomeLinks.INTERACTIONS)
Home.getInteractions().click()
Home.interactions().click()
cy.url().should("contains", Home.getLink())
})

it("Book Store", () => {
Home.setLink(HomeLinks.BOOKSTORE)
Home.getBookStore().click()
Home.bookStore().click()
cy.url().should("contains", Home.getLink())
})

Expand Down
40 changes: 22 additions & 18 deletions cypress/pages/HomePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,47 @@ class HomePage {
this.link = link;
}

getBanner() {
return cy.get(`div.home-banner a[href="${this.getLink()}"]`)
banner() {
return cy.get(`div.home-banner a[href="${this.getLink()}"]`);
}

getElements() {
return cy.xpath("//div[contains(@class, 'card-body')][contains(.,'Elements')]")
elements() {
return this.cardByTitle("Elements");
}

getForms() {
return cy.xpath("//div[contains(@class, 'card-body')][contains(.,'Forms')]")
forms() {
return this.cardByTitle("Forms");
}

getAlertsFramesWindows() {
return cy.xpath("//div[contains(@class, 'card-body')][contains(.,'Alerts, Frame & Windows')]")
alertsFramesWindows() {
return this.cardByTitle("Alerts, Frame & Windows");
}

getWidgets() {
return cy.xpath("//div[contains(@class, 'card-body')][contains(.,'Widgets')]")
widgets() {
return this.cardByTitle("Widgets");
}

getInteractions() {
return cy.xpath("//div[contains(@class, 'card-body')][contains(.,'Interactions')]")
interactions() {
return this.cardByTitle("Interactions");
}

getBookStore() {
return cy.xpath("//div[contains(@class, 'card-body')][contains(.,'Book Store Application')]")
bookStore() {
return this.cardByTitle("Book Store Application");
}

setLink(link: string) {
return (this.link = link)
return (this.link = link);
}

getLink() {
return this.link
return this.link;
}


private cardByTitle(title: string) {
return cy.xpath(
`//div[contains(@class, 'card-body')][contains(.,'${title}')]`
);
}
}

export default HomePage
export default HomePage;
3 changes: 3 additions & 0 deletions s Permanent Address
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* elements
home
main

0 comments on commit 29f3d02

Please sign in to comment.