Skip to content

Commit

Permalink
WIP(rubrics): rework payroll rubric config tests
Browse files Browse the repository at this point in the history
Reworks the tests with the new unified view.
  • Loading branch information
jniles committed Dec 31, 2024
1 parent 221dc67 commit 91bdb83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 39 deletions.
40 changes: 12 additions & 28 deletions test/end-to-end/rubricsConfig/rubrics_config.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ class RubricConfigPage {
return rows.count();
}

async create(rubric) {
async create(rubric, checklist = []) {
await TU.buttons.create();
await TU.input('ConfigModalCtrl.rubric.label', rubric.label);
await TU.input('RubricConfigModalCtrl.config.label', rubric.label);

// loop through rubric ids in checklist and check them
await Promise.all(checklist.map(async (item) => TU.locator(by.id(item)).click()));

await TU.modal.submit();
await notification.hasSuccess();
Expand All @@ -27,47 +30,28 @@ class RubricConfigPage {
async errorOnCreateRubricConfig() {
await TU.buttons.create();
await TU.modal.submit();
await TU.validation.error('ConfigModalCtrl.rubric.label');
await TU.validation.error('RubricConfigModalCtrl.config.label');
await TU.modal.cancel();
}

async update(label, updateRubricConfig) {
async update(label, updateRubricConfig, checklist = []) {
const row = new GridRow(label);
await row.dropdown();
await row.edit();

await TU.input('ConfigModalCtrl.rubric.label', updateRubricConfig.label);

await TU.modal.submit();
await notification.hasSuccess();
}

async setRubricConfig(label) {
const row = new GridRow(label);
await row.dropdown();
await row.method('configure');

await TU.waitForSelector(by.id('social'));

await TU.locator(by.id('social')).click();
await TU.locator(by.id('tax')).click();

await TU.modal.submit();
await notification.hasSuccess();
}

async unsetRubricConfig(label) {
const row = new GridRow(label);
await row.dropdown();
await row.method('configure');
await TU.input('RubricConfigModalCtrl.config.label', updateRubricConfig.label);

// reset the updated checkboxes
await TU.waitForSelector(by.id('all'));
const checkbox = TU.locator(by.id('all'));

// double click to set all, then unset
await checkbox.click();
await checkbox.click();

// now update the values
await Promise.all(checklist.map(async (item) => TU.locator(by.id(item)).click()));

await TU.modal.submit();
await notification.hasSuccess();
}
Expand Down
14 changes: 3 additions & 11 deletions test/end-to-end/rubricsConfig/rubrics_config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,21 @@ test.describe('Rubrics Configuration Management', () => {
const page = new RubricConfigPage();

const rubricConfig = {
label : 'Configuration 2013',
label: 'Configuration 2013',
};

const updateRubricConfig = {
label : 'Configuration 2013 Updated',
label: 'Configuration 2013 Updated',
};

test('successfully creates a new rubric configuration', async () => {
await page.create(rubricConfig);
await page.create(rubricConfig, ['social', 'tax']);
});

test('successfully edits a rubric configuration', async () => {
await page.update(rubricConfig.label, updateRubricConfig);
});

test('successfully set rubrics in rubric configuration', async () => {
await page.setRubricConfig(updateRubricConfig.label);
});

test('successfully unset rubrics in rubric configuration', async () => {
await page.unsetRubricConfig(updateRubricConfig.label);
});

test('do not create when incorrect rubric', async () => {
await page.errorOnCreateRubricConfig();
});
Expand Down

0 comments on commit 91bdb83

Please sign in to comment.