Skip to content

Commit

Permalink
feat: [DHIS2-15187][DHIS2-15190] Working list bulk actions (#3773)
Browse files Browse the repository at this point in the history
Add bulk action working list for both tracked entities and events.
  • Loading branch information
eirikhaugstulen authored Nov 12, 2024
1 parent d88409f commit 5a12722
Show file tree
Hide file tree
Showing 73 changed files with 3,060 additions and 97 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Feature: User facing tests for bulk actions on event working lists

Scenario: the user should be able to select rows
Given you open the main page with Ngelehun and malaria case context
When you select the first 5 rows
Then the bulk action bar should say 5 selected
And the first 5 rows should be selected

Scenario: the user should be able to deselect rows
Given you open the main page with Ngelehun and malaria case context
When you select the first 5 rows
And you deselect the first 3 rows
Then the bulk action bar should say 2 selected

Scenario: the user should be able to select all rows
Given you open the main page with Ngelehun and malaria case context
When you select all rows
Then the bulk action bar should say 15 selected
And all rows should be selected

Scenario: the user should be able to deselect all rows
Given you open the main page with Ngelehun and malaria case context
When you select all rows
And all rows should be selected
And you select all rows
Then the bulk action bar should not be present
And no rows should be selected

Scenario: the filters should be disabled when rows are selected
Given you open the main page with Ngelehun and malaria case context
When you select the first 5 rows
Then the filters should be disabled

@v<42
Scenario: the user should be able to bulk complete events
Given you open the main page with Ngelehun and malaria case context
And you select the first 3 rows
And you click the bulk complete button
And the bulk complete modal should open
When you click the confirm complete events button
Then the bulk complete modal should close

Scenario: the user should be able to bulk delete events
Given you open the main page with Ngelehun and malaria case context
And you select the first 3 rows
And you click the bulk Delete button
And the bulk delete modal should open
When you click the confirm delete events button
Then the bulk delete modal should close
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
import '../../sharedSteps';

Given('you open the main page with Ngelehun and malaria case context', () => {
cy.visit('#/?programId=VBqh0ynB2wv&orgUnitId=DiszpKrYNg8');
});

Then('the bulk complete modal should open', () => {
cy.get('[data-test="bulk-complete-events-dialog"]')
.should('exist');
});

When('you click the confirm complete events button', () => {
cy.intercept({
method: 'POST',
url: '**/tracker?async=false**',
}, {
statusCode: 200,
body: {},
}).as('completeEvents');

cy.get('[data-test="bulk-complete-events-dialog"]')
.find('[data-test="dhis2-uicore-button"]')
.contains('Complete').click();

cy.wait('@completeEvents')
.its('request.body')
.should(({ events }) => {
expect(events).to.have.length(3);
expect(events[0]).to.include({ status: 'COMPLETED' });
expect(events[1]).to.include({ status: 'COMPLETED' });
expect(events[2]).to.include({ status: 'COMPLETED' });
});
});

Then('the bulk complete modal should close', () => {
cy.get('[data-test="bulk-complete-events-dialog"]')
.should('not.exist');
});

Then('the bulk delete modal should open', () => {
cy.get('[data-test="bulk-delete-events-dialog"]')
.should('exist');
});

// you click the confirm delete events button
When('you click the confirm delete events button', () => {
cy.intercept({
method: 'POST',
url: '**/tracker?async=false**',
}, {
statusCode: 200,
body: {},
}).as('deleteEvents');

cy.get('[data-test="bulk-delete-events-dialog"]')
.find('[data-test="dhis2-uicore-button"]')
.contains('Delete').click();

cy.wait('@deleteEvents')
.its('request.body')
.should(({ events }) => {
expect(events).to.have.length(3);
expect(events).to.deep.include({ event: 'a969f7a3bf1' });
expect(events).to.deep.include({ event: 'a6f092d0d44' });
expect(events).to.deep.include({ event: 'a5e67163090' });
});
});

Then('the bulk delete modal should close', () => {
cy.get('[data-test="bulk-delete-events-dialog"]')
.should('not.exist');
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
import { v4 as uuid } from 'uuid';
import '../sharedSteps';
import { getCurrentYear, combineDataAndYear } from '../../../../support/date';
import { combineDataAndYear, getCurrentYear } from '../../../../support/date';

Given('you open the main page with Ngelehun and malaria case context', () => {
cy.visit('#/?programId=VBqh0ynB2wv&orgUnitId=DiszpKrYNg8');
Expand Down Expand Up @@ -29,7 +29,7 @@ Then('the default working list should be displayed', () => {
.should('have.length', 16)
.each(($row, index) => {
if (index) {
cy.wrap($row).find('td').first().invoke('text')
cy.wrap($row).find('td').eq(1).invoke('text')
.then((date) => {
const firstArgs = rows[date].length > 1 ?
new RegExp(`${rows[date].map(item => item.split(' ')[0]).join('|')}`, 'g')
Expand Down Expand Up @@ -185,7 +185,7 @@ Then('the list should display data for the second page', () => {
.should('have.length', 16)
.each(($row, index) => {
if (index) {
cy.wrap($row).find('td').first().invoke('text')
cy.wrap($row).find('td').eq(1).invoke('text')
.then((date) => {
const firstArgs = rows[date].length > 1 ?
new RegExp(`${rows[date].map(item => item.split(' ')[0]).join('|')}`, 'g')
Expand Down Expand Up @@ -219,7 +219,7 @@ Then('the list should display 10 rows of data', () => {
.should('have.length', 11)
.each(($row, index) => {
if (index) {
cy.wrap($row).find('td').first().invoke('text')
cy.wrap($row).find('td').eq(1).invoke('text')
.then((date) => {
const firstArgs = rows[date].length > 1 ?
new RegExp(`${rows[date].map(item => item.split(' ')[0]).join('|')}`, 'g')
Expand Down Expand Up @@ -278,7 +278,7 @@ Then('the list should display data ordered descendingly by report date', () => {
.should('have.length', 16)
.each(($row, index) => {
if (index) {
cy.wrap($row).find('td').first().invoke('text')
cy.wrap($row).find('td').eq(1).invoke('text')
.then((date) => {
const firstArgs = rows[date].length > 1 ?
new RegExp(`${rows[date].map(item => item.split(' ')[0]).join('|')}`, 'g')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Feature: User facing tests for bulk actions on Tracked Entity working lists

Scenario: the user should be able to select rows
Given you open the main page with Ngelehun and child programe context
When you select the first 5 rows
Then the bulk action bar should say 5 selected
And the first 5 rows should be selected

Scenario: the user should be able to deselect rows
Given you open the main page with Ngelehun and child programe context
When you select the first 5 rows
And you deselect the first 3 rows
Then the bulk action bar should say 2 selected

Scenario: the user should be able to select all rows
Given you open the main page with Ngelehun and child programe context
When you select all rows
Then the bulk action bar should say 15 selected
And all rows should be selected

Scenario: the user should be able to deselect all rows
Given you open the main page with Ngelehun and child programe context
When you select all rows
And all rows should be selected
And you select all rows
Then the bulk action bar should not be present
And no rows should be selected

Scenario: the filters should be disabled when rows are selected
Given you open the main page with Ngelehun and child programe context
When you select the first 5 rows
Then the filters should be disabled

Scenario: The user should see an error message when trying to bulk complete enrollments with errors
Given you open the main page with Ngelehun and Malaria focus investigation context
And you select the first 3 rows
And you click the bulk complete enrollments button
And the bulk complete enrollments modal should open
And the modal content should say: This action will complete 2 active enrollments in your selection. 1 enrollment already marked as completed will not be changed.
When you confirm 2 active enrollments with errors
Then an error dialog will be displayed to the user
And you close the error dialog
And the unsuccessful enrollments should still be selected

Scenario: the user should be able to bulk complete enrollments and events
Given you open the main page with Ngelehun and Malaria focus investigation context
And you select the first 4 rows
And you click the bulk complete enrollments button
And the bulk complete enrollments modal should open
And the modal content should say: This action will complete 3 active enrollments in your selection. 1 enrollment already marked as completed will not be changed.
When you confirm 3 active enrollments successfully
Then the bulk complete enrollments modal should close

Scenario: the user should be able to bulk complete enrollments without completing events
Given you open the main page with Ngelehun and Malaria Case diagnosis context
And you select row number 1
And you click the bulk complete enrollments button
And the bulk complete enrollments modal should open
And you deselect the complete events checkbox
And the modal content should say: This action will complete 1 active enrollment in your selection.
When you confirm 1 active enrollment without completing events successfully
Then the bulk complete enrollments modal should close

Scenario: the user should be able to bulk delete enrollments
Given you open the main page with Ngelehun and Malaria Case diagnosis context
And you select the first 3 rows
And you click the bulk delete enrollments button
And the bulk delete enrollments modal should open
When you confirm deleting 3 enrollments
Then the bulk delete enrollments modal should close

Scenario: the user should be able to bulk delete only active enrollments
Given you open the main page with Ngelehun and Malaria Case diagnosis context
And you select the first 3 rows
And you click the bulk delete enrollments button
And the bulk delete enrollments modal should open
When you deselect completed enrollments
And you confirm deleting 2 active enrollments
Then the bulk delete enrollments modal should close

@user:trackerAutoTestRestricted
Scenario: a restricted user should not be able to bulk delete enrollments
Given you open the main page with Ngelehun and WHO RMNCH Tracker context
And you open the working lists
When you select the first 3 rows
Then the bulk delete enrollments button should not be visible
Loading

0 comments on commit 5a12722

Please sign in to comment.