forked from verdnatura/hedera-web
More tests
This commit is contained in:
parent
693b309e79
commit
ff423ae79b
|
@ -73,6 +73,7 @@
|
|||
"test:e2e": "cd ../salix && gulp docker && cd ../hedera-web && cypress run",
|
||||
"cy:open-mindshore": "cd ../salix && gulp docker && cd ../hedera-web-mindshore && cypress open",
|
||||
"test:e2e-mindshore": "cd ../salix && gulp docker && cd ../hedera-web-mindshore && cypress run",
|
||||
"resetDatabase": "cd ../salix && gulp docker",
|
||||
"build": "rm -rf build/ ; webpack",
|
||||
"clean": "rm -rf build/",
|
||||
"lint": "eslint --ext .js,.vue ./"
|
||||
|
|
|
@ -87,7 +87,9 @@ const logoutSupplantedUser = async () => {
|
|||
</QToolbar>
|
||||
<div class="user-info">
|
||||
<div>
|
||||
<span id="user-name">{{ mainUser?.nickname }}</span>
|
||||
<span id="user-name" data-testid="layoutUserName">
|
||||
{{ mainUser?.nickname }}
|
||||
</span>
|
||||
<QBtn
|
||||
flat
|
||||
icon="logout"
|
||||
|
@ -96,7 +98,12 @@ const logoutSupplantedUser = async () => {
|
|||
data-testid="logoutButton"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="supplantedUser" id="supplant" class="supplant">
|
||||
<div
|
||||
v-if="supplantedUser"
|
||||
id="supplant"
|
||||
class="supplant"
|
||||
data-testid="layoutSupplantedUserName"
|
||||
>
|
||||
<span id="supplanted">
|
||||
{{ supplantedUser?.nickname }}
|
||||
</span>
|
||||
|
|
|
@ -115,6 +115,7 @@ onMounted(() => fetchLanguagesSql());
|
|||
:label="t('nickname')"
|
||||
@keyup.enter="updateUserNickname(data.nickname)"
|
||||
@blur="updateUserNickname(data.nickname)"
|
||||
data-testid="configViewNickname"
|
||||
/>
|
||||
<VnSelect
|
||||
v-model="data.lang"
|
||||
|
|
|
@ -47,6 +47,7 @@ const supplantUser = async user => {
|
|||
search-field="user"
|
||||
@on-search="onSearch"
|
||||
@on-search-error="users = []"
|
||||
data-testid="usersViewSearchBar"
|
||||
/>
|
||||
</Teleport>
|
||||
<QPage class="vn-w-xs">
|
||||
|
@ -56,11 +57,13 @@ const supplantUser = async user => {
|
|||
empty-icon="refresh"
|
||||
:loading="loading"
|
||||
:rows="users"
|
||||
data-testid="usersViewList"
|
||||
>
|
||||
<CardList
|
||||
v-for="(user, index) in users"
|
||||
:key="index"
|
||||
:to="{ name: 'accessLog', params: { id: user.id } }"
|
||||
data-testid="userViewCard"
|
||||
>
|
||||
<template #content>
|
||||
<span class="text-bold q-mb-sm">
|
||||
|
@ -75,6 +78,7 @@ const supplantUser = async user => {
|
|||
flat
|
||||
rounded
|
||||
@click.stop.prevent="supplantUser(user.name)"
|
||||
data-testid="usersViewSupplantUserBtn"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Impersonate user') }}
|
||||
|
|
|
@ -122,6 +122,7 @@ const fetchData = async () => {
|
|||
:to="{ name: 'confirm', params: { id: orderId } }"
|
||||
rounded
|
||||
no-caps
|
||||
data-testid="basketToConfirmBtn"
|
||||
>
|
||||
<QTooltip>{{ t('checkout') }}</QTooltip>
|
||||
</QBtn>
|
||||
|
|
|
@ -111,7 +111,7 @@ const deleteRow = id => {
|
|||
</QCardSection>
|
||||
<QSeparator v-if="showItems" inset />
|
||||
<QList v-for="(row, index) in rows" :key="index">
|
||||
<QItem v-if="row">
|
||||
<QItem v-if="row" data-testid="basketItemRow">
|
||||
<QItemSection v-if="canDeleteItems" avatar>
|
||||
<QBtn
|
||||
icon="delete"
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
describe('User flow: Login, create a new order, add item to basket', () => {
|
||||
describe('User flow: Login, create a new order, add item to basket and go to confirm view', () => {
|
||||
it('success', () => {
|
||||
// 2- Loguear como empleado
|
||||
// 1- Loguear como empleado
|
||||
cy.login('employee');
|
||||
// 2- Crear una orden
|
||||
cy.createOrderReceiveFlow();
|
||||
// 3- Filtrar items y agregar item al carrito
|
||||
cy.addItemToBasketFlow();
|
||||
// 4- Ir al carrito
|
||||
cy.dataCy('catalogGoToBasketButton').should('exist');
|
||||
cy.dataCy('catalogGoToBasketButton').click();
|
||||
cy.url().should('contain', '/#/ecomerce/basket');
|
||||
// 5- Verificar que el item se agregó al carrito
|
||||
cy.dataCy('basketItemRow').should('exist');
|
||||
cy.dataCy('basketItemRow').should('have.length', 1);
|
||||
// 6- Ir a la vista de confirmación
|
||||
cy.dataCy('basketToConfirmBtn').should('exist');
|
||||
cy.dataCy('basketToConfirmBtn').click();
|
||||
cy.url().should('contain', '/#/ecomerce/confirm');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
Cypress.Commands.add('userViewSupplant', user => {
|
||||
cy.dataCy('usersViewSearchBar').should('exist');
|
||||
cy.get('input[data-testid="usersViewSearchBar"]').type(`${user}{enter}`);
|
||||
cy.dataCy('layoutSupplantedUserName').should('not.exist');
|
||||
cy.dataCy('usersViewList').should('not.contain', 'Sin datos');
|
||||
cy.dataCy('userViewCard').should('exist');
|
||||
cy.dataCy('usersViewSupplantUserBtn').click();
|
||||
cy.dataCy('layoutSupplantedUserName').should('exist');
|
||||
cy.dataCy('layoutSupplantedUserName').should('contain', user);
|
||||
});
|
|
@ -0,0 +1,32 @@
|
|||
describe('UsersView', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('adminboss');
|
||||
cy.visit('/#/admin/users');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cy.logout();
|
||||
});
|
||||
|
||||
it('should show empty state when entering the view', () => {
|
||||
cy.dataCy('usersViewList').should('contain', 'Sin datos');
|
||||
});
|
||||
|
||||
it('supplants user', () => {
|
||||
cy.userViewSupplant('Bruce Wayne');
|
||||
cy.getSessionStorage('supplantUser').should('equal', 'brucewayne');
|
||||
});
|
||||
|
||||
it('makes actions for the supplanted user', () => {
|
||||
cy.userViewSupplant('Bruce Wayne');
|
||||
cy.wait(100);
|
||||
cy.visit('/#/account/conf');
|
||||
cy.url().should('contain', '/#/account/conf');
|
||||
cy.changeUserNickname('Bruce Wayne', 'New test nickname');
|
||||
cy.dataCy('layoutSupplantedUserName').should(
|
||||
'contain',
|
||||
'New test nickname'
|
||||
);
|
||||
cy.clearDB();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
Cypress.Commands.add('changeUserNickname', (oldNickname, newNickname) => {
|
||||
const nicknameInput = 'input[data-testid="configViewNickname"]';
|
||||
cy.get(nicknameInput).should('exist');
|
||||
cy.getValue('input[data-testid="configViewNickname"]').should(
|
||||
'equal',
|
||||
oldNickname
|
||||
);
|
||||
cy.get(nicknameInput).clear();
|
||||
cy.get(nicknameInput).type(newNickname);
|
||||
cy.get(nicknameInput).blur();
|
||||
cy.dataCy('positiveNotify').should('contain', 'Datos guardados');
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
describe('Changes user nickname', () => {
|
||||
it('success', () => {
|
||||
cy.changeUserNickname('Bruce Wayne', 'New test nickname');
|
||||
});
|
||||
});
|
|
@ -63,8 +63,22 @@ Cypress.Commands.add('getSessionStorage', key => {
|
|||
cy.window().then(window => window.sessionStorage.getItem(key));
|
||||
});
|
||||
|
||||
Cypress.Commands.add('getLocalStorage', key => {
|
||||
cy.window().then(window => window.localStorage.getItem(key));
|
||||
});
|
||||
|
||||
Cypress.Commands.add('setLocalStorage', (key, value) => {
|
||||
cy.window().then(window => {
|
||||
window.localStorage.setItem(key, value);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('setSessionStorage', (key, value) => {
|
||||
cy.window().then(window => {
|
||||
window.sessionStorage.setItem(key, value);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clearDB', () => {
|
||||
cy.exec('npm run resetDatabase');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue