0
0
Fork 0

refs #5255 tests fixed

This commit is contained in:
Alexandre Riera 2023-04-27 10:40:00 +02:00
parent 0096851894
commit cacd36a854
7 changed files with 41 additions and 31 deletions

View File

@ -58,9 +58,12 @@ const onResponseError = (error) => {
break; break;
} }
if (session.isLoggedIn && response.status === 401) { if (session.isLoggedIn() && response.status === 401) {
session.destroy(); session.destroy();
Router.push({ path: '/login' }); Router.push({ path: '/login' });
} else if(!session.isLoggedIn())
{
message = 'login.loginError';
} }
Notify.create({ Notify.create({

View File

@ -48,25 +48,29 @@ const password = ref('');
const keepLogin = ref(true); const keepLogin = ref(true);
async function onSubmit() { async function onSubmit() {
const { data } = await axios.post('Accounts/login', { try {
user: username.value, const { data } = await axios.post('Accounts/login', {
password: password.value, user: username.value,
}); password: password.value,
});
if (!data) return; if (!data) return;
await session.login(data.token, keepLogin.value); await session.login(data.token, keepLogin.value);
quasar.notify({ quasar.notify({
message: t('login.loginSuccess'), message: t('login.loginSuccess'),
type: 'positive', type: 'positive',
}); });
const currentRoute = router.currentRoute.value; const currentRoute = router.currentRoute.value;
if (currentRoute.query && currentRoute.query.redirect) { if (currentRoute.query && currentRoute.query.redirect) {
router.push(currentRoute.query.redirect); router.push(currentRoute.query.redirect);
} else { } else {
router.push({ name: 'Dashboard' }); router.push({ name: 'Dashboard' });
}
} catch (e) {
//
} }
} }
</script> </script>

View File

@ -43,13 +43,13 @@ describe('ClaimPhoto', () => {
cy.get( cy.get(
'.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon' '.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon'
).click(); ).click();
cy.get('.q-btn--standard > .q-btn__content > .block').click(); cy.get('.q-btn--unelevated > .q-btn__content > .block').click();
cy.get('.q-notification__message').should('have.text', 'Data deleted'); cy.get('.q-notification__message').should('have.text', 'Data deleted');
cy.get( cy.get(
'.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon' '.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon'
).click(); ).click();
cy.get('.q-btn--standard > .q-btn__content > .block').click(); cy.get('.q-btn--unelevated > .q-btn__content > .block').click();
cy.get('.q-notification__message').should('have.text', 'Data deleted'); cy.get('.q-notification__message').should('have.text', 'Data deleted');
}); });
}); });

View File

@ -1,5 +1,5 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
xdescribe('TicketBoxing', () => { describe('TicketBoxing', () => {
beforeEach(() => { beforeEach(() => {
const ticketId = 1; const ticketId = 1;
cy.viewport(1280, 720); cy.viewport(1280, 720);
@ -26,9 +26,9 @@ xdescribe('TicketBoxing', () => {
}, },
['2022-01-01T01-01-00.mp4', '2022-02-02T02-02-00.mp4', '2022-03-03T03-03-00.mp4'] ['2022-01-01T01-01-00.mp4', '2022-02-02T02-02-00.mp4', '2022-03-03T03-03-00.mp4']
).as('getVideoList'); ).as('getVideoList');
cy.get('.q-list > :nth-child(3)').click(); cy.get('.q-list').eq(3).find('.q-item').eq(2).click();
cy.get('.q-list > :nth-child(1)').should('be.visible'); cy.get('.q-list').eq(3).find('.q-item').eq(0).find('.q-range');
cy.get('.q-list > :nth-child(2)').should('be.visible'); cy.get('.q-list').eq(3).find('.q-item').eq(1).find('.q-select');
}); });
}); });

View File

@ -12,7 +12,10 @@ describe('WorkerList', () => {
}); });
it('should open the worker summary', () => { it('should open the worker summary', () => {
cy.get('div[class="q-item__section column q-item__section--side justify-center q-pa-md"]').eq(0).click(); cy.get('div.text-h6')
.parentsUntil('div.q-card')
.find('div.q-card__actions')
.find('button').first().click();
cy.get('div[class="header bg-primary q-pa-sm q-mb-md"').should('have.text', '1110 - Jessica Jones'); cy.get('div[class="header bg-primary q-pa-sm q-mb-md"').should('have.text', '1110 - Jessica Jones');
cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(0).should('have.text', 'Basic data'); cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(0).should('have.text', 'Basic data');
cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(1).should('have.text', 'User data'); cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(1).should('have.text', 'User data');

View File

@ -6,10 +6,10 @@ describe('WorkerSummary', () => {
}); });
it('should load worker summary', () => { it('should load worker summary', () => {
cy.get('div[class="header bg-primary q-pa-sm q-mb-md"').should('have.text', '19 - salesBoss'); cy.get('div[class="header bg-primary q-pa-sm q-mb-md"').should('have.text', '19 - salesBoss salesBoss');
cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(0).should('have.text', 'Basic data'); cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(0).should('have.text', 'Basic data');
cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(1).should('have.text', 'User data'); cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(1).should('have.text', 'User data');
cy.get('div[class="q-item__section column q-item__section--main justify-center"]').eq(0).should('have.text', 'NamesalesBossNick'); cy.get('div[class="q-item__section column q-item__section--main justify-center"]').eq(0).should('have.text', 'NamesalesBossNick');
}); });
}); });

View File

@ -1,15 +1,15 @@
import { vi, describe, expect, it } from 'vitest'; import { Notify } from 'quasar';
import { onRequest, onResponseError } from 'src/boot/axios'; import { onRequest, onResponseError } from 'src/boot/axios';
import { Notify } from 'quasar' import { describe, expect, it, vi } from 'vitest';
vi.mock('src/composables/useSession', () => ({ vi.mock('src/composables/useSession', () => ({
useSession: () => ({ useSession: () => ({
getToken: () => 'DEFAULT_TOKEN' getToken: () => 'DEFAULT_TOKEN',
}), isLoggedIn: () => vi.fn(),
destroy: () => vi.fn(),
})
})); }));
vi.mock('src/router', () => ({}));
describe('Axios boot', () => { describe('Axios boot', () => {
describe('onRequest()', async () => { describe('onRequest()', async () => {