busy-soccer-31234
03/02/2023, 8:46 PMadventurous-dream-20049
03/02/2023, 9:03 PMadventurous-dream-20049
03/02/2023, 9:04 PMbusy-soccer-31234
03/02/2023, 9:23 PMadventurous-dream-20049
03/02/2023, 11:05 PMechoing-tent-95037
03/02/2023, 11:09 PMcy.visit in a beforeEach You would have to more specific on what you need saved between tests.busy-soccer-31234
03/03/2023, 9:24 AMts
describe('private-accommodation', () => {
before(function() {
cy.request({
method: 'POST',
url: '/authorization/authorize',
body: {
email: 'admin',
password: 'admin'
},
}).then((response) => {
const token = response.body.data[0].token;
window.localStorage.setItem('token', token);
expect(response.status).to.eq(200);
});
});
beforeEach(function() {
const token = window.localStorage.getItem('token');
cy.intercept({
url: '/authorization/authorize',
}, (req) => {
req.headers["Authorization"] = `Bearer ${token}`;
});
});
it('typologies_create', () => {
cy.visit('/typologies/create')
cy.get('#name').type('cypress');
cy.contains('button', 'Criar').click().then(() => {
cy.get('#name').invoke('val').then((value) => {
cy.request({
url: '/api/private_accommodation/typologies',
method: 'POST',
failOnStatusCode: false,
headers: {
Authorization: `Bearer ${window.localStorage.getItem('token')}`
},
body: {
name: value
},
}).then((resp) => {
expect(resp.status).to.eq(200);
});
});
});
})
it('not_found_page', () => {
cy.visit('typologies/');
})
})busy-soccer-31234
03/03/2023, 9:31 AMadventurous-dream-20049
03/03/2023, 1:05 PMbusy-soccer-31234
03/03/2023, 1:54 PM