227 lines
8.1 KiB
JavaScript
227 lines
8.1 KiB
JavaScript
describe('Entry', () => {
|
|
beforeEach(() => {
|
|
cy.viewport(1920, 1080);
|
|
cy.login('buyer');
|
|
cy.visit(`/#/entry/list`);
|
|
});
|
|
|
|
it('Filter deleted entries and other fields', () => {
|
|
createEntry();
|
|
cy.get('.q-notification__message').eq(0).should('have.text', 'Data created');
|
|
cy.waitForElement('[data-cy="entry-buys"]');
|
|
deleteEntry();
|
|
cy.typeSearchbar('{enter}');
|
|
cy.get('span[title="Date"]').click().click();
|
|
cy.typeSearchbar('{enter}');
|
|
cy.url().should('include', 'order');
|
|
cy.get('td[data-row-index="0"][data-col-field="landed"]').should(
|
|
'have.text',
|
|
'-',
|
|
);
|
|
});
|
|
|
|
it('Create entry, modify travel and add buys', () => {
|
|
createEntryAndBuy();
|
|
cy.get('a[data-cy="EntryBasicData-menu-item"]').click();
|
|
selectTravel('two');
|
|
cy.saveCard();
|
|
cy.get('.q-notification__message').eq(0).should('have.text', 'Data created');
|
|
deleteEntry();
|
|
});
|
|
|
|
it('Clone entry and recalculate rates', () => {
|
|
createEntry();
|
|
|
|
cy.waitForElement('[data-cy="entry-buys"]');
|
|
|
|
cy.url().then((previousUrl) => {
|
|
cy.get('[data-cy="descriptor-more-opts"]').click();
|
|
cy.get('div[data-cy="clone-entry"]').should('be.visible').click();
|
|
|
|
cy.get('.q-notification__message').eq(1).should('have.text', 'Entry cloned');
|
|
|
|
cy.url()
|
|
.should('not.eq', previousUrl)
|
|
.then(() => {
|
|
cy.waitForElement('[data-cy="entry-buys"]');
|
|
|
|
cy.get('[data-cy="descriptor-more-opts"]').click();
|
|
cy.get('div[data-cy="recalculate-rates"]').click();
|
|
|
|
cy.get('.q-notification__message')
|
|
.eq(2)
|
|
.should('have.text', 'Entry prices recalculated');
|
|
|
|
cy.get('[data-cy="descriptor-more-opts"]').click();
|
|
deleteEntry();
|
|
|
|
cy.log(previousUrl);
|
|
|
|
cy.visit(previousUrl);
|
|
|
|
cy.waitForElement('[data-cy="entry-buys"]');
|
|
deleteEntry();
|
|
});
|
|
});
|
|
});
|
|
|
|
it('Should notify when entry is lock by another user', () => {
|
|
const checkLockMessage = () => {
|
|
cy.get('[data-cy="entry-lock-confirm"]').should('be.visible');
|
|
cy.get('[data-cy="VnConfirm_message"] > span').should(
|
|
'contain.text',
|
|
'This entry has been locked by buyerNick',
|
|
);
|
|
};
|
|
|
|
createEntry();
|
|
goToEntryBuys();
|
|
cy.get('.q-notification__message')
|
|
.eq(1)
|
|
.should('have.text', 'The entry has been locked successfully');
|
|
|
|
cy.login('logistic');
|
|
cy.reload();
|
|
checkLockMessage();
|
|
cy.get('[data-cy="VnConfirm_cancel"]').click();
|
|
cy.url().should('include', 'summary');
|
|
|
|
goToEntryBuys();
|
|
checkLockMessage();
|
|
cy.get('[data-cy="VnConfirm_confirm"]').click();
|
|
cy.url().should('include', 'buys');
|
|
|
|
deleteEntry();
|
|
});
|
|
|
|
it('Edit buys and use toolbar actions', () => {
|
|
const COLORS = {
|
|
negative: 'rgb(251, 82, 82)',
|
|
positive: 'rgb(200, 228, 132)',
|
|
enabled: 'rgb(255, 255, 255)',
|
|
disable: 'rgb(168, 168, 168)',
|
|
};
|
|
|
|
const selectCell = (field, row = 0) =>
|
|
cy.get(`td[data-col-field="${field}"][data-row-index="${row}"]`);
|
|
const selectSpan = (field, row = 0) => selectCell(field, row).find('div > span');
|
|
const selectButton = (cySelector) => cy.get(`button[data-cy="${cySelector}"]`);
|
|
const clickAndType = (field, value, row = 0) =>
|
|
selectCell(field, row).click().type(value);
|
|
const checkText = (field, expectedText, row = 0) =>
|
|
selectCell(field, row).should('have.text', expectedText);
|
|
const checkColor = (field, expectedColor, row = 0) =>
|
|
selectSpan(field, row).should('have.css', 'color', expectedColor);
|
|
|
|
createEntryAndBuy();
|
|
|
|
selectCell('isIgnored')
|
|
.click()
|
|
.click()
|
|
.trigger('keydown', { key: 'Tab', keyCode: 9, which: 9 });
|
|
checkText('isIgnored', 'check');
|
|
checkColor('quantity', COLORS.negative);
|
|
|
|
clickAndType('stickers', '1');
|
|
checkText('quantity', '11');
|
|
checkText('amount', '550');
|
|
clickAndType('packing', '2');
|
|
checkText('packing', '12close');
|
|
checkText('weight', '12');
|
|
checkText('quantity', '132');
|
|
checkText('amount', '6600');
|
|
checkColor('packing', COLORS.enabled);
|
|
|
|
selectCell('groupingMode').click().click().click();
|
|
checkColor('packing', COLORS.disable);
|
|
checkColor('grouping', COLORS.enabled);
|
|
|
|
selectCell('buyingValue').click().clear().type('{backspace}{backspace}1');
|
|
checkText('amount', '132');
|
|
checkColor('minPrice', COLORS.disable);
|
|
|
|
selectCell('hasMinPrice').click().click();
|
|
checkColor('minPrice', COLORS.enabled);
|
|
selectCell('hasMinPrice').click();
|
|
|
|
cy.saveCard();
|
|
cy.get('span[data-cy="footer-stickers"]').should('have.text', '11');
|
|
cy.get('.q-notification__message').contains('Data saved');
|
|
|
|
selectButton('change-quantity-sign').should('be.disabled');
|
|
selectButton('check-buy-amount').should('be.disabled');
|
|
cy.get('tr.cursor-pointer > .q-table--col-auto-width > .q-checkbox').click();
|
|
selectButton('change-quantity-sign').should('be.enabled');
|
|
selectButton('check-buy-amount').should('be.enabled');
|
|
|
|
selectButton('change-quantity-sign').click();
|
|
selectButton('set-negative-quantity').click();
|
|
checkText('quantity', '-132');
|
|
selectButton('set-positive-quantity').click();
|
|
checkText('quantity', '132');
|
|
checkColor('amount', COLORS.disable);
|
|
|
|
selectButton('check-buy-amount').click();
|
|
selectButton('uncheck-amount').click();
|
|
checkColor('amount', COLORS.disable);
|
|
|
|
selectButton('check-amount').click();
|
|
checkColor('amount', COLORS.positive);
|
|
cy.saveCard();
|
|
|
|
cy.get('span[data-cy="footer-amount"]').should(
|
|
'have.css',
|
|
'color',
|
|
COLORS.positive,
|
|
);
|
|
|
|
deleteEntry();
|
|
});
|
|
|
|
function goToEntryBuys() {
|
|
const entryBuySelector = 'a[data-cy="EntryBuys-menu-item"]';
|
|
cy.get(entryBuySelector).should('be.visible');
|
|
cy.waitForElement('[data-cy="entry-buys"]');
|
|
cy.get(entryBuySelector).click();
|
|
}
|
|
|
|
function deleteEntry() {
|
|
cy.get('[data-cy="descriptor-more-opts"]').click();
|
|
cy.waitForElement('div[data-cy="delete-entry"]');
|
|
cy.get('div[data-cy="delete-entry"]').should('be.visible').click();
|
|
cy.url().should('include', 'list');
|
|
}
|
|
|
|
function createEntryAndBuy() {
|
|
createEntry();
|
|
createBuy();
|
|
}
|
|
|
|
function createEntry() {
|
|
cy.get('button[data-cy="vnTableCreateBtn"]').click();
|
|
selectTravel('one');
|
|
cy.get('button[data-cy="FormModelPopup_save"]').click();
|
|
cy.url().should('include', 'summary');
|
|
cy.get('.q-notification__message').eq(0).should('have.text', 'Data created');
|
|
}
|
|
|
|
function selectTravel(warehouse) {
|
|
cy.get('i[data-cy="Travel_icon"]').click();
|
|
cy.get('input[data-cy="Warehouse Out_select"]').type(warehouse);
|
|
cy.get('div[role="listbox"] > div > div[role="option"]').eq(0).click();
|
|
cy.get('button[data-cy="save-filter-travel-form"]').click();
|
|
cy.get('tr').eq(1).click();
|
|
}
|
|
|
|
function createBuy() {
|
|
cy.get('a[data-cy="EntryBuys-menu-item"]').click();
|
|
cy.get('a[data-cy="EntryBuys-menu-item"]').click();
|
|
cy.get('button[data-cy="vnTableCreateBtn"]').click();
|
|
|
|
cy.get('input[data-cy="itemFk-create-popup"]').type('1');
|
|
cy.get('div[role="listbox"] > div > div[role="option"]').eq(0).click();
|
|
cy.get('input[data-cy="Grouping mode_select"]').should('have.value', 'packing');
|
|
cy.get('button[data-cy="FormModelPopup_save"]').click();
|
|
}
|
|
});
|