-
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.
- Loading branch information
Showing
13 changed files
with
257 additions
and
133 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -1,7 +1,20 @@ | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
chromeWebSecurity: false, | ||
e2e: { | ||
supportFile: false | ||
} | ||
baseUrl: 'https://localhost:4322', | ||
// supportFile: "cypress/support/commands.js", | ||
supportFile: false, | ||
}, | ||
// env: { | ||
// googleRefreshToken: 'xxxxxxx', | ||
// googleClientId: 'xxxxxxx', | ||
// googleClientSecret: 'xxxxxxx', | ||
// }, | ||
video: false, | ||
retries: { | ||
runMode: 2, | ||
openMode: 0, | ||
}, | ||
}) |
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 |
---|---|---|
@@ -1,5 +1,16 @@ | ||
it('titles are correct', () => { | ||
const page = cy.visit('https://localhost:4322'); | ||
page.get('title').should('have.text'); | ||
// page.get('h1').should('hytave.text'); | ||
describe('Página de inicio', () => { | ||
beforeEach(() => { | ||
// Visita la página de inicio antes de cada prueba | ||
cy.visit('/') | ||
}) | ||
|
||
it('El título de la página no está vacío', () => { | ||
// Verifica que el título de la página no esté vacío | ||
cy.title().should('not.be.empty'); | ||
}); | ||
|
||
it('El título de la página es correcto', () => { | ||
// Verifica que el título de la página sea igual a 'Home' | ||
cy.title().should('eq', 'Home'); | ||
}); | ||
}); |
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,80 @@ | ||
const cookieValue = { | ||
sessionState: 2, | ||
sessionInfo: { | ||
OAuth: { user: { | ||
id: 1, | ||
name: 'Víctor', | ||
email: '[email protected]', | ||
image: 'https://lh3.googleusercontent.com/a/ACg8ocKzfoTnzs-nio7LCynxeRM-_zVyswLSKkOOgStQ3fhxKbgzizZl1Q=s96-c', | ||
}, expires: '2024-07-18T18:33:37.885Z' }, | ||
profile: { | ||
id: 1, | ||
name: 'Víctor', | ||
surname: 'Valdés Cobos', | ||
email: '[email protected]', | ||
phone_number: '123459789', | ||
address: '123 Main St', | ||
city: 'New York', | ||
bornDate: '1990-01-01T00:00:00.000Z', | ||
created_at: '2024-06-08T23:11:00.000Z', | ||
updated_at: '2024-06-08T23:11:00.000Z', | ||
username: 'johndoedd', | ||
image: '', | ||
active: true | ||
}, | ||
role: 'Clients', | ||
profilePhotoSrc: 'https://lh3.googleusercontent.com/a/ACg8ocKzfoTnzs-nio7LCynxeRM-_zVyswLSKkOOgStQ3fhxKbgzizZl1Q=s96-c' | ||
} | ||
}; | ||
|
||
const APP_SELECTOR = '#App'; | ||
const HEADER_SELECTOR = 'header'; | ||
const FOOTER_SELECTOR = 'footer'; | ||
const PROFILETHUMB_SELECTOR = '#profileThumb_header'; | ||
|
||
describe('Layout', () => { | ||
beforeEach(() => { | ||
// Visita la página inicial antes de cada prueba | ||
cy.visit('/') | ||
cy.setCookie('sessionInfoState', JSON.stringify(cookieValue)); | ||
cy.visit('/') | ||
}) | ||
|
||
it('Los títulos no están vacíos', () => { | ||
// Verifica que el título de la página no esté vacío | ||
cy.title().should('not.be.empty'); | ||
}); | ||
|
||
it('Main container is in DOM', () => { | ||
// Verifica que el contenedor principal exista y sea visible | ||
cy.get(APP_SELECTOR).should('exist').and('be.visible'); | ||
}); | ||
|
||
it('Header set', () => { | ||
// Verifica que el encabezado exista | ||
cy.get(HEADER_SELECTOR).should('exist').and('be.visible'); | ||
}) | ||
|
||
it('Footer set', () => { | ||
// Verifica que el pie de página exista | ||
cy.get(FOOTER_SELECTOR).should('exist').and('be.visible') | ||
}) | ||
|
||
it('Profilephoto exists', () => { | ||
// Verifica que la imagen exista | ||
cy.get('#profileThumb_header') | ||
.should('be.visible') | ||
}) | ||
}) | ||
|
||
it('Profilephoto src is set', () => { | ||
// Verifica que el atributo src del elemento img del encabezado exista | ||
cy.visit('/') | ||
cy.setCookie('sessionInfoState', JSON.stringify(cookieValue)); | ||
cy.visit('/') | ||
cy.intercept('GET', 'https://lh3.googleusercontent.com/a/ACg8ocKzfoTnzs-nio7LCynxeRM-_zVyswLSKkOOgStQ3fhxKbgzizZl1Q=s96-c').as('getProfilePhoto'); | ||
cy.wait('@getProfilePhoto'); | ||
cy.get('#profileThumb_header') | ||
.should('have.attr', 'srcset') | ||
.and('be.a', 'image'); | ||
}); |
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,45 @@ | ||
const cookieValue = { | ||
sessionState: 2, | ||
sessionInfo: { | ||
OAuth: { user: { | ||
id: 1, | ||
name: 'Víctor', | ||
email: '[email protected]', | ||
image: 'https://lh3.googleusercontent.com/a/ACg8ocKzfoTnzs-nio7LCynxeRM-_zVyswLSKkOOgStQ3fhxKbgzizZl1Q=s96-c', | ||
}, expires: '2024-07-18T18:33:37.885Z' }, | ||
profile: { | ||
id: 1, | ||
name: 'Víctor', | ||
surname: 'Valdés Cobos', | ||
email: '[email protected]', | ||
phone_number: '123459789', | ||
address: '123 Main St', | ||
city: 'New York', | ||
bornDate: '1990-01-01T00:00:00.000Z', | ||
created_at: '2024-06-08T23:11:00.000Z', | ||
updated_at: '2024-06-08T23:11:00.000Z', | ||
username: 'johndoedd', | ||
image: '', | ||
active: true | ||
}, | ||
role: 'Clients', | ||
profilePhotoSrc: 'https://lh3.googleusercontent.com/a/ACg8ocKzfoTnzs-nio7LCynxeRM-_zVyswLSKkOOgStQ3fhxKbgzizZl1Q=s96-c' | ||
} | ||
}; | ||
|
||
const APP_SELECTOR = '#App'; | ||
const HEADER_SELECTOR = 'header'; | ||
const FOOTER_SELECTOR = 'footer'; | ||
const PROFILETHUMB_SELECTOR = '#profileThumb_registro'; | ||
|
||
describe('Perfil', () => { | ||
beforeEach(() => { | ||
cy.visit('/') | ||
cy.setCookie('sessionInfoState', JSON.stringify(cookieValue)); | ||
cy.visit('/perfil') | ||
}); | ||
|
||
it('should have main thumbnail', () => { | ||
cy.get(PROFILETHUMB_SELECTOR).should('exist').and('be.visible'); | ||
}); | ||
}); |
Binary file not shown.
Binary file added
BIN
+40.5 KB
...ut.cy.js/Layout -- Los títulos no están vacíos -- before each hook (failed).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,36 @@ | ||
Cypress.Commands.add('loginByGoogleApi', () => { | ||
cy.log('Logging in to Google') | ||
cy.request({ | ||
method: 'POST', | ||
url: 'https://www.googleapis.com/oauth2/v4/token', | ||
body: { | ||
grant_type: 'refresh_token', | ||
client_id: Cypress.env('googleClientId'), | ||
client_secret: Cypress.env('googleClientSecret'), | ||
refresh_token: Cypress.env('googleRefreshToken'), | ||
}, | ||
}).then(({ body }) => { | ||
const { access_token, id_token } = body | ||
|
||
cy.request({ | ||
method: 'GET', | ||
url: 'https://www.googleapis.com/oauth2/v3/userinfo', | ||
headers: { Authorization: `Bearer ${access_token}` }, | ||
}).then(({ body }) => { | ||
cy.log(body) | ||
const userItem = { | ||
token: id_token, | ||
user: { | ||
googleId: body.sub, | ||
email: body.email, | ||
givenName: body.given_name, | ||
familyName: body.family_name, | ||
imageUrl: body.picture, | ||
}, | ||
} | ||
|
||
window.localStorage.setItem('googleCypress', JSON.stringify(userItem)) | ||
cy.visit('/') | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.