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
|
// Imports Quasar Cypress AE predefined commands
|
||||||
// import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress';
|
// import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress';
|
||||||
Cypress.Commands.add('waitUntil', { prevSubject: 'optional' }, require('./waitUntil'));
|
Cypress.Commands.add('waitUntil', { prevSubject: 'optional' }, require('./waitUntil'));
|
||||||
|
|
||||||
Cypress.Commands.add('resetDB', () => {
|
Cypress.Commands.add('resetDB', () => {
|
||||||
cy.exec('pnpm run resetDatabase');
|
cy.exec('pnpm run resetDatabase');
|
||||||
});
|
});
|
||||||
Cypress.Commands.add('login', (user) => {
|
|
||||||
//cy.visit('/#/login');
|
Cypress.Commands.add('login', (user = 'developer') => {
|
||||||
cy.request({
|
cy.session(['user-session', user], () => {
|
||||||
method: 'POST',
|
|
||||||
url: '/api/accounts/login',
|
|
||||||
body: {
|
|
||||||
user: user,
|
|
||||||
password: 'nightmare',
|
|
||||||
},
|
|
||||||
}).then((response) => {
|
|
||||||
window.localStorage.setItem('token', response.body.token);
|
|
||||||
cy.request({
|
cy.request({
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
url: '/api/VnUsers/ShareToken',
|
url: '/api/accounts/login',
|
||||||
headers: {
|
body: {
|
||||||
Authorization: window.localStorage.getItem('token'),
|
user: user,
|
||||||
|
password: 'nightmare',
|
||||||
},
|
},
|
||||||
}).then(({ body }) => {
|
}).then((response) => {
|
||||||
window.localStorage.setItem('tokenMultimedia', body.multimediaToken.id);
|
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();
|
.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', () => {
|
Cypress.Commands.add('openUserPanel', () => {
|
||||||
cy.get(
|
cy.get(
|
||||||
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image',
|
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image',
|
||||||
|
|
Loading…
Reference in New Issue