refactor: refs #8484 streamline login command and remove commented code
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2025-02-26 12:37:57 +01:00
parent f48b2bbab4
commit 05fe2b5b21
1 changed files with 38 additions and 18 deletions

View File

@ -35,33 +35,53 @@ Cypress.Commands.add('resetDB', () => {
});
Cypress.Commands.add('login', (user = 'developer') => {
cy.session(['user-session', user], () => {
//cy.visit('/#/login');
cy.request({
method: 'POST',
url: '/api/accounts/login',
body: {
user: user,
password: 'nightmare',
},
}).then((response) => {
window.localStorage.setItem('token', response.body.token);
cy.request({
method: 'POST',
url: '/api/accounts/login',
body: {
user: user,
password: 'nightmare',
method: 'GET',
url: '/api/VnUsers/ShareToken',
headers: {
Authorization: window.localStorage.getItem('token'),
},
}).then((response) => {
window.localStorage.setItem('token', response.body.token);
cy.request({
method: 'GET',
url: '/api/VnUsers/ShareToken',
headers: {
Authorization: window.localStorage.getItem('token'),
},
}).then(({ body }) => {
window.localStorage.setItem('tokenMultimedia', body.multimediaToken.id);
});
}).then(({ body }) => {
window.localStorage.setItem('tokenMultimedia', body.multimediaToken.id);
});
});
// cy.session(['user-session', user], () => {
// cy.request({
// method: 'POST',
// url: '/api/accounts/login',
// body: {
// user: user,
// password: 'nightmare',
// },
// }).then((response) => {
// window.localStorage.setItem('token', response.body.token);
// cy.request({
// method: 'GET',
// url: '/api/VnUsers/ShareToken',
// headers: {
// Authorization: window.localStorage.getItem('token'),
// },
// }).then(({ body }) => {
// window.localStorage.setItem('tokenMultimedia', body.multimediaToken.id);
// });
// });
// });
});
Cypress.Commands.overwrite('visit', (originalFn, url, options) => {
originalFn(url, options);
cy.waitUntil(() => cy.document().then((doc) => doc.readyState === 'complete'));
cy.waitUntil(() => cy.get('main', { timeout: 10000 }).should('exist'));
cy.waitUntil(() => cy.get('main').should('exist'));
});
Cypress.Commands.add('waitForElement', (element, timeout = 10000) => {