-
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.
Merge pull request #11 from feroline/links
cenários da tela Links e @alias para os path,
- Loading branch information
Showing
22 changed files
with
2,293 additions
and
2,036 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
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
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,138 @@ | ||
import LinksPage from '@pageObject/links/LinksPage'; | ||
import ElementsLinks from '@enum/links/Elements'; | ||
import Link from '@enum/links/Link'; | ||
|
||
const Links = new LinksPage(); | ||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
beforeEach(() => { | ||
cy.visitarToolsQA(ElementsLinks.Links); | ||
}); | ||
|
||
describe('Open new tab', () => { | ||
describe('Simple Link', () => { | ||
it.only('Check FrontEnd (Opens New Tab)', () => { | ||
Links.getsimpleLink().then(($link) => { | ||
cy.visit(Links.getPropHref($link)); | ||
cy.url().should('be.equal', `${baseUrl}/`); | ||
Links.checkRedirectFrontHome(); | ||
}); | ||
}); | ||
|
||
it('Check Backend (API)', () => { | ||
Links.getsimpleLink().then(($link) => { | ||
cy.request(Links.getPropHref($link)).as('request'); | ||
|
||
cy.get('@request').then((response) => { | ||
//@ts-ignore | ||
let urlRecebida = response.allRequestResponses[0]['Request URL']; | ||
//@ts-ignore | ||
Links.expectStatus(response.status, 200); | ||
Links.expectUrl(urlRecebida, `${baseUrl}/`); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Dynamic Link', () => { | ||
it('Check FrontEnd (Opens New Tab)', () => { | ||
Links.getDynamicLink().then(($link) => { | ||
cy.visit(Links.getPropHref($link)); | ||
cy.url().should('be.equal', `${baseUrl}/`); | ||
Links.checkRedirectFrontHome(); | ||
}); | ||
}); | ||
it('Check Backend (API)', () => { | ||
Links.getDynamicLink().then(($link) => { | ||
cy.request(Links.getPropHref($link)).as('request'); | ||
|
||
cy.get('@request').then((response) => { | ||
//@ts-ignore | ||
let urlRecebida = response.allRequestResponses[0]['Request URL']; | ||
//@ts-ignore | ||
Links.expectStatus(response.status, 200); | ||
Links.expectUrl(urlRecebida, `${baseUrl}/`); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Send an api call', () => { | ||
it('Created', () => { | ||
cy.intercept('GET', `**${Link.Created}`).as('intercept'); | ||
|
||
Links.createdLink(); | ||
|
||
cy.wait('@intercept').then(({ request, response }) => { | ||
Links.expectUrl(request.url, `${baseUrl}${Link.Created}`); | ||
Links.expectStatus(response?.statusCode, 201); | ||
}); | ||
}); | ||
|
||
it('No Content', () => { | ||
cy.intercept('GET', `**${Link.NoContent}`).as('intercept'); | ||
|
||
Links.noContentLink(); | ||
|
||
cy.wait('@intercept').then(({ request, response }) => { | ||
Links.expectUrl(request.url, `${baseUrl}${Link.NoContent}`); | ||
Links.expectStatus(response?.statusCode, 204); | ||
}); | ||
}); | ||
|
||
it('Moved', () => { | ||
cy.intercept('GET', `**${Link.Moved}`).as('intercept'); | ||
|
||
Links.movedLink(); | ||
|
||
cy.wait('@intercept').then(({ request, response }) => { | ||
Links.expectUrl(request.url, `${baseUrl}${Link.Moved}`); | ||
Links.expectStatus(response?.statusCode, 301); | ||
}); | ||
}); | ||
|
||
it('Bad Request', () => { | ||
cy.intercept('GET', `**${Link.BadRequest}`).as('intercept'); | ||
|
||
Links.badRequestLink(); | ||
|
||
cy.wait('@intercept').then(({ request, response }) => { | ||
Links.expectUrl(request.url, `${baseUrl}${Link.BadRequest}`); | ||
Links.expectStatus(response?.statusCode, 400); | ||
}); | ||
}); | ||
|
||
it('Unauthorized', () => { | ||
cy.intercept('GET', `**${Link.Unauthorized}`).as('intercept'); | ||
|
||
Links.unauthorizedLink(); | ||
|
||
cy.wait('@intercept').then(({ request, response }) => { | ||
Links.expectUrl(request.url, `${baseUrl}${Link.Unauthorized}`); | ||
Links.expectStatus(response?.statusCode, 401); | ||
}); | ||
}); | ||
|
||
it('Forbidden', () => { | ||
cy.intercept('GET', `**${Link.Forbidden}`).as('intercept'); | ||
|
||
Links.forbiddenLink(); | ||
|
||
cy.wait('@intercept').then(({ request, response }) => { | ||
Links.expectUrl(request.url, `${baseUrl}${Link.Forbidden}`); | ||
Links.expectStatus(response?.statusCode, 403); | ||
}); | ||
}); | ||
|
||
it('Not Found', () => { | ||
cy.intercept('GET', `**${Link.NotFound}`).as('intercept'); | ||
|
||
Links.notFoundLink(); | ||
|
||
cy.wait('@intercept').then(({ request, response }) => { | ||
Links.expectUrl(request.url, `${baseUrl}${Link.NotFound}`); | ||
Links.expectStatus(response?.statusCode, 404); | ||
}); | ||
}); | ||
}); |
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
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
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,13 @@ | ||
const LinksLocators = { | ||
simple: 'p>a#simpleLink', | ||
dynamic: 'p>a#dynamicLink', | ||
created: 'p>a#created', | ||
noContent: 'p>a#no-content', | ||
moved: 'p>a#moved', | ||
badRequest: 'p>a#bad-request', | ||
unauthorized: 'p>a#unauthorized', | ||
forbidden: 'p>a#forbidden', | ||
notFound: 'p>a#invalid-url', | ||
}; | ||
|
||
export default LinksLocators; |
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 @@ | ||
import locators from './LinksLocators'; | ||
import homeLocators from '@pageObject/home/HomeLocators'; | ||
import Cards from '@enum/Cards'; | ||
|
||
class LinksPage { | ||
getsimpleLink() { | ||
return cy.get(locators.simple).click(); | ||
} | ||
|
||
getDynamicLink() { | ||
return cy.get(locators.dynamic).click(); | ||
} | ||
|
||
getPropHref($link: JQuery<HTMLElement>) { | ||
return $link.prop('href'); | ||
} | ||
|
||
createdLink() { | ||
cy.get(locators.created).click(); | ||
} | ||
|
||
noContentLink() { | ||
cy.get(locators.noContent).click(); | ||
} | ||
|
||
movedLink() { | ||
cy.get(locators.moved).click(); | ||
} | ||
|
||
badRequestLink() { | ||
cy.get(locators.badRequest).click(); | ||
} | ||
|
||
unauthorizedLink() { | ||
cy.get(locators.unauthorized).click(); | ||
} | ||
|
||
forbiddenLink() { | ||
cy.get(locators.forbidden).click(); | ||
} | ||
|
||
notFoundLink() { | ||
cy.get(locators.notFound).click(); | ||
} | ||
|
||
expectStatus(statusRecebido: number | undefined, cod: number) { | ||
expect(statusRecebido).be.equal(cod); | ||
} | ||
|
||
expectUrl(urlRecebida: string | undefined, urlEsperada: string) { | ||
expect(urlRecebida).be.equal(urlEsperada); | ||
} | ||
|
||
expectRequestUrl(requestUrl: string, urlEsperada: string) { | ||
expect(requestUrl).be.equal(urlEsperada); | ||
} | ||
|
||
checkRedirectFrontHome() { | ||
cy.xpath(homeLocators.cardXpath(Cards.Elements)).should('be.visible'); | ||
} | ||
} | ||
|
||
export default LinksPage; |
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,11 @@ | ||
enum Links { | ||
Created = '/created', | ||
NoContent = '/no-content', | ||
Moved = '/moved', | ||
BadRequest = '/bad-request', | ||
Unauthorized = '/unauthorized', | ||
Forbidden = '/forbidden', | ||
NotFound = '/invalid-url', | ||
} | ||
|
||
export default Links; |
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
Oops, something went wrong.