Skip to content

Commit

Permalink
C343345 added (#220)
Browse files Browse the repository at this point in the history
* C343345 added

* updated per comments

* settings path updated
  • Loading branch information
KyryloBrener authored Feb 11, 2022
1 parent 4dda26d commit 311183d
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import TopMenu from '../../../support/fragments/topMenu';
import NewBatchGroup from '../../../support/fragments/invoices/newBatchGroup';
import SettingsInvoices from '../../../support/fragments/invoices/settingsInvoices';
import TestType from '../../../support/dictionary/testTypes';

describe('ui-invoices-settings: Batch Group creation', () => {
const batchGroup = { ...NewBatchGroup.defaultUiBatchGroup };
before(() => {
cy.login(Cypress.env('diku_login'), Cypress.env('diku_password'));
cy.visit(`${TopMenu.settingsInvoice}${SettingsInvoices.settingsInvoicePath.batchGroups}`);
});

it('C343345 Create and edit Batch groups', { tags: [TestType.smoke] }, () => {
SettingsInvoices.waitBatchGroupsLoading();
SettingsInvoices.createNewBatchGroup(batchGroup);
SettingsInvoices.checkBatchGroup(batchGroup);
batchGroup.name += 'updated';
batchGroup.description += 'updated';
SettingsInvoices.editBatchGroup(batchGroup);
SettingsInvoices.checkBatchGroup(batchGroup);
SettingsInvoices.deleteBatchGroup(batchGroup);
});
});
8 changes: 8 additions & 0 deletions cypress/support/fragments/invoices/newBatchGroup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import getRandomPostfix from '../../utils/stringTools';

export default {
defaultUiBatchGroup : {
name: `000autotest_group_${getRandomPostfix()}`,
description: 'Created by autotest',
}
};
65 changes: 65 additions & 0 deletions cypress/support/fragments/invoices/settingsInvoices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Button, TextField, NavListItem, MultiColumnListHeader, EditableListRow, MultiColumnListCell } from '../../../../interactors';
import InteractorsTools from '../../utils/interactorsTools';
import DateTools from '../../utils/dateTools';

const saveButton = Button('Save');
const deleteButton = Button('Delete');
const trashIconButton = Button({ icon: 'trash' });
const editIconButton = Button({ icon: 'edit' });

export default {
settingsInvoicePath: {
approvals: '/approvals',
adjustments: '/adjustments',
batchGroups: '/batch-groups',
batchGroupConfiguration: '/batch-group-configuration',
voucherNumber: '/invoice/voucher-number'
},

waitBatchGroupsLoading: () => {
cy.expect(MultiColumnListHeader({ id: 'list-column-name' }).exists());
},

fillRequiredFields: (batchGroup) => {
cy.do([
TextField({ placeholder: 'name' }).fillIn(batchGroup.name),
TextField({ placeholder: 'description' }).fillIn(batchGroup.description),
saveButton.click()
]);
},

createNewBatchGroup(batchGroup) {
cy.do(Button({ id: 'clickable-add-batch-groups' }).click());
this.fillRequiredFields(batchGroup);
},

editBatchGroup(batchGroup, rowNumber = 0) {
cy.do(EditableListRow({ index: rowNumber }).find(editIconButton).click());
this.fillRequiredFields(batchGroup);
},

checkBatchGroup: (batchGroup, rowNumber = 0) => {
const createdByAdmin = `${DateTools.getFormattedDateWithSlashes({ date: new Date() })} by ADMINISTRATOR, DIKU`;

cy.expect(EditableListRow({ index: rowNumber })
.find(MultiColumnListCell({ columnIndex: 0 }))
.has({ content: batchGroup.name }));

cy.expect(EditableListRow({ index: rowNumber })
.find(MultiColumnListCell({ columnIndex: 1 }))
.has({ content: batchGroup.description }));

cy.expect(EditableListRow({ index: rowNumber })
.find(MultiColumnListCell({ columnIndex: 2 }))
.has({ content: createdByAdmin }));
},

deleteBatchGroup: (batchGroup, rowNumber = 0) => {
cy.do([
EditableListRow({ index: rowNumber })
.find(trashIconButton).click(),
deleteButton.click()
]);
InteractorsTools.checkCalloutMessage(`The Batch group ${batchGroup.name} was successfully deleted`);
}
};
1 change: 1 addition & 0 deletions cypress/support/fragments/topMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export default class TopMenu {
static ordersPath = '/orders';
static invoicesPath = '/invoice';
static circulationLogPath = '/circulation-log';
static settingsInvoice = 'settings/invoice';
}
4 changes: 4 additions & 0 deletions cypress/support/utils/dateTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export default {
getFormattedDate({ date }) {
return `${date.getFullYear()}-${padWithZero(date.getMonth() + 1)}-${padWithZero(date.getDate())}`;
},
// Formats date as MM/DD/YYYY without zeros - used in settings
getFormattedDateWithSlashes({ date }) {
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
},
clearPaddingZero(initialString) {
return initialString.replaceAll(/0([1-9])\//g, '$1/');
}
Expand Down
2 changes: 1 addition & 1 deletion interactors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export { default as MessageBanner, MessageBannerTypes } from './messagebanner';
export { default as Modal } from './modal';
export { MultiColumnList, MultiColumnListRow, MultiColumnListCell, MultiColumnListHeader } from './multi-column-list';
export { default as MultiSelect, MultiSelectMenu, MultiSelectOption, ValueChipRoot } from './multi-select';
export { default as NavList } from './navlist';
export { default as NavList, NavListItem } from './navlist';
export { default as Pane, PaneHeader } from './pane';
export { default as RadioButton } from './radio-button';
export { default as RadioButtonGroup } from './radio-button-group';
Expand Down
1 change: 1 addition & 0 deletions interactors/multi-column-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const MultiColumnListHeader = HTML.extend('multi column list header')
.selector('div[class*=mclHeader-]')
.filters({
index: childIndex,
id: el => el.getAttribute('id')
})
.actions({
click: ({ perform }) => perform(el => el.querySelector('[role=button]').click()),
Expand Down
11 changes: 11 additions & 0 deletions interactors/navlist.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { HTML, Link } from '@interactors/html';

function label(element) {
const labelEl = element.querySelector('[class^=NavListItem]');
return labelEl ? labelEl.textContent.trim() : '';
}

export default HTML.extend('Nav List')
.selector('[data-test-nav-list]')
.filters({
Expand All @@ -8,3 +13,9 @@ export default HTML.extend('Nav List')
.actions({
navTo: ({ find }, linkText) => find(Link(linkText)).click(),
});

export const NavListItem = HTML.extend('Nav List Item')
.selector('[class^=NavListItem]')
.filters({
label
});
1 change: 1 addition & 0 deletions interactors/text-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default HTML.extend('text field')
warning: (el) => (el.querySelector('[class*=feedbackWarning-]') || {}).textContent,
valid: el => el.querySelector('input').getAttribute('aria-invalid') !== 'true',
name: el => el.querySelector('input').name,
placeholder: el => el.querySelector('input').placeholder,
clearButton: el => {
const clearBtn = [...el.querySelectorAll('[class^=iconButton]')]
.filter(I => I.getAttribute('icon') === 'clear');
Expand Down

0 comments on commit 311183d

Please sign in to comment.