refactor: refs #8484 enhance login command with session management and clean up unused commands
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
98363c2197
commit
1acfbfa3cb
|
@ -28,28 +28,31 @@
|
|||
// Imports Quasar Cypress AE predefined commands
|
||||
// import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress';
|
||||
Cypress.Commands.add('waitUntil', { prevSubject: 'optional' }, require('./waitUntil'));
|
||||
|
||||
Cypress.Commands.add('resetDB', () => {
|
||||
cy.exec('pnpm run resetDatabase');
|
||||
});
|
||||
Cypress.Commands.add('login', (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);
|
||||
|
||||
Cypress.Commands.add('login', (user = 'developer') => {
|
||||
cy.session(['user-session', user], () => {
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: '/api/VnUsers/ShareToken',
|
||||
headers: {
|
||||
Authorization: window.localStorage.getItem('token'),
|
||||
method: 'POST',
|
||||
url: '/api/accounts/login',
|
||||
body: {
|
||||
user: user,
|
||||
password: 'nightmare',
|
||||
},
|
||||
}).then(({ body }) => {
|
||||
window.localStorage.setItem('tokenMultimedia', body.multimediaToken.id);
|
||||
}).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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -311,32 +314,6 @@ Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
|||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openActionDescriptor', (opt) => {
|
||||
cy.openActionsDescriptor();
|
||||
const listItem = '[role="menu"] .q-list .q-item';
|
||||
cy.contains(listItem, opt).click();
|
||||
1;
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
||||
cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
|
||||
.invoke('removeAttr', 'target')
|
||||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openActionDescriptor', (opt) => {
|
||||
cy.openActionsDescriptor();
|
||||
const listItem = '[role="menu"] .q-list .q-item';
|
||||
cy.contains(listItem, opt).click();
|
||||
1;
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clickButtonsDescriptor', (id) => {
|
||||
cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
|
||||
.invoke('removeAttr', 'target')
|
||||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openUserPanel', () => {
|
||||
cy.get(
|
||||
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image',
|
||||
|
|
Loading…
Reference in New Issue