Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated end-to-end tests #7428

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/modules/enterprises/enterprises.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
<b><i class="fa fa-cube"></i> <span translate>TREE.PROJECT</span></b>
</div>

<ul class="list-group">
<ul class="list-group" id="projectList">
<li class="list-group-item clearfix" data-project="{{ ::p.abbr }}" ng-repeat="p in EnterpriseCtrl.projects track by p.id">
<span>
<i class="fa fa-hospital-o"></i> {{ p.name }} ({{ p.abbr }})
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/journal/journal.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@

<div class="toolbar-item">
<button
id="editTransaction"
ng-class="{ 'btn-success' : JournalCtrl.selection.selected.groups.length === 1 }"
ng-disabled="JournalCtrl.selection.selected.groups.length === 0"
ng-click="JournalCtrl.editTransactionModal()"
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = defineConfig({
forbidOnly : !!process.env.CI,

/* Retry on CI only */
retries : process.env.CI ? 1 : 0,
retries : process.env.CI ? 2 : 0,

/* Opt out of parallel tests on CI. */
// workers : process.env.CI ? 1 : undefined,
Expand Down
8 changes: 6 additions & 2 deletions sh/test-show-results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ if test -f "./results/end-to-end-report-account"; then
echo " " `grep passed ./results/end-to-end-report-account`
pending=`egrep -e '([0-9]+ pending)' ./results/end-to-end-report-account`
if [ "$pending" ]; then echo " $pending"; fi
skipped=`egrep -e '([0-9]+ skipped|[0-9]+ flakey)' ./results/end-to-end-report-account`
skipped=`egrep -e '([0-9]+ skipped)' ./results/end-to-end-report-account`
if [ "$skipped" ]; then echo " $skipped"; fi
flaky=`egrep -e '([0-9]+ flakey|[0-9]+ flaky)' ./results/end-to-end-report-account`
if [ "$flaky" ]; then echo " $flaky"; fi
failed=`egrep -e '([0-9]+ failing|[0-9]+ failed)' ./results/end-to-end-report-account`
if [ "$failed" ]; then echo " $failed"; fi
echo
Expand All @@ -67,8 +69,10 @@ for i in {1..8}; do
echo " " `grep passed ./results/end-to-end-report-$i`
pending=`egrep -e '([0-9]+ pending)' ./results/end-to-end-report-$i`
if [ "$pending" ]; then echo " $pending"; fi
skipped=`egrep -e '([0-9]+ skipped|[0-9]+ flakey)' ./results/end-to-end-report-$i`
skipped=`egrep -e '([0-9]+ skipped)' ./results/end-to-end-report-$i`
if [ "$skipped" ]; then echo " $skipped"; fi
flaky=`egrep -e '([0-9]+ flakey|[0-9]+ flaky)' ./results/end-to-end-report-$i`
if [ "$flaky" ]; then echo " $flaky"; fi
failed=`egrep -e '([0-9]+ failing|[0-9]+ failed)' ./results/end-to-end-report-$i`
if [ "$failed" ]; then echo " $failed"; fi
echo
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/cashboxes/cashboxes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ test.describe('Cashboxes', () => {
await TU.locator('[data-currency-id="1"]').click();

// confirm that the modal appears
// ??? await TU.exists('[uib-modal-window]', true);
await TU.locator('[uib-modal-window]');
await TU.exists(by.name('CashboxModalForm'));
await TU.waitForSelector('.modal-dialog');
await TU.waitForSelector(by.name('CashboxModalForm'));

await accountSelect.set('Gain de change', 'account-id');
await accountSelect.set('Différences de change', 'transfer-account-id');
Expand Down
3 changes: 2 additions & 1 deletion test/end-to-end/creditorGroups/creditor_groups.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ test.describe('Creditor Groups Management', () => {
// click the "delete" button
await TU.buttons.delete();

await TU.modal.submit();
await TU.modal.submit(); // Confirm the deletion

await components.notification.hasSuccess();
});

Expand Down
13 changes: 12 additions & 1 deletion test/end-to-end/editJournal/edit_journal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ test.describe('Edit Posting Journal', () => {
});

test('edits a transaction to change an account', async () => {
await GU.clearRowSelections(gridId);
await GU.selectRow(gridId, 0);
await TU.waitForSelector('button#editTransaction:not([disabled])');
await openEditingModal();

const accountNumberCell = await GU.getCell(editingGridId, 0, 1);
Expand Down Expand Up @@ -68,10 +70,11 @@ test.describe('Edit Posting Journal', () => {
}

test('edits a transaction to change the value of debit and credit', async () => {
await GU.clearRowSelections(gridId);
await GU.selectRow(gridId, 0);
await TU.waitForSelector('button#editTransaction:not([disabled])');
await openEditingModal();

// change the first row (index 0), debit and credit inputs (index 2 and 3)
await editInput(0, 2, 99);
await editInput(0, 3, 0);

Expand All @@ -84,7 +87,9 @@ test.describe('Edit Posting Journal', () => {
});

test('prevents an unbalanced transaction', async () => {
await GU.clearRowSelections(gridId);
await GU.selectRow(gridId, 0);
await TU.waitForSelector('button#editTransaction:not([disabled])');
await openEditingModal();

await editInput(0, 2, 100);
Expand All @@ -102,7 +107,9 @@ test.describe('Edit Posting Journal', () => {

// Test for validation
test('prevents a single line transaction', async () => {
await GU.clearRowSelections(gridId);
await GU.selectRow(gridId, 0);
await TU.waitForSelector('button#editTransaction:not([disabled])');
await openEditingModal();

await GU.selectRow(editingGridId, 0);
Expand All @@ -116,7 +123,9 @@ test.describe('Edit Posting Journal', () => {

// @TODO: Fix. Works alone but fails with other tests
test.skip('preventing transaction who have debit and credit null', async () => {
await GU.clearRowSelections(gridId);
await GU.selectRow(gridId, 0);
await TU.waitForSelector('button#editTransaction:not([disabled])');
await openEditingModal();

await editInput(0, 2, 0);
Expand All @@ -131,7 +140,9 @@ test.describe('Edit Posting Journal', () => {
});

test('preventing transaction who was debited and credited in a same line', async () => {
await GU.clearRowSelections(gridId);
await GU.selectRow(gridId, 0);
await TU.waitForSelector('button#editTransaction:not([disabled])');
await openEditingModal();

await editInput(0, 2, 10);
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/employees/registration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ test.describe('Employees', () => {
await registrationPage.createEmployee();
await TU.waitForSelector('#receipt-confirm-created');
await registrationPage.isEmployeeCreated(true);
await TU.buttons.close(); // Close the receipt modal
});

test('register an employee from a patient', async () => {
Expand Down
7 changes: 5 additions & 2 deletions test/end-to-end/enterprises/enterprises.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ test.describe('Enterprises', () => {

test('delete an existing project', async () => {
// Pop up the project deletion dialog
await TU.locator(`[data-project="${projectUpdate.abbr}"] a[data-method="delete"]`).click();
await TU.input('$ctrl.text', projectUpdate.name);
const proj = await TU.locator(`#projectList li:has-text("${projectUpdate.abbr}")`);
// NB: Not sure why this work-around was necessary when the 'update' one above works fine
await proj.locator('a[data-method="delete"]').click();
await TU.input('$ctrl.text', projectUpdate.name); // Confirm deletion

await TU.modal.submit();

await components.notification.hasSuccess();
Expand Down
25 changes: 18 additions & 7 deletions test/end-to-end/fiscalYears/fiscalYears.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ test.describe('Fiscal Year', () => {

test('set the opening balance for the first fiscal year', async () => {
// the last in the list is the oldest
await TU.locator('.pagination-last > a').click();
await TU.locator('.pagination-last a').click();
await TU.locator('[data-fiscal-entry] [data-method="update"]').last().click();

// click on the opening balance button
Expand All @@ -111,12 +111,16 @@ test.describe('Fiscal Year', () => {
await components.notification.hasSuccess();
});

test('forbid not balanced submission', async () => {
// await TU.navigate(path);
await TU.navigate(path);
test('forbid unbalanced submission', async () => {
await TU.navigate(path); // Force reload (?)

// If we are not on the last page, go to it
const disabled = await TU.locator('li.pagination-last').isDisabled();
if (!disabled) {
await TU.locator('li.pagination-last a').click();
}

// the last in the list is the oldest
await TU.locator('.pagination-last > a').click();
await TU.locator('[data-fiscal-entry] [data-method="update"]').last().click();

// click on the opening balance button
Expand All @@ -131,16 +135,23 @@ test.describe('Fiscal Year', () => {
await TU.locator(`[data-debit-account="${account1}"]`).fill('150');
await TU.locator(`[data-debit-account="${account2}"]`).fill('150');
await TU.locator(`[data-credit-account="${account3}"]`).fill('200');

await TU.buttons.submit();

await components.notification.hasDanger();
expect(await TU.isPresent('[data-status="not-balanced"]')).toBe(true);
});

test('closing a fiscal year in normal way', async () => {
await TU.navigate(path);
await TU.navigate(path); // Force reload (?)

// If we are not on the last page, go to it
const disabled = await TU.locator('li.pagination-last[disabled]');
if (disabled > 0) {
await TU.locator('li.pagination-last a').click();
}

// the last in the list is the oldest
await TU.locator('.pagination-last > a').click();
await TU.locator('[data-fiscal-entry] [data-method="update"]').last().click();

// this fix multiple element found take first
Expand Down
25 changes: 25 additions & 0 deletions test/end-to-end/shared/GridUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,30 @@ async function selectRow(gridId, rowNum) {
// return btn.click();
}

/**
* Unselect all rows
*
* @param {number} gridId - number of the desired row
*/
async function clearRowSelections(gridId) {
const grid = await getGrid(gridId);
const ports = await grid.locator('[ui-grid-viewport]');
const selPort = await ports.nth(0);
const selBtns = await selPort.locator('.ui-grid-selection-row-header-buttons').all();

if (selBtns) {
/* eslint-disable no-await-in-loop */
for (let j = 0; j < selBtns.length; j++) {
const elt = selBtns[j];
const checked = await elt.isChecked();
if (checked) {
await elt.setChecked(false);
}
}
/* eslint-enable no-await-in-loop */
}
}

/**
* Selects all rows in the grid.
*
Expand Down Expand Up @@ -324,4 +348,5 @@ exports.expectHeaderColumns = expectHeaderColumns;
exports.expectHeaderColumnsContained = expectHeaderColumnsContained;
exports.selectRow = selectRow;
exports.selectAll = selectAll;
exports.clearRowSelections = clearRowSelections;
exports.expectCellValueMatch = expectCellValueMatch;
10 changes: 10 additions & 0 deletions test/end-to-end/shared/TestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,16 @@ module.exports = {
);
},

/**
* Do a screen shot
*
* @param {string} path - name/path of the screen shot file
* @returns {Promise} for completion of the screen shot
*/
screenshot : async (path) => {
return page.screenshot({ path });
},

buttons,
by,
fill,
Expand Down
38 changes: 37 additions & 1 deletion test/end-to-end/stock/stock.aggregate_consumption.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const moment = require('moment');

const { test } = require('@playwright/test');
const TU = require('../shared/TestUtils');
const { by } = require('../shared/TestUtils');

const components = require('../shared/components');

Expand Down Expand Up @@ -127,6 +128,12 @@ function StockAggregateConsumptionTests() {
}];

await page.setDetailed(1, 10);

// Wait until the modal is fully up
await TU.waitForSelector('.modal-dialog');
await TU.waitForSelector(by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.uid'));
await TU.waitForSelector('bh-date-picker[date="row.entity.end_date"] input');

await page.setLots(lots);

await page.setQuantityConsumed(2, 7, 500);
Expand All @@ -145,6 +152,12 @@ function StockAggregateConsumptionTests() {
}];

await page.setDetailed(2, 10);

// Wait until the modal is fully up
await TU.waitForSelector('.modal-dialog');
await TU.waitForSelector(by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.uid'));
await TU.waitForSelector('bh-date-picker[date="row.entity.end_date"] input');

await page.setLots(lots2);

await page.setHeaderValue(3, 9, 20);
Expand Down Expand Up @@ -187,6 +200,12 @@ function StockAggregateConsumptionTests() {
}];

await page.setDetailed(1, 10);

// Wait until the modal is fully up
await TU.waitForSelector('.modal-dialog');
await TU.waitForSelector(by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.uid'));
await TU.waitForSelector('bh-date-picker[date="row.entity.end_date"] input');

await page.setLotsError(lots);
});

Expand Down Expand Up @@ -224,6 +243,12 @@ function StockAggregateConsumptionTests() {
}];

await page.setDetailed(1, 10);

// Wait until the modal is fully up
await TU.waitForSelector('.modal-dialog');
await TU.waitForSelector(by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.uid'));
await TU.waitForSelector('bh-date-picker[date="row.entity.end_date"] input');

await page.setLotsError(lots);
});

Expand All @@ -243,7 +268,6 @@ function StockAggregateConsumptionTests() {

// Wait until the rows are loaded
await TU.waitForSelector('div.ui-grid-row');

await page.setHeaderValue(0, 9, 5);
await page.setQuantityConsumed(1, 7, 15);
await page.setQuantityLost(1, 8, 5);
Expand All @@ -261,6 +285,12 @@ function StockAggregateConsumptionTests() {
}];

await page.setDetailed(1, 10);

// Wait until the modal is fully up
await TU.waitForSelector('.modal-dialog');
await TU.waitForSelector(by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.uid'));
await TU.waitForSelector('bh-date-picker[date="row.entity.end_date"] input');

await page.setLotsError(lots);
});

Expand Down Expand Up @@ -298,6 +328,12 @@ function StockAggregateConsumptionTests() {
}];

await page.setDetailed(1, 10);

// Wait until the modal is fully up
await TU.waitForSelector('.modal-dialog');
await TU.waitForSelector(by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.uid'));
await TU.waitForSelector('bh-date-picker[date="row.entity.end_date"] input');

await page.setLotsError(lots);
});

Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/stock/stock.entry.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function StockEntryPage() {
page.openLotsModal = async (inventoryRowNumber) => {
const launchLots = await GU.getCell(gridId, inventoryRowNumber, 4);
await launchLots.locator('[data-lots]').click();
return TU.waitForSelector('.modal-dialog');
};

/**
Expand Down
4 changes: 4 additions & 0 deletions test/end-to-end/transactionType/transactionType.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ test.describe('transaction types', () => {
test('successfully updates an existing transaction type', async () => {
const editButton = `[data-edit-type="${newType.text}"]`;
await TU.waitForSelector(editButton);

await TU.locator(editButton).click();

await TU.input('$ctrl.transactionType.text', updateType.text);
await TU.select('$ctrl.transactionType.type', updateType.type);

await TU.buttons.submit();

await components.notification.hasSuccess();
});

Expand Down
Loading