From 44318903e774f5cea64a0e13ae53709b0d66ff9b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 1 Mar 2022 15:15:58 +0100 Subject: [PATCH 1/2] feat(claim): add log section --- db/changes/10430-ash/00-aclClaimLog.sql | 3 ++ db/changes/10430-ash/delete.keep | 1 - e2e/helpers/selectors.js | 4 ++ e2e/paths/06-claim/07_.claim_log.spec.js | 52 +++++++++++++++++++ .../claim/back/models/claim-beginning.json | 7 ++- .../claim/back/models/claim-development.json | 6 ++- modules/claim/back/models/claim-end.json | 6 ++- modules/claim/back/models/claim-state.json | 7 ++- modules/claim/back/models/claim.json | 6 ++- modules/claim/front/index.js | 1 + modules/claim/front/log/index.html | 4 ++ modules/claim/front/log/index.js | 7 +++ modules/claim/front/routes.json | 9 +++- 13 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 db/changes/10430-ash/00-aclClaimLog.sql delete mode 100644 db/changes/10430-ash/delete.keep create mode 100644 e2e/paths/06-claim/07_.claim_log.spec.js create mode 100644 modules/claim/front/log/index.html create mode 100644 modules/claim/front/log/index.js diff --git a/db/changes/10430-ash/00-aclClaimLog.sql b/db/changes/10430-ash/00-aclClaimLog.sql new file mode 100644 index 000000000..cad88a6ab --- /dev/null +++ b/db/changes/10430-ash/00-aclClaimLog.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('ClaimLog', '*', 'READ', 'ALLOW', 'ROLE', 'claimManager'); diff --git a/db/changes/10430-ash/delete.keep b/db/changes/10430-ash/delete.keep deleted file mode 100644 index 8fe7322e3..000000000 --- a/db/changes/10430-ash/delete.keep +++ /dev/null @@ -1 +0,0 @@ -delete file \ No newline at end of file diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f0a5c37b5..1adf5ff2b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -729,6 +729,10 @@ export default { firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]', isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]' }, + claimLog: { + anyLineCreated: 'vn-claim-log > vn-log vn-tbody > vn-tr', + firstLineCreatedProperty: 'vn-claim-log > vn-log vn-tbody > vn-tr:nth-child(1) > vn-td > vn-one:nth-child(3) > div span:nth-child(2)', + }, ordersIndex: { secondSearchResultTotal: 'vn-order-index vn-card > vn-table > div > vn-tbody .vn-tr:nth-child(2) vn-td:nth-child(9)', advancedSearchButton: 'vn-order-search-panel vn-submit[label="Search"]', diff --git a/e2e/paths/06-claim/07_.claim_log.spec.js b/e2e/paths/06-claim/07_.claim_log.spec.js new file mode 100644 index 000000000..a970fd1e9 --- /dev/null +++ b/e2e/paths/06-claim/07_.claim_log.spec.js @@ -0,0 +1,52 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +fdescribe('Claim log path', () => { + let browser; + let page; + const claimId = '1'; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('claimManager', 'claim'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should now navigate to the target claim basicData section', async() => { + await page.loginAndModule('claimManager', 'claim'); + await page.accessToSearchResult(claimId); + await page.accessToSection('claim.card.basicData'); + }); + + it(`should edit claim state and observation fields`, async() => { + await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Faltas'); + await page.waitToClick(selectors.claimBasicData.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should edit claim state and observation fields`, async() => { + await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Faltas'); + await page.waitToClick(selectors.claimBasicData.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should search for the created item and navigate to it's log section`, async() => { + await page.waitForState('claim.card.detail'); + await page.accessToSection('claim.card.log'); + }); + + it(`should confirm the log is showing 5 entries`, async() => { + await page.waitForSelector(selectors.claimLog.anyLineCreated); + const anyLineCreatedCount = await page.countElement(selectors.claimLog.anyLineCreated); + + expect(anyLineCreatedCount).toEqual(5); + }); +}); diff --git a/modules/claim/back/models/claim-beginning.json b/modules/claim/back/models/claim-beginning.json index 50506122a..abdae440a 100644 --- a/modules/claim/back/models/claim-beginning.json +++ b/modules/claim/back/models/claim-beginning.json @@ -1,6 +1,11 @@ { "name": "ClaimBeginning", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "ClaimLog", + "relation": "claim", + "showField": "quantity" + }, "options": { "mysql": { "table": "claimBeginning" diff --git a/modules/claim/back/models/claim-development.json b/modules/claim/back/models/claim-development.json index 94c677304..2e8eb2f01 100644 --- a/modules/claim/back/models/claim-development.json +++ b/modules/claim/back/models/claim-development.json @@ -1,6 +1,10 @@ { "name": "ClaimDevelopment", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "ClaimLog", + "relation": "claim" + }, "options": { "mysql": { "table": "claimDevelopment" diff --git a/modules/claim/back/models/claim-end.json b/modules/claim/back/models/claim-end.json index 8f835ee84..d908c252b 100644 --- a/modules/claim/back/models/claim-end.json +++ b/modules/claim/back/models/claim-end.json @@ -1,6 +1,10 @@ { "name": "ClaimEnd", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "ClaimLog", + "relation": "claim" + }, "options": { "mysql": { "table": "claimEnd" diff --git a/modules/claim/back/models/claim-state.json b/modules/claim/back/models/claim-state.json index 287a525ad..e0a536e11 100644 --- a/modules/claim/back/models/claim-state.json +++ b/modules/claim/back/models/claim-state.json @@ -1,6 +1,11 @@ { "name": "ClaimState", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "ClaimLog", + "relation": "claim", + "showField": "description" + }, "options": { "mysql": { "table": "claimState" diff --git a/modules/claim/back/models/claim.json b/modules/claim/back/models/claim.json index 3cb64e31d..761a3b4c9 100644 --- a/modules/claim/back/models/claim.json +++ b/modules/claim/back/models/claim.json @@ -1,6 +1,10 @@ { "name": "Claim", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "ClaimLog", + "showField": "id" + }, "options": { "mysql": { "table": "claim" diff --git a/modules/claim/front/index.js b/modules/claim/front/index.js index b6c39196e..ebbc6ea06 100644 --- a/modules/claim/front/index.js +++ b/modules/claim/front/index.js @@ -11,3 +11,4 @@ import './development'; import './search-panel'; import './summary'; import './photos'; +import './log'; diff --git a/modules/claim/front/log/index.html b/modules/claim/front/log/index.html new file mode 100644 index 000000000..500a626d6 --- /dev/null +++ b/modules/claim/front/log/index.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/modules/claim/front/log/index.js b/modules/claim/front/log/index.js new file mode 100644 index 000000000..0143a612b --- /dev/null +++ b/modules/claim/front/log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnClaimLog', { + template: require('./index.html'), + controller: Section, +}); diff --git a/modules/claim/front/routes.json b/modules/claim/front/routes.json index ced6f4a6f..5f08255be 100644 --- a/modules/claim/front/routes.json +++ b/modules/claim/front/routes.json @@ -13,7 +13,8 @@ {"state": "claim.card.detail", "icon": "icon-details"}, {"state": "claim.card.photos", "icon": "image"}, {"state": "claim.card.development", "icon": "icon-traceability"}, - {"state": "claim.card.action", "icon": "icon-actions"} + {"state": "claim.card.action", "icon": "icon-actions"}, + {"state": "claim.card.log", "icon": "history"} ] }, "keybindings": [ @@ -88,6 +89,12 @@ "params": { "claim": "$ctrl.claim" } + }, { + "url" : "/log", + "state": "claim.card.log", + "component": "vn-claim-log", + "description": "Log", + "acl": ["claimManager"] } ] } \ No newline at end of file From 64a94cd60d05441e74abc132df1170556ef5d64d Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 2 Mar 2022 09:50:29 +0100 Subject: [PATCH 2/2] delete e2e --- e2e/helpers/selectors.js | 4 -- e2e/paths/06-claim/07_.claim_log.spec.js | 52 ------------------------ 2 files changed, 56 deletions(-) delete mode 100644 e2e/paths/06-claim/07_.claim_log.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 1adf5ff2b..f0a5c37b5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -729,10 +729,6 @@ export default { firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]', isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]' }, - claimLog: { - anyLineCreated: 'vn-claim-log > vn-log vn-tbody > vn-tr', - firstLineCreatedProperty: 'vn-claim-log > vn-log vn-tbody > vn-tr:nth-child(1) > vn-td > vn-one:nth-child(3) > div span:nth-child(2)', - }, ordersIndex: { secondSearchResultTotal: 'vn-order-index vn-card > vn-table > div > vn-tbody .vn-tr:nth-child(2) vn-td:nth-child(9)', advancedSearchButton: 'vn-order-search-panel vn-submit[label="Search"]', diff --git a/e2e/paths/06-claim/07_.claim_log.spec.js b/e2e/paths/06-claim/07_.claim_log.spec.js deleted file mode 100644 index a970fd1e9..000000000 --- a/e2e/paths/06-claim/07_.claim_log.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -fdescribe('Claim log path', () => { - let browser; - let page; - const claimId = '1'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('claimManager', 'claim'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should now navigate to the target claim basicData section', async() => { - await page.loginAndModule('claimManager', 'claim'); - await page.accessToSearchResult(claimId); - await page.accessToSection('claim.card.basicData'); - }); - - it(`should edit claim state and observation fields`, async() => { - await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Faltas'); - await page.waitToClick(selectors.claimBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should edit claim state and observation fields`, async() => { - await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Faltas'); - await page.waitToClick(selectors.claimBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should search for the created item and navigate to it's log section`, async() => { - await page.waitForState('claim.card.detail'); - await page.accessToSection('claim.card.log'); - }); - - it(`should confirm the log is showing 5 entries`, async() => { - await page.waitForSelector(selectors.claimLog.anyLineCreated); - const anyLineCreatedCount = await page.countElement(selectors.claimLog.anyLineCreated); - - expect(anyLineCreatedCount).toEqual(5); - }); -});