From a70883378ae1b7ac5c018bc89b936689ba827afb Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Thu, 5 Mar 2020 16:47:59 +0000 Subject: [PATCH] [AAE-2107] Move e2e to Unit test (#5535) * [AAE-2107] Move e2e to Unit test * * fixed namings * * more unit test added * * minor changes --- e2e/core/card-view/card-view-component.e2e.ts | 314 ---------- .../data-table-component-selection.e2e.ts | 29 - .../process-custom-filters.e2e.ts | 39 -- .../process-filter-results.e2e.ts | 8 - .../process-filter-task.e2e.ts | 32 +- .../process-list-cloud-component.e2e.ts | 102 ---- .../start-task-custom-app-cloud.e2e.ts | 7 - .../task-filters-cloud.e2e.ts | 9 - .../card-view-dateitem.component.spec.ts | 216 +++---- ...d-view-keyvaluepairsitem.component.spec.ts | 5 +- .../card-view-selectitem.component.spec.ts | 47 ++ .../card-view-textitem.component.spec.ts | 549 ++++++++++++++---- .../datatable/datatable.component.spec.ts | 19 + .../process-list-cloud.component.spec.ts | 71 ++- .../mock/process-list-service.mock.ts | 68 +++ .../start-task-cloud.component.spec.ts | 5 +- .../edit-task-filter-cloud.component.spec.ts | 4 +- .../task-filters-cloud.component.spec.ts | 15 + .../task-list-cloud.component.spec.ts | 42 ++ 19 files changed, 809 insertions(+), 772 deletions(-) delete mode 100644 e2e/core/card-view/card-view-component.e2e.ts delete mode 100644 e2e/process-services-cloud/process-list-cloud-component.e2e.ts diff --git a/e2e/core/card-view/card-view-component.e2e.ts b/e2e/core/card-view/card-view-component.e2e.ts deleted file mode 100644 index c28de76e08..0000000000 --- a/e2e/core/card-view/card-view-component.e2e.ts +++ /dev/null @@ -1,314 +0,0 @@ -/*! - * @license - * Copyright 2019 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { BrowserVisibility, LoginPage } from '@alfresco/adf-testing'; -import { browser, by, element } from 'protractor'; -import { CardViewComponentPage } from '../../pages/adf/card-view-component.page'; -import { MetadataViewPage } from '../../pages/adf/metadata-view.page'; -import { NavigationBarPage } from '../../pages/adf/navigation-bar.page'; - -describe('CardView Component', () => { - const loginPage = new LoginPage(); - const navigationBarPage = new NavigationBarPage(); - const cardViewPageComponent = new CardViewComponentPage(); - const metadataViewPage = new MetadataViewPage(); - - beforeAll(async () => { - await loginPage.loginToContentServices(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword); - await navigationBarPage.clickCardViewButton(); - }); - - afterAll(async () => { - await navigationBarPage.clickLogoutButton(); - }); - - afterEach(async () => { - await cardViewPageComponent.clickOnResetButton(); - }); - - describe('key-value pair ', () => { - - it('[C279938] Should the label be present', async () => { - const label = element(by.css('div[data-automation-id="card-key-value-pairs-label-key-value-pairs"]')); - - await BrowserVisibility.waitUntilElementIsPresent(label); - }); - - it('[C279898] Should be possible edit key-value pair properties', async () => { - await cardViewPageComponent.clickOnAddButton(); - await cardViewPageComponent.setName('testName'); - await cardViewPageComponent.setValue('testValue'); - await cardViewPageComponent.clickOnAddButton(); - await cardViewPageComponent.waitForOutput(); - await expect(await cardViewPageComponent.getOutputText(0)).toBe('[CardView Key-Value Pairs Item] - [{"name":"testName","value":"testValue"}]'); - - await cardViewPageComponent.deletePairsValues(); - - await expect(await cardViewPageComponent.getOutputText(1)).toBe('[CardView Key-Value Pairs Item] - []'); - }); - }); - - describe('SelectBox', () => { - - it('[C279939] Should the label be present', async () => { - const label = element(by.css('div[data-automation-id="card-select-label-select"]')); - - await BrowserVisibility.waitUntilElementIsPresent(label); - }); - - it('[C279899] Should be possible edit selectBox item', async () => { - await cardViewPageComponent.clickSelectBox(); - await cardViewPageComponent.selectValueFromComboBox(1); - - await expect(await cardViewPageComponent.getOutputText(0)) - .toBe('[CardView Select Item] - two'); - }); - - it('[C312448] Should be able to enable None option', async () => { - await cardViewPageComponent.enableNoneOption(); - await cardViewPageComponent.clickSelectBox(); - await cardViewPageComponent.selectValueFromComboBox(0); - - await expect(cardViewPageComponent.getOutputText(0)) - .toBe('[CardView Select Item] - null'); - }); - }); - - describe('Text', () => { - - it('[C279937] Should the label be present', async () => { - await cardViewPageComponent.checkNameTextLabelIsPresent(); - }); - - it('[C279943] Should be present a default value', async () => { - await expect(await cardViewPageComponent.getNameTextFieldText()).toBe('Spock'); - }); - - it('[C279934] Should be possible edit text item', async () => { - await cardViewPageComponent.clickOnNameTextField(); - await cardViewPageComponent.enterNameTextField('example'); - await cardViewPageComponent.clickOnNameTextSaveIcon(); - - await expect(await cardViewPageComponent.getOutputText(0)).toBe('[CardView Text Item] - example'); - }); - - it('[C279944] Should be possible undo text item modify when click on the clear button', async () => { - await cardViewPageComponent.clickOnNameTextField(); - await cardViewPageComponent.enterNameTextField('example'); - await cardViewPageComponent.clickOnNameTextClearIcon(); - - await expect(await cardViewPageComponent.getNameTextFieldText()).toBe('Spock'); - }); - }); - - describe('Int', () => { - - it('[C279940] Should the label be present', async () => { - const label = element(by.css('div[data-automation-id="card-textitem-label-int"]')); - - await BrowserVisibility.waitUntilElementIsPresent(label); - }); - - it('[C279945] Should be present a default value', async () => { - await expect(await cardViewPageComponent.getIntFieldText()).toBe('213'); - }); - - it('[C279946] Should be possible edit int item', async () => { - await cardViewPageComponent.clickOnIntField(); - await cardViewPageComponent.enterIntField('99999'); - await cardViewPageComponent.clickOnIntSaveIcon(); - - await expect(await cardViewPageComponent.getOutputText(0)).toBe('[CardView Int Item] - 99999'); - }); - - it('[C279947] Should not be possible add string value to the int item', async () => { - await cardViewPageComponent.clickOnIntField(); - await cardViewPageComponent.enterIntField('string value'); - await cardViewPageComponent.clickOnIntSaveIcon(); - - await expect(await cardViewPageComponent.getErrorInt()).toBe('Use an integer format'); - }); - - it('[C279948] Should not be possible add float value to the int item', async () => { - await cardViewPageComponent.clickOnIntField(); - await cardViewPageComponent.enterIntField('0.22'); - await cardViewPageComponent.clickOnIntSaveIcon(); - - await expect(await cardViewPageComponent.getErrorInt()).toBe('Use an integer format'); - }); - - it('[C279949] Should not be possible to have a space as a value', async () => { - await cardViewPageComponent.clickOnIntField(); - await cardViewPageComponent.enterIntField(' '); - await cardViewPageComponent.clickOnIntSaveIcon(); - - await expect(await cardViewPageComponent.getErrorInt()).toBe('Use an integer format'); - }); - - it('[C321535] Should be able to delete the value and save the CardView Int Item', async () => { - await cardViewPageComponent.clickOnIntField(); - await cardViewPageComponent.clearIntField(); - await cardViewPageComponent.clickOnIntSaveIcon(); - await expect(await cardViewPageComponent.isErrorNotDisplayed()).toBe(true, 'The CardView Int Item should accept an empty field, but the error message is still displayed'); - }); - - it('[C279950] Should return an error when the value is > 2147483647', async () => { - await cardViewPageComponent.clickOnIntField(); - await cardViewPageComponent.enterIntField('214748367'); - await cardViewPageComponent.clickOnIntSaveIcon(); - - await expect(await cardViewPageComponent.getOutputText(0)).toBe('[CardView Int Item] - 214748367'); - - await cardViewPageComponent.clickOnIntField(); - await cardViewPageComponent.enterIntField('2147483648'); - await cardViewPageComponent.clickOnIntSaveIcon(); - - await expect(await cardViewPageComponent.getErrorInt()).toBe('Use an integer format'); - }); - - it('[C279951] Should be possible undo item modify when click on the clear button', async () => { - await cardViewPageComponent.clickOnIntField(); - await cardViewPageComponent.enterIntField('999'); - await cardViewPageComponent.clickOnIntClearIcon(); - - await expect(await cardViewPageComponent.getIntFieldText()).toBe('213'); - }); - }); - - describe('Float', () => { - - it('[C279941] Should the label be present', async () => { - const label = element(by.css('div[data-automation-id="card-textitem-label-float"]')); - - await BrowserVisibility.waitUntilElementIsPresent(label); - }); - - it('[C279952] Should be present a default value', async () => { - await expect(await cardViewPageComponent.getFloatFieldText()).toBe('9.9'); - }); - - it('[C279953] Should be possible edit float item', async () => { - await cardViewPageComponent.clickOnFloatField(); - await cardViewPageComponent.enterFloatField('77.33'); - await cardViewPageComponent.clickOnFloatSaveIcon(); - - await expect(await cardViewPageComponent.getOutputText(0)).toBe('[CardView Float Item] - 77.33'); - }); - - it('[C279954] Should not be possible add string value to the float item', async () => { - await cardViewPageComponent.clickOnFloatField(); - await cardViewPageComponent.enterFloatField('string value'); - await cardViewPageComponent.clickOnFloatSaveIcon(); - - await expect(await cardViewPageComponent.getErrorFloat()).toBe('Use a number format'); - }); - - it('[C279955] Should be possible undo item item modify when click on the clear button', async () => { - await cardViewPageComponent.clickOnFloatField(); - await cardViewPageComponent.enterFloatField('77.33'); - await cardViewPageComponent.clickOnFloatClearIcon(); - - await expect(await cardViewPageComponent.getFloatFieldText()).toBe('9.9'); - }); - - it('[C279956] Should not be possible have an empty value', async () => { - await cardViewPageComponent.clickOnFloatField(); - await cardViewPageComponent.enterFloatField(' '); - await cardViewPageComponent.clickOnFloatSaveIcon(); - - await expect(await cardViewPageComponent.getErrorFloat()).toBe('Use a number format'); - }); - }); - - describe('Boolean', () => { - - it('[C279942] Should the label be present', async () => { - const label = element(by.css('div[data-automation-id="card-boolean-label-boolean"]')); - - await BrowserVisibility.waitUntilElementIsPresent(label); - }); - - it('[C279957] Should be possible edit the checkbox value when click on it', async () => { - await cardViewPageComponent.checkboxClick(); - - await expect(await cardViewPageComponent.getOutputText(0)).toBe('[CardView Boolean Item] - false'); - - await cardViewPageComponent.checkboxClick(); - - await expect(await cardViewPageComponent.getOutputText(1)).toBe('[CardView Boolean Item] - true'); - }); - }); - - describe('Date and DateTime', () => { - - it('[C279961] Should the label be present', async () => { - const labelDate = element(by.css('div[data-automation-id="card-dateitem-label-date"]')); - - await BrowserVisibility.waitUntilElementIsPresent(labelDate); - - const labelDatetime = element(by.css('div[data-automation-id="card-dateitem-label-datetime"]')); - - await BrowserVisibility.waitUntilElementIsPresent(labelDatetime); - }); - - it('[C279962] Should be present a default value', async () => { - await expect(await metadataViewPage.getPropertyText('date', 'date')).toEqual('12/24/83'); - await expect(await metadataViewPage.getPropertyText('datetime', 'datetime')).toEqual('12/24/83, 10:00 AM'); - }); - - it('[C312447] Should be able to clear the date field', async () => { - await cardViewPageComponent.enableClearDate(); - await cardViewPageComponent.clearDateField(); - await expect(await cardViewPageComponent.getDateValue()).toBe('', 'Date field should be cleared'); - await expect(cardViewPageComponent.getOutputText(0)) - .toBe('[CardView Date Item] - null'); - await cardViewPageComponent.clearDateTimeField(); - await expect(await cardViewPageComponent.getDateTimeValue()).toBe('', 'DateTime field should be cleared'); - await expect(cardViewPageComponent.getOutputText(1)) - .toBe('[CardView Datetime Item] - null'); - }); - }); - - it('[C306895] Should display the form field as editable and clickable depending on the \'Editable\' toggle mode.', async () => { - const message = 'clickable updated'; - await cardViewPageComponent.clickOnResetButton(); - await expect(await cardViewPageComponent.getClickableValue()).toContain('click here'); - - await cardViewPageComponent.updateClickableField(message); - await expect(await cardViewPageComponent.hasCardViewConsoleLog(message)).toContain(`[This is clickable ] - ${message}`); - - await cardViewPageComponent.clickOnResetButton(); - await cardViewPageComponent.updateClickableField(''); - await expect(await cardViewPageComponent.hasCardViewConsoleLog('[This is clickable ] -' )).toContain('[This is clickable ] -'); - }); - - it('[C279936] Should not be possible edit any parameter when editable property is false', async () => { - await cardViewPageComponent.disableEdit(); - - const editIconText = element(by.css('button[data-automation-id="card-textitem-edit-icon-name"]')); - const editIconInt = element(by.css('button[data-automation-id="card-textitem-edit-icon-int"]')); - const editIconFloat = element(by.css('button[data-automation-id="card-textitem-edit-icon-float"]')); - const editIconKey = element(by.css('mat-icon[data-automation-id="card-key-value-pairs-button-key-value-pairs"]')); - const editIconData = element(by.css('mat-datetimepicker-toggle')); - - await BrowserVisibility.waitUntilElementIsNotVisible(editIconText); - await BrowserVisibility.waitUntilElementIsNotVisible(editIconInt); - await BrowserVisibility.waitUntilElementIsNotVisible(editIconFloat); - await BrowserVisibility.waitUntilElementIsNotVisible(editIconKey); - await BrowserVisibility.waitUntilElementIsNotVisible(editIconData); - }); -}); diff --git a/e2e/core/datatable/data-table-component-selection.e2e.ts b/e2e/core/datatable/data-table-component-selection.e2e.ts index b7e0b44227..35190ba8f4 100644 --- a/e2e/core/datatable/data-table-component-selection.e2e.ts +++ b/e2e/core/datatable/data-table-component-selection.e2e.ts @@ -69,33 +69,4 @@ describe('Datatable component - selection', () => { await dataTablePage.checkNoRowIsSelected(); }); - it('[C260059] Should be possible select multiple row when multiselect is true', async () => { - await dataTablePage.clickMultiSelect(); - await dataTablePage.clickCheckbox('1'); - await dataTablePage.checkRowIsChecked('1'); - await dataTablePage.clickCheckbox('3'); - await dataTablePage.checkRowIsChecked('3'); - await dataTablePage.checkRowIsNotChecked('2'); - await dataTablePage.checkRowIsNotChecked('4'); - await dataTablePage.clickCheckbox('3'); - await dataTablePage.checkRowIsNotChecked('3'); - await dataTablePage.checkRowIsChecked('1'); - }); - - it('[C260058] Should be possible select all the rows when multiselect is true', async () => { - await dataTablePage.checkAllRows(); - await dataTablePage.checkRowIsChecked('1'); - await dataTablePage.checkRowIsChecked('2'); - await dataTablePage.checkRowIsChecked('3'); - await dataTablePage.checkRowIsChecked('4'); - }); - - it('[C277262] Should be possible reset the selected row when click on the reset button', async () => { - await dataTablePage.checkRowIsChecked('1'); - await dataTablePage.checkRowIsChecked('2'); - await dataTablePage.checkRowIsChecked('3'); - await dataTablePage.checkRowIsChecked('4'); - await dataTablePage.clickReset(); - await dataTablePage.checkNoRowIsSelected(); - }); }); diff --git a/e2e/process-services-cloud/process-custom-filters.e2e.ts b/e2e/process-services-cloud/process-custom-filters.e2e.ts index 17ca81c40f..317e199594 100644 --- a/e2e/process-services-cloud/process-custom-filters.e2e.ts +++ b/e2e/process-services-cloud/process-custom-filters.e2e.ts @@ -227,18 +227,6 @@ describe('Process list cloud', () => { await expect(await processCloudDemoPage.processListCloudComponent().getDataTable().checkListIsSorted('DESC', 'Business Key')).toBe(true); }); - it('[C305054] Should display the actions filters Save, SaveAs and Delete', async () => { - await processCloudDemoPage.processFilterCloudComponent.clickAllProcessesFilter(); - await expect(await processCloudDemoPage.processFilterCloudComponent.getActiveFilterName()).toBe('All Processes'); - await processCloudDemoPage.editProcessFilterCloudComponent().openFilter(); - - const editProcessFilterCloudComponent = processCloudDemoPage.editProcessFilterCloudComponent(); - - await editProcessFilterCloudComponent.checkSaveButtonIsDisplayed(); - await editProcessFilterCloudComponent.checkSaveAsButtonIsDisplayed(); - await editProcessFilterCloudComponent.checkDeleteButtonIsDisplayed(); - }); - it('[C297697] The value of the filter should be preserved when saving it', async () => { await processCloudDemoPage.editProcessFilterCloudComponent().openFilter(); await processCloudDemoPage.editProcessFilterCloudComponent().setProcessInstanceId(completedProcess.entry.id); @@ -297,32 +285,5 @@ describe('Process list cloud', () => { await BrowserActions.closeMenuAndDialogs(); }); - describe('Process List - Check Action Filters', () => { - - beforeEach(async () => { - await LocalStorageUtil.setConfigField('adf-edit-process-filter', JSON.stringify({ - 'actions': [ - 'save', - 'saveAs' - ] - })); - await navigationBarPage.navigateToProcessServicesCloudPage(); - await appListCloudComponent.checkApsContainer(); - await appListCloudComponent.goToApp(candidateBaseApp); - await tasksCloudDemoPage.taskListCloudComponent().checkTaskListIsLoaded(); - await processCloudDemoPage.processFilterCloudComponent.clickOnProcessFilters(); - - }); - - it('[C305054] Should display the actions filters Save and SaveAs, Delete button is not displayed', async () => { - await processCloudDemoPage.processFilterCloudComponent.clickAllProcessesFilter(); - await expect(await processCloudDemoPage.processFilterCloudComponent.getActiveFilterName()).toBe('All Processes'); - await processCloudDemoPage.editProcessFilterCloudComponent().openFilter(); - await processCloudDemoPage.editProcessFilterCloudComponent().checkSaveButtonIsDisplayed(); - await processCloudDemoPage.editProcessFilterCloudComponent().checkSaveAsButtonIsDisplayed(); - await processCloudDemoPage.editProcessFilterCloudComponent().checkDeleteButtonIsNotDisplayed(); - }); - - }); }); }); diff --git a/e2e/process-services-cloud/process-filter-results.e2e.ts b/e2e/process-services-cloud/process-filter-results.e2e.ts index adbb22bb8e..cdea83ea2c 100644 --- a/e2e/process-services-cloud/process-filter-results.e2e.ts +++ b/e2e/process-services-cloud/process-filter-results.e2e.ts @@ -184,14 +184,6 @@ describe('Process filters cloud', () => { await processCloudDemoPage.processListCloudComponent().checkContentIsNotDisplayedByName(differentAppUserProcessInstance.entry.name); }); - it('[C306891] Should be able to see "No process found" when providing an initiator whitout processes', async () => { - await processCloudDemoPage.editProcessFilterCloudComponent().openFilter(); - await processCloudDemoPage.editProcessFilterCloudComponent().setProperty('initiator', anotherUser.username); - - await processCloudDemoPage.processListCloudComponent().getDataTable().waitTillContentLoaded(); - await expect(await processListPage.getDisplayedProcessListTitle()).toEqual('No Processes Found'); - }); - it('[C311315] Should be able to filter by process definition id', async () => { await processCloudDemoPage.editProcessFilterCloudComponent().openFilter(); await processCloudDemoPage.editProcessFilterCloudComponent().setProperty('processDefinitionId', processDefinition.entry.id); diff --git a/e2e/process-services-cloud/process-filter-task.e2e.ts b/e2e/process-services-cloud/process-filter-task.e2e.ts index 412edd8389..c9cd2ecab6 100644 --- a/e2e/process-services-cloud/process-filter-task.e2e.ts +++ b/e2e/process-services-cloud/process-filter-task.e2e.ts @@ -31,10 +31,13 @@ import { ProcessCloudDemoPage } from '../pages/adf/demo-shell/process-services/p import { ProcessDetailsCloudDemoPage } from '../pages/adf/demo-shell/process-services-cloud/process-details-cloud-demo.page'; import { TasksCloudDemoPage } from '../pages/adf/demo-shell/process-services/tasks-cloud-demo.page'; import { NavigationBarPage } from '../pages/adf/navigation-bar.page'; -import { ProcessListPage } from '../pages/adf/process-services/process-list.page'; import { EditProcessFilterConfiguration } from './config/edit-process-filter.config'; import { ProcessListCloudConfiguration } from './config/process-list-cloud.config'; -import { ProcessDefinitionCloud, ProcessInstanceCloud, StartTaskCloudResponseModel } from '@alfresco/adf-process-services-cloud'; +import { + ProcessDefinitionCloud, + ProcessInstanceCloud, + StartTaskCloudResponseModel +} from '@alfresco/adf-process-services-cloud'; describe('Process filters cloud', () => { const loginSSOPage = new LoginSSOPage(); @@ -45,7 +48,6 @@ describe('Process filters cloud', () => { const processDetailsCloudDemoPage = new ProcessDetailsCloudDemoPage(); const taskHeaderCloudPage = new TaskHeaderCloudPage(); const taskFormCloudComponent = new TaskFormCloudComponent(); - const processListPage = new ProcessListPage(); const apiService = new ApiService( browser.params.config.oauth2.clientId, browser.params.config.bpmHost, browser.params.config.oauth2.host, browser.params.config.providers @@ -88,30 +90,6 @@ describe('Process filters cloud', () => { await processCloudDemoPage.processFilterCloudComponent.clickOnProcessFilters(); }); - it('[C290041] Should be displayed the "No Process Found" message when the process list is empty', async () => { - await processCloudDemoPage.editProcessFilterCloudComponent().openFilter(); - await processCloudDemoPage.editProcessFilterCloudComponent().setAppNameDropDown(simpleApp); - await processCloudDemoPage.editProcessFilterCloudComponent().setStatusFilterDropDown('COMPLETED'); - - await processCloudDemoPage.processListCloudComponent().getDataTable().waitTillContentLoaded(); - await expect(await processCloudDemoPage.processListCloudComponent().getDataTable().contents.count()).toBeGreaterThan(0); - - await processCloudDemoPage.editProcessFilterCloudComponent().setProperty('processInstanceId', 'i_am_fake_id'); - await expect(await processListPage.getDisplayedProcessListTitle()).toEqual('No Processes Found'); - }); - - it('[C315296] Should NOT display "No Process Found" before displaying the process list', async () => { - await processCloudDemoPage.editProcessFilterCloudComponent().openFilter(); - await processCloudDemoPage.editProcessFilterCloudComponent().setAppNameDropDown(simpleApp); - await processCloudDemoPage.editProcessFilterCloudComponent().setStatusFilterDropDown('COMPLETED'); - - await expect(await processListPage.titleNotPresent()).toBeTruthy(); - await expect(await processCloudDemoPage.processListCloudComponent().getDataTable().contents.count()).toBeGreaterThan(0); - - await processCloudDemoPage.editProcessFilterCloudComponent().setProperty('processInstanceId', 'i_am_fake_id'); - await expect(await processListPage.getDisplayedProcessListTitle()).toEqual('No Processes Found'); - }); - it('[C290040] Should be able to open the Task Details page by clicking on the process name', async () => { await processCloudDemoPage.editProcessFilterCloudComponent().openFilter(); await processCloudDemoPage.editProcessFilterCloudComponent().setAppNameDropDown(simpleApp); diff --git a/e2e/process-services-cloud/process-list-cloud-component.e2e.ts b/e2e/process-services-cloud/process-list-cloud-component.e2e.ts deleted file mode 100644 index a9498df94c..0000000000 --- a/e2e/process-services-cloud/process-list-cloud-component.e2e.ts +++ /dev/null @@ -1,102 +0,0 @@ -/*! - * @license - * Copyright 2019 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ApiService, AppListCloudPage, GroupIdentityService, IdentityService, LocalStorageUtil, LoginSSOPage, ProcessDefinitionsService, ProcessInstancesService } from '@alfresco/adf-testing'; -import { browser } from 'protractor'; -import { ProcessCloudDemoPage } from '../pages/adf/demo-shell/process-services/process-cloud-demo.page'; -import { NavigationBarPage } from '../pages/adf/navigation-bar.page'; -import { ProcessListCloudConfiguration } from './config/process-list-cloud.config'; - -describe('Process list cloud', () => { - - describe('Process List', () => { - const loginSSOPage = new LoginSSOPage(); - const navigationBarPage = new NavigationBarPage(); - const appListCloudComponent = new AppListCloudPage(); - const processCloudDemoPage = new ProcessCloudDemoPage(); - const apiService = new ApiService(browser.params.config.oauth2.clientId, browser.params.config.bpmHost, browser.params.config.oauth2.host, 'BPM'); - - let processDefinitionService: ProcessDefinitionsService; - let processInstancesService: ProcessInstancesService; - let identityService: IdentityService; - let groupIdentityService: GroupIdentityService; - let testUser, groupInfo; - - const candidateBaseApp = browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.name; - let jsonFile; - let runningProcess; - - beforeAll(async () => { - await apiService.login(browser.params.identityAdmin.email, browser.params.identityAdmin.password); - identityService = new IdentityService(apiService); - groupIdentityService = new GroupIdentityService(apiService); - testUser = await identityService.createIdentityUserWithRole(apiService, [identityService.ROLES.ACTIVITI_USER]); - groupInfo = await groupIdentityService.getGroupInfoByGroupName('hr'); - await identityService.addUserToGroup(testUser.idIdentityService, groupInfo.id); - - await apiService.login(testUser.email, testUser.password); - - processDefinitionService = new ProcessDefinitionsService(apiService); - const processDefinition = await processDefinitionService - .getProcessDefinitionByName(browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.processes.candidateGroupProcess, candidateBaseApp); - - processInstancesService = new ProcessInstancesService(apiService); - runningProcess = await processInstancesService.createProcessInstance(processDefinition.entry.key, candidateBaseApp); - - await loginSSOPage.loginSSOIdentityService(testUser.email, testUser.password); - }); - - afterAll(async () => { - await apiService.login(browser.params.identityAdmin.email, browser.params.identityAdmin.password); - await identityService.deleteIdentityUser(testUser.idIdentityService); - - }); - - beforeEach(async () => { - const processListCloudConfiguration = new ProcessListCloudConfiguration(); - jsonFile = processListCloudConfiguration.getConfiguration(); - - await LocalStorageUtil.setConfigField('adf-cloud-process-list', JSON.stringify(jsonFile)); - - await navigationBarPage.navigateToProcessServicesCloudPage(); - await appListCloudComponent.checkApsContainer(); - await appListCloudComponent.goToApp(candidateBaseApp); - await processCloudDemoPage.processFilterCloudComponent.clickOnProcessFilters(); - await processCloudDemoPage.processFilterCloudComponent.clickRunningProcessesFilter(); - await expect(await processCloudDemoPage.processFilterCloudComponent.getActiveFilterName()).toBe('Running Processes'); - await processCloudDemoPage.processListCloudComponent().checkProcessListIsLoaded(); - await processCloudDemoPage.processListCloudComponent().checkContentIsDisplayedById(runningProcess.entry.id); - - }); - - it('[C291997] Should be able to change the default columns', async () => { - - await expect(await processCloudDemoPage.processListCloudComponent().getDataTable().getNumberOfColumns()).toBe(10); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('id'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('name'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('status'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('startDate'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('appName'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('businessKey'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('initiator'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('lastModified'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('processDefinitionId'); - await processCloudDemoPage.processListCloudComponent().getDataTable().checkColumnIsDisplayed('processDefinitionKey'); - - }); - }); -}); diff --git a/e2e/process-services-cloud/start-task/start-task-custom-app-cloud.e2e.ts b/e2e/process-services-cloud/start-task/start-task-custom-app-cloud.e2e.ts index 947e68e094..dfe589bfa5 100644 --- a/e2e/process-services-cloud/start-task/start-task-custom-app-cloud.e2e.ts +++ b/e2e/process-services-cloud/start-task/start-task-custom-app-cloud.e2e.ts @@ -199,13 +199,6 @@ describe('Start Task', () => { await expect(await tasksCloudDemoPage.taskFilterCloudComponent.getActiveFilterName()).toBe('My Tasks'); }); - it('[C291953] Assignee field should display the logged user as default', async () => { - await tasksCloudDemoPage.openNewTaskForm(); - await startTask.checkFormIsDisplayed(); - await expect(await peopleCloudComponent.checkSelectedPeople(testUser.firstName)); - await startTask.clickCancelButton(); - }); - it('[C305050] Should be able to reassign the removed user when starting a new task', async () => { await tasksCloudDemoPage.openNewTaskForm(); await startTask.checkFormIsDisplayed(); diff --git a/e2e/process-services-cloud/task-filters-cloud.e2e.ts b/e2e/process-services-cloud/task-filters-cloud.e2e.ts index dfa7880187..bcfa681a92 100644 --- a/e2e/process-services-cloud/task-filters-cloud.e2e.ts +++ b/e2e/process-services-cloud/task-filters-cloud.e2e.ts @@ -63,11 +63,6 @@ describe('Task filters cloud', () => { await appListCloudComponent.goToApp(simpleApp); }); - it('[C290011] Should display default filters when an app is deployed', async () => { - await tasksCloudDemoPage.taskFilterCloudComponent.checkMyTasksFilterIsDisplayed(); - await tasksCloudDemoPage.taskFilterCloudComponent.checkCompletedTasksFilterIsDisplayed(); - }); - it('[C290009] Should display default filters and created task', async () => { tasksService = new TasksService(apiService); @@ -101,9 +96,5 @@ describe('Task filters cloud', () => { await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(completedTask); }); - it('[C291792] Should select the first task filter from the list as default', async () => { - - await expect(await tasksCloudDemoPage.taskFilterCloudComponent.firstFilterIsActive()).toBe(true); - }); }); }); diff --git a/lib/core/card-view/components/card-view-dateitem/card-view-dateitem.component.spec.ts b/lib/core/card-view/components/card-view-dateitem/card-view-dateitem.component.spec.ts index 90b5cab867..8d0fc64d47 100644 --- a/lib/core/card-view/components/card-view-dateitem/card-view-dateitem.component.spec.ts +++ b/lib/core/card-view/components/card-view-dateitem/card-view-dateitem.component.spec.ts @@ -23,17 +23,26 @@ import { CardViewDateItemModel } from '../../models/card-view-dateitem.model'; import { CardViewUpdateService } from '../../services/card-view-update.service'; import { CardViewDateItemComponent } from './card-view-dateitem.component'; import { CoreTestingModule } from '../../../testing/core.testing.module'; +import { AppConfigService } from '@alfresco/adf-core'; describe('CardViewDateItemComponent', () => { let fixture: ComponentFixture; let component: CardViewDateItemComponent; + let appConfigService: AppConfigService; setupTestBed({ imports: [CoreTestingModule] }); beforeEach(() => { + appConfigService = TestBed.get(AppConfigService); + appConfigService.config.dateValues = { + defaultDateFormat: 'shortDate', + defaultDateTimeFormat: 'M/d/yy, h:mm a', + defaultLocale: 'uk' + }; + fixture = TestBed.createComponent(CardViewDateItemComponent); component = fixture.componentInstance; component.property = new CardViewDateItemModel({ @@ -46,8 +55,10 @@ describe('CardViewDateItemComponent', () => { }); }); - afterEach(() => { - fixture.destroy(); + afterEach(() => fixture.destroy()); + + it('should pick date format from appConfigService', () => { + expect(component.dateFormat).toEqual('shortDate'); }); it('should render the label and value', () => { @@ -153,6 +164,7 @@ describe('CardViewDateItemComponent', () => { component.property.editable = true; fixture.detectChanges(); + expect(component.isEditable()).toBe(false); const datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-${component.property.key}"]`)); const datePickerToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepickertoggle-${component.property.key}"]`)); expect(datePicker).toBeNull('Datepicker should NOT be in DOM'); @@ -206,101 +218,111 @@ describe('CardViewDateItemComponent', () => { ); })); - it('should render the clear icon in case of displayClearAction:true', () => { - component.editable = true; - component.property.editable = true; - component.property.value = 'Jul 10 2017'; - fixture.detectChanges(); - - const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear-${component.property.key}"]`)); - expect(datePickerClearToggle).not.toBeNull('Clean Icon should be in DOM'); - }); - - it('should not render the clear icon in case of property value empty', () => { - component.editable = true; - component.property.editable = true; - component.property.value = null; - fixture.detectChanges(); - - const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear--${component.property.key}"]`)); - expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM'); - }); - - it('should not render the clear icon in case of displayClearAction:false', () => { - component.editable = true; - component.property.editable = true; - component.displayClearAction = false; - component.property.value = 'Jul 10 2017'; - fixture.detectChanges(); - - const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear--${component.property.key}"]`)); - expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM'); - }); - - it('should remove the property value after a successful clear attempt', async(() => { - component.editable = true; - component.property.editable = true; - component.property.value = 'Jul 10 2017'; - fixture.detectChanges(); - - component.onDateClear(); - - fixture.whenStable().then( - () => { - expect(component.property.value).toBeNull(); - } - ); - })); - - it('should remove the property default value after a successful clear attempt', async(() => { - component.editable = true; - component.property.editable = true; - component.property.default = 'Jul 10 2017'; - fixture.detectChanges(); - - component.onDateClear(); - - fixture.whenStable().then( - () => { - expect(component.property.default).toBeNull(); - } - ); - })); - - it('should remove actual and default value after a successful clear attempt', async(() => { - component.editable = true; - component.property.editable = true; - component.property.default = 'Jul 10 2017'; - component.property.value = 'Jul 10 2017'; - fixture.detectChanges(); - - component.onDateClear(); - - fixture.whenStable().then( - () => { - expect(component.property.value).toBeNull(); - expect(component.property.default).toBeNull(); - } - ); - })); - - it('should be possible update a date/date-time', async(() => { - component.editable = true; - component.property.editable = true; - component.property.default = 'Jul 10 2017'; - component.property.key = 'fake-key'; - component.property.value = 'Jul 10 2017'; - const expectedDate = moment('Jul 10 2018', 'MMM DD YY'); - fixture.detectChanges(); - - fixture.whenStable().then(() => { + describe('clear icon', () => { + it('should render the clear icon in case of displayClearAction:true', () => { + component.editable = true; + component.property.editable = true; + component.property.value = 'Jul 10 2017'; fixture.detectChanges(); - const element = fixture.debugElement.nativeElement.querySelector('span[data-automation-id="card-date-value-fake-key"]'); - expect(element).toBeDefined(); - expect(element.innerText).toEqual('Jul 10, 2017'); - component.onDateChanged({ value: expectedDate }); - fixture.detectChanges(); - fixture.whenStable().then(() => expect(component.property.value).toEqual(expectedDate.toDate())); + + const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear-${component.property.key}"]`)); + expect(datePickerClearToggle).not.toBeNull('Clean Icon should be in DOM'); }); - })); + + it('should not render the clear icon in case of property value empty', () => { + component.editable = true; + component.property.editable = true; + component.property.value = null; + fixture.detectChanges(); + + const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear--${component.property.key}"]`)); + expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM'); + }); + + it('should not render the clear icon in case of displayClearAction:false', () => { + component.editable = true; + component.property.editable = true; + component.displayClearAction = false; + component.property.value = 'Jul 10 2017'; + fixture.detectChanges(); + + const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear--${component.property.key}"]`)); + expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM'); + }); + + it('should remove the property value after a successful clear attempt', async(() => { + component.editable = true; + component.property.editable = true; + component.property.value = 'Jul 10 2017'; + fixture.detectChanges(); + + component.onDateClear(); + + fixture.whenStable().then( + () => { + expect(component.property.value).toBeNull(); + } + ); + })); + + it('should remove the property default value after a successful clear attempt', async(() => { + component.editable = true; + component.property.editable = true; + component.property.default = 'Jul 10 2017'; + fixture.detectChanges(); + + component.onDateClear(); + + fixture.whenStable().then( + () => { + expect(component.property.default).toBeNull(); + } + ); + })); + + it('should remove actual and default value after a successful clear attempt', async(() => { + component.editable = true; + component.property.editable = true; + component.property.default = 'Jul 10 2017'; + component.property.value = 'Jul 10 2017'; + fixture.detectChanges(); + const cardViewUpdateService = TestBed.get(CardViewUpdateService); + + const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe( + (updateNotification) => { + expect(updateNotification.target).toBe(component.property); + expect(updateNotification.changed).toEqual({ dateKey: null }); + disposableUpdate.unsubscribe(); + } + ); + + component.onDateClear(); + + fixture.whenStable().then(() => { + expect(component.property.value).toBeNull(); + expect(component.property.default).toBeNull(); + }); + })); + }); + + it('should be possible update a date-time', async () => { + component.editable = true; + component.property.editable = true; + component.property.default = 'Jul 10 2017 00:01:00'; + component.property.key = 'fake-key'; + component.dateFormat = 'M/d/yy, h:mm a'; + component.property.value = 'Jul 10 2017 00:01:00'; + const expectedDate = moment('Jul 10 2018', 'MMM DD YY h:m:s'); + fixture.detectChanges(); + + await fixture.whenStable(); + fixture.detectChanges(); + const element = fixture.debugElement.nativeElement.querySelector('span[data-automation-id="card-date-value-fake-key"]'); + expect(element).toBeDefined(); + expect(element.innerText).toEqual('Jul 10, 2017'); + component.onDateChanged({ value: expectedDate }); + + fixture.detectChanges(); + expect(component.property.value).toEqual(expectedDate.toDate()); + }); }); diff --git a/lib/core/card-view/components/card-view-keyvaluepairsitem/card-view-keyvaluepairsitem.component.spec.ts b/lib/core/card-view/components/card-view-keyvaluepairsitem/card-view-keyvaluepairsitem.component.spec.ts index 3653195c31..e3cd73815b 100644 --- a/lib/core/card-view/components/card-view-keyvaluepairsitem/card-view-keyvaluepairsitem.component.spec.ts +++ b/lib/core/card-view/components/card-view-keyvaluepairsitem/card-view-keyvaluepairsitem.component.spec.ts @@ -66,12 +66,14 @@ describe('CardViewKeyValuePairsItemComponent', () => { component.property = new CardViewKeyValuePairsItemModel({ label: 'Key Value Pairs', value: mockData, - key: 'key-value-pairs' + key: 'key-value-pairs', + editable: false }); component.ngOnChanges(); fixture.detectChanges(); + expect(component.isEditable()).toBe(false); const table = fixture.debugElement.query(By.css('.adf-card-view__key-value-pairs__read-only')); const form = fixture.debugElement.query(By.css('.adf-card-view__key-value-pairs')); @@ -96,7 +98,6 @@ describe('CardViewKeyValuePairsItemComponent', () => { const valueInput = fixture.debugElement.query(By.css(`[data-automation-id="card-${component.property.key}-value-input-0"]`)); expect(nameInput).not.toBeNull(); expect(valueInput).not.toBeNull(); - }); it('should remove an item from list on REMOVE button click', () => { diff --git a/lib/core/card-view/components/card-view-selectitem/card-view-selectitem.component.spec.ts b/lib/core/card-view/components/card-view-selectitem/card-view-selectitem.component.spec.ts index cbae86ccf0..917426c8ca 100644 --- a/lib/core/card-view/components/card-view-selectitem/card-view-selectitem.component.spec.ts +++ b/lib/core/card-view/components/card-view-selectitem/card-view-selectitem.component.spec.ts @@ -16,6 +16,7 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { OverlayContainer } from '@angular/cdk/overlay'; import { By } from '@angular/platform-browser'; import { CardViewSelectItemModel } from '../../models/card-view-selectitem.model'; import { CardViewSelectItemComponent } from './card-view-selectitem.component'; @@ -27,6 +28,7 @@ describe('CardViewSelectItemComponent', () => { let fixture: ComponentFixture; let component: CardViewSelectItemComponent; + let overlayContainer: OverlayContainer; const mockData = [{ key: 'one', label: 'One' }, { key: 'two', label: 'Two' }, { key: 'three', label: 'Three' }]; const mockDefaultProps = { label: 'Select box label', @@ -43,6 +45,7 @@ describe('CardViewSelectItemComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(CardViewSelectItemComponent); component = fixture.componentInstance; + overlayContainer = TestBed.get(OverlayContainer); component.property = new CardViewSelectItemModel(mockDefaultProps); }); @@ -75,6 +78,50 @@ describe('CardViewSelectItemComponent', () => { expect(selectBox).toBeNull(); }); + it('should be possible edit selectBox item', () => { + component.property = new CardViewSelectItemModel({ + ...mockDefaultProps, + editable: true + }); + component.editable = true; + component.displayNoneOption = true; + component.ngOnChanges(); + fixture.detectChanges(); + + expect(component.value).toEqual('two'); + expect(component.isEditable()).toBe(true); + const selectBox = fixture.debugElement.query(By.css('.mat-select-trigger')); + selectBox.triggerEventHandler('click', {}); + + fixture.detectChanges(); + const optionsElement = Array.from(overlayContainer.getContainerElement().querySelectorAll('mat-option')); + expect(optionsElement.length).toEqual(4); + optionsElement[1].dispatchEvent(new Event('click')); + fixture.detectChanges(); + + expect(component.value).toEqual('one'); + }); + + it('should be able to enable None option', () => { + component.property = new CardViewSelectItemModel({ + ...mockDefaultProps, + editable: true + }); + component.editable = true; + component.displayNoneOption = true; + component.ngOnChanges(); + fixture.detectChanges(); + + expect(component.isEditable()).toBe(true); + const selectBox = fixture.debugElement.query(By.css('.mat-select-trigger')); + selectBox.triggerEventHandler('click', {}); + + fixture.detectChanges(); + const noneElement: HTMLElement = overlayContainer.getContainerElement().querySelector('mat-option'); + expect(noneElement).toBeDefined(); + expect(noneElement.innerText).toEqual('CORE.CARDVIEW.NONE'); + }); + it('should render select box if editable property is TRUE', () => { component.ngOnChanges(); component.editable = true; diff --git a/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts b/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts index 9e578a13e5..f2f3b63499 100644 --- a/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts +++ b/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts @@ -22,11 +22,13 @@ import { CardViewUpdateService } from '../../services/card-view-update.service'; import { CardViewTextItemComponent } from './card-view-textitem.component'; import { setupTestBed } from '../../../testing/setup-test-bed'; import { CoreTestingModule } from '../../../testing/core.testing.module'; +import { CardViewItemFloatValidator, CardViewItemIntValidator } from '@alfresco/adf-core'; describe('CardViewTextItemComponent', () => { let fixture: ComponentFixture; let component: CardViewTextItemComponent; + const mouseEvent = new MouseEvent('click'); setupTestBed({ imports: [CoreTestingModule] @@ -109,128 +111,6 @@ describe('CardViewTextItemComponent', () => { expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY'); }); - it('should render the default as value if the value is empty, clickable is false and displayEmpty is true', () => { - component.property = new CardViewTextItemModel({ - label: 'Text label', - value: '', - key: 'textkey', - default: 'FAKE-DEFAULT-KEY', - clickable: false - }); - component.displayEmpty = true; - fixture.detectChanges(); - - const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`)); - expect(value).not.toBeNull(); - expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY'); - }); - - it('should render the default as value if the value is empty and clickable true', () => { - component.property = new CardViewTextItemModel({ - label: 'Text label', - value: '', - key: 'textkey', - default: 'FAKE-DEFAULT-KEY', - clickable: true - }); - fixture.detectChanges(); - - const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`)); - expect(value).not.toBeNull(); - expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY'); - }); - - it('should not render the edit icon in case of clickable true but edit false', () => { - component.property = new CardViewTextItemModel({ - label: 'Text label', - value: '', - key: 'textkey', - default: 'FAKE-DEFAULT-KEY', - clickable: true - }); - fixture.detectChanges(); - - const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`)); - expect(value).toBeNull(); - }); - - it('should not render the clickable icon in case editable set to false', () => { - component.property = new CardViewTextItemModel({ - label: 'Text label', - value: '', - key: 'textkey', - default: 'FAKE-DEFAULT-KEY', - clickable: true, - icon: 'create' - }); - component.editable = false; - fixture.detectChanges(); - - const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`)); - expect(value).toBeNull('icon should NOT be shown'); - }); - - it('should render the defined clickable icon in case of clickable true and editable input set to true', () => { - component.property = new CardViewTextItemModel({ - label: 'Text label', - value: '', - key: 'textkey', - default: 'FAKE-DEFAULT-KEY', - clickable: true, - icon: 'FAKE_ICON' - }); - component.editable = true; - fixture.detectChanges(); - - const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`)); - expect(value).not.toBeNull(); - expect(value.nativeElement.innerText).toBe('FAKE_ICON'); - }); - - it('should not render clickable icon in case of clickable true and icon undefined', () => { - component.property = new CardViewTextItemModel({ - label: 'Text label', - value: '', - key: 'textkey', - default: 'FAKE-DEFAULT-KEY', - clickable: true - }); - component.editable = true; - fixture.detectChanges(); - - const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`)); - expect(value).toBeNull('icon should NOT be shown'); - }); - - it('should not render the edit icon in case of clickable true and icon undefined', () => { - component.property = new CardViewTextItemModel({ - label: 'Text label', - value: '', - key: 'textkey', - default: 'FAKE-DEFAULT-KEY', - clickable: true - }); - fixture.detectChanges(); - - const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`)); - expect(value).toBeNull('Edit icon should NOT be shown'); - }); - - it('should not render the edit icon in case of clickable false and icon defined', () => { - component.property = new CardViewTextItemModel({ - label: 'Text label', - value: '', - key: 'textkey', - default: 'FAKE-DEFAULT-KEY', - clickable: false, - icon: 'FAKE-ICON' - }); - fixture.detectChanges(); - - const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`)); - expect(value).toBeNull('Edit icon should NOT be shown'); - }); - it('should render value when editable:true', () => { component.editable = true; component.property.editable = true; @@ -268,6 +148,142 @@ describe('CardViewTextItemComponent', () => { }); }); + describe('clickable', () => { + beforeEach(() => { + component.property = new CardViewTextItemModel({ + label: 'Text label', + value: '', + key: 'textkey', + default: 'FAKE-DEFAULT-KEY' + }); + }); + + it('should render the default as value if the value is empty, clickable is false and displayEmpty is true', () => { + component.property.clickable = false; + component.displayEmpty = true; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`)); + expect(value).not.toBeNull(); + expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY'); + }); + + it('should render the default as value if the value is empty and clickable true', () => { + component.property.clickable = true; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`)); + expect(value).not.toBeNull(); + expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY'); + }); + + it('should not render the edit icon in case of clickable true but edit false', () => { + component.property.clickable = true; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`)); + expect(value).toBeNull(); + }); + + it('should not render the clickable icon in case editable set to false', () => { + component.property.clickable = true; + component.property.icon = 'create'; + component.editable = false; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`)); + expect(value).toBeNull('icon should NOT be shown'); + }); + + it('should render the defined clickable icon in case of clickable true and editable input set to true', () => { + component.property.clickable = true; + component.property.icon = 'FAKE_ICON'; + component.editable = true; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`)); + expect(value).not.toBeNull(); + expect(value.nativeElement.innerText).toBe('FAKE_ICON'); + }); + + it('should not render clickable icon in case of clickable true and icon undefined', () => { + component.property.clickable = true; + component.editable = true; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`)); + expect(value).toBeNull('icon should NOT be shown'); + }); + + it('should not render the edit icon in case of clickable false and icon defined', () => { + component.property.clickable = false; + component.property.icon = 'FAKE_ICON'; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`)); + expect(value).toBeNull('Edit icon should NOT be shown'); + }); + + it('should call back function when clickable property enabled', () => { + const callBackSpy = jasmine.createSpy('callBack'); + component.property.clickable = true; + component.property.icon = 'FAKE_ICON'; + component.property.clickCallBack = callBackSpy; + component.editable = true; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`)); + expect(value.nativeElement.innerText).toBe('FAKE_ICON'); + value.nativeElement.click(); + expect(callBackSpy).toHaveBeenCalled(); + }); + + it('should click event to the event stream when clickable property enabled', () => { + const cardViewUpdateService = TestBed.get(CardViewUpdateService); + spyOn(cardViewUpdateService, 'clicked').and.stub(); + + component.property.clickable = true; + component.property.icon = 'FAKE_ICON'; + component.editable = false; + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-toggle-${component.property.key}"]`)); + value.nativeElement.click(); + expect(cardViewUpdateService.clicked).toHaveBeenCalled(); + }); + + it('should update input the value on click of save', () => { + component.property.clickable = true; + + component.property.editable = true; + component.editable = true; + component.editedValue = 'updated-value'; + component.property.isValid = () => true; + const expectedText = 'changed text'; + spyOn(component, 'update').and.callThrough(); + const cardViewUpdateService = TestBed.get(CardViewUpdateService); + fixture.detectChanges(); + + const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe((updateNotification) => { + expect(updateNotification.target).toBe(component.property); + expect(updateNotification.changed).toEqual({ textkey: expectedText }); + disposableUpdate.unsubscribe(); + }); + + updateTextField(component.property.key, expectedText); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + + expect(component.update).toHaveBeenCalled(); + fixture.detectChanges(); + + expect(getFieldValue(component.property.key)).toEqual(expectedText); + expect(component.property.value).toBe(expectedText); + }); + + }); + describe('Update', () => { const event = new MouseEvent('click'); @@ -416,7 +432,7 @@ describe('CardViewTextItemComponent', () => { editInput.nativeElement.dispatchEvent(enterKeyboardEvent); fixture.detectChanges(); - const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-textkey"]`)); + const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`)); expect(textItemReadOnly.nativeElement.textContent).toEqual(expectedText); expect(component.property.value).toBe(expectedText); })); @@ -439,9 +455,294 @@ describe('CardViewTextItemComponent', () => { editInput.nativeElement.dispatchEvent(enterKeyboardEvent); fixture.detectChanges(); - const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-textkey"]`)); + const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`)); expect(textItemReadOnly.nativeElement.textContent).toEqual('Lorem ipsum'); expect(component.property.value).toBe('Lorem ipsum'); })); + + it('should reset the value onclick of clear button', () => { + component.inEdit = false; + component.property.isValid = () => true; + spyOn(component, 'reset').and.callThrough(); + fixture.detectChanges(); + + updateTextField(component.property.key, 'changed text'); + + const clearButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-reset-${component.property.key}"]`)); + clearButton.nativeElement.click(); + expect(component.reset).toHaveBeenCalled(); + + fixture.detectChanges(); + + expect(getFieldValue(component.property.key)).toEqual('Lorem ipsum'); + expect(component.property.value).toBe('Lorem ipsum'); + }); + + it('should update multiline input the value on click of save', () => { + component.inEdit = false; + component.property.isValid = () => true; + component.property.multiline = true; + const expectedText = 'changed text'; + spyOn(component, 'update').and.callThrough(); + const cardViewUpdateService = TestBed.get(CardViewUpdateService); + fixture.detectChanges(); + + const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe((updateNotification) => { + expect(updateNotification.target).toBe(component.property); + expect(updateNotification.changed).toEqual({ textkey: expectedText }); + disposableUpdate.unsubscribe(); + }); + + updateTextArea(component.property.key, expectedText); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + + expect(component.update).toHaveBeenCalled(); + fixture.detectChanges(); + + expect(getFieldValue(component.property.key)).toEqual(expectedText); + expect(component.property.value).toBe(expectedText); + }); }); + + describe('number', () => { + let cardViewUpdateService: CardViewUpdateService; + + beforeEach(() => { + component.property.editable = true; + component.editable = true; + component.inEdit = false; + component.property.value = 10; + component.property.validators.push(new CardViewItemIntValidator()); + component.ngOnChanges(); + fixture.detectChanges(); + cardViewUpdateService = TestBed.get(CardViewUpdateService); + }); + + it('should show validation error when string passed', () => { + spyOn(component, 'update').and.callThrough(); + + updateTextField(component.property.key, 'update number'); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + fixture.detectChanges(); + expect(component.update).toHaveBeenCalled(); + + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR'); + expect(component.property.value).toBe(10); + }); + + it('should show validation error for empty string', () => { + spyOn(component, 'update').and.callThrough(); + + updateTextField(component.property.key, ' '); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + expect(component.update).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR'); + + expect(component.property.value).toBe(10); + }); + + it('should show validation error for float number', () => { + spyOn(component, 'update').and.callThrough(); + + updateTextField(component.property.key, 0.024); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + expect(component.update).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR'); + + expect(component.property.value).toBe(10); + }); + + it('should show validation error for exceed the number limit (2147483648)', () => { + spyOn(component, 'update').and.callThrough(); + + updateTextField(component.property.key, 2147483648); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + expect(component.update).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR'); + + expect(component.property.value).toBe(10); + }); + + it('should not show validation error for below the number limit (2147483647)', () => { + spyOn(component, 'update').and.callThrough(); + + updateTextField(component.property.key, 2147483647); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + expect(component.update).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error).toBeFalsy(); + + expect(component.property.value).toBe('2147483647'); + }); + + it('should reset the value onclick of clear button', () => { + spyOn(component, 'reset').and.callThrough(); + fixture.detectChanges(); + + updateTextField(component.property.key, 20); + + const clearButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-reset-${component.property.key}"]`)); + clearButton.nativeElement.click(); + expect(component.reset).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error).toBeFalsy(); + + expect(getFieldValue(component.property.key)).toEqual('10'); + expect(component.property.value).toBe(10); + }); + + it('should update input the value on click of save', () => { + component.property.multiline = true; + const expectedNumber = 2020; + spyOn(component, 'update').and.callThrough(); + fixture.detectChanges(); + expect(component.property.value).not.toEqual(expectedNumber); + + const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe((updateNotification) => { + expect(updateNotification.target).toBe(component.property); + expect(updateNotification.changed).toEqual({ textkey: expectedNumber.toString() }); + disposableUpdate.unsubscribe(); + }); + + updateTextArea(component.property.key, expectedNumber); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + expect(component.update).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error).toBeFalsy(); + + expect(getFieldValue(component.property.key)).toEqual(expectedNumber.toString()); + expect(component.property.value).toBe(expectedNumber.toString()); + }); + }); + + describe('float', () => { + let cardViewUpdateService: CardViewUpdateService; + const floatValue = 77.33; + + beforeEach(() => { + component.property.editable = true; + component.editable = true; + component.inEdit = false; + component.property.value = floatValue; + component.property.validators.push(new CardViewItemFloatValidator()); + component.ngOnChanges(); + fixture.detectChanges(); + cardViewUpdateService = TestBed.get(CardViewUpdateService); + }); + + it('should show validation error when string passed', () => { + spyOn(component, 'update').and.callThrough(); + + updateTextField(component.property.key, ' '); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + expect(component.update).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.FLOAT_VALIDATION_ERROR'); + + expect(component.property.value).toBe(floatValue); + }); + + it('should show validation error for empty string', () => { + spyOn(component, 'update').and.callThrough(); + + updateTextField(component.property.key, ' '); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + expect(component.update).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.FLOAT_VALIDATION_ERROR'); + + expect(component.property.value).toBe(floatValue); + }); + + it('should update input the value on click of save', () => { + component.property.multiline = true; + const expectedFloat = 88.44; + spyOn(component, 'update').and.callThrough(); + fixture.detectChanges(); + + const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe((updateNotification) => { + expect(updateNotification.target).toBe(component.property); + expect(updateNotification.changed).toEqual({ textkey: expectedFloat.toString() }); + disposableUpdate.unsubscribe(); + }); + + updateTextArea(component.property.key, expectedFloat); + + const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`)); + saveButton.nativeElement.click(); + expect(component.update).toHaveBeenCalled(); + + fixture.detectChanges(); + const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`)); + expect(error).toBeFalsy(); + + expect(getFieldValue(component.property.key)).toEqual(expectedFloat.toString()); + expect(component.property.value).toBe(expectedFloat.toString()); + }); + }); + + function updateTextField(key, value) { + const editIcon = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-toggle-${key}"]`)); + editIcon.nativeElement.dispatchEvent(new MouseEvent('click')); + fixture.detectChanges(); + + const editInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-editinput-${key}"]`)); + editInput.nativeElement.value = value; + editInput.nativeElement.dispatchEvent(new Event('input')); + fixture.detectChanges(); + } + + function updateTextArea(key, value) { + const editIcon = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-toggle-${key}"]`)); + editIcon.nativeElement.dispatchEvent(mouseEvent); + fixture.detectChanges(); + + const editInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edittextarea-${key}"]`)); + editInput.nativeElement.value = value; + editInput.nativeElement.dispatchEvent(new Event('input')); + fixture.detectChanges(); + } + + function getFieldValue(key): string { + const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`)); + return textItemReadOnly.nativeElement.textContent; + } }); diff --git a/lib/core/datatable/components/datatable/datatable.component.spec.ts b/lib/core/datatable/components/datatable/datatable.component.spec.ts index 305bb71bbd..1e80ed72ad 100644 --- a/lib/core/datatable/components/datatable/datatable.component.spec.ts +++ b/lib/core/datatable/components/datatable/datatable.component.spec.ts @@ -890,6 +890,25 @@ describe('DataTable', () => { expect(dataTable.isSelectAllChecked).toBe(true); }); + it('should allow select row when multi-select enabled', () => { + const data = new ObjectDataTableAdapter([{}, {}], []); + const rows = data.getRows(); + + dataTable.multiselect = true; + dataTable.ngOnChanges({ 'data': new SimpleChange('123', data, true) }); + + expect(rows[0].isSelected).toBe(false); + expect(rows[1].isSelected).toBe(false); + + dataTable.onCheckboxChange(rows[1], { checked: true }); + expect(rows[0].isSelected).toBe(false); + expect(rows[1].isSelected).toBe(true); + + dataTable.onCheckboxChange(rows[0], { checked: true }); + expect(rows[0].isSelected).toBe(true); + expect(rows[1].isSelected).toBe(true); + }); + it('should require multiselect option to toggle row state', () => { const data = new ObjectDataTableAdapter([{}, {}, {}], []); const rows = data.getRows(); diff --git a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts index 7c4875681c..d2307fbc05 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts @@ -15,12 +15,19 @@ * limitations under the License. */ import { Component, SimpleChange, ViewChild } from '@angular/core'; -import { ComponentFixture, TestBed, async } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { AppConfigService, setupTestBed, CoreModule, DataTableModule, DataRowEvent, ObjectDataRow } from '@alfresco/adf-core'; +import { + AppConfigService, + CoreModule, + DataRowEvent, + DataTableModule, + ObjectDataRow, + setupTestBed +} from '@alfresco/adf-core'; import { ProcessListCloudService } from '../services/process-list-cloud.service'; import { ProcessListCloudComponent } from './process-list-cloud.component'; -import { fakeProcessCloudList, fakeCustomSchema } from '../mock/process-list-service.mock'; +import { fakeCustomSchema, fakeProcessCloudList, processListSchemaMock } from '../mock/process-list-service.mock'; import { of } from 'rxjs'; import { ProcessListCloudTestingModule } from '../testing/process-list.testing.module'; import { ProcessListCloudModule } from '../process-list-cloud.module'; @@ -65,7 +72,8 @@ describe('ProcessListCloudComponent', () => { setupTestBed({ imports: [ - ProcessListCloudTestingModule, ProcessListCloudModule + ProcessListCloudTestingModule, + ProcessListCloudModule ], providers: [ProcessListCloudService] }); @@ -97,14 +105,57 @@ describe('ProcessListCloudComponent', () => { }); }); - afterEach(() => { - fixture.destroy(); + afterEach(() => fixture.destroy()); + + it('should use the default schemaColumn', () => { + appConfig.config = Object.assign(appConfig.config, { 'adf-cloud-process-list': processListSchemaMock }); + component.ngAfterContentInit(); + fixture.detectChanges(); + + expect(component.columns).toBeDefined(); + expect(component.columns.length).toEqual(10); }); - it('should use the default schemaColumn as default', () => { - component.ngAfterContentInit(); - expect(component.columns).toBeDefined(); - expect(component.columns.length).toEqual(2); + it('should display empty content when process list is empty', () => { + const emptyList = {list: {entries: []}}; + spyOn(processListCloudService, 'getProcessByRequest').and.returnValue(of(emptyList)); + + fixture.detectChanges(); + expect(component.isLoading).toBe(true); + let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + expect(loadingContent.nativeElement).toBeDefined(); + + const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); + component.ngOnChanges({ appName }); + fixture.detectChanges(); + + loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + expect(loadingContent).toBeFalsy(); + + const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content')); + expect(emptyContent.nativeElement).toBeDefined(); + }); + + it('should load spinner and show the content', () => { + spyOn(processListCloudService, 'getProcessByRequest').and.returnValue(of(fakeProcessCloudList)); + const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); + + fixture.detectChanges(); + expect(component.isLoading).toBe(true); + let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + expect(loadingContent.nativeElement).toBeDefined(); + + component.ngOnChanges({ appName }); + fixture.detectChanges(); + + expect(component.isLoading).toBe(false); + loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + expect(loadingContent).toBeFalsy(); + + const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content')); + expect(emptyContent).toBeFalsy(); + + expect(component.rows.length).toEqual(3); }); it('should use the custom schemaColumn from app.config.json', () => { diff --git a/lib/process-services-cloud/src/lib/process/process-list/mock/process-list-service.mock.ts b/lib/process-services-cloud/src/lib/process/process-list/mock/process-list-service.mock.ts index 7eae55e6fa..39c29a7c40 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/mock/process-list-service.mock.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/mock/process-list-service.mock.ts @@ -97,3 +97,71 @@ export let fakeCustomSchema = 'sortable': true }) ]; + +export const processListSchemaMock = { + 'presets': { + 'default': [ + { + 'key': 'entry.id', + 'type': 'text', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.ID', + 'sortable': true + }, + { + 'key': 'entry.name', + 'type': 'text', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME', + 'sortable': true + }, + { + 'key': 'entry.status', + 'type': 'text', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.STATUS', + 'sortable': true + }, + { + 'key': 'entry.startDate', + 'type': 'date', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE', + 'sortable': true, + 'format': 'timeAgo' + }, + { + 'key': 'entry.appName', + 'type': 'text', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.APP_NAME', + 'sortable': true + }, + { + 'key': 'entry.businessKey', + 'type': 'text', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.BUSINESS_KEY', + 'sortable': true + }, + { + 'key': 'entry.initiator', + 'type': 'text', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.INITIATOR', + 'sortable': true + }, + { + 'key': 'entry.lastModified', + 'type': 'date', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.LAST_MODIFIED', + 'sortable': true + }, + { + 'key': 'entry.processDefinitionId', + 'type': 'text', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_ID', + 'sortable': true + }, + { + 'key': 'entry.processDefinitionKey', + 'type': 'text', + 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_KEY', + 'sortable': true + } + ] + } +}; diff --git a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.spec.ts index f297a8db16..8832d885e1 100644 --- a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.spec.ts @@ -166,10 +166,11 @@ describe('StartTaskCloudComponent', () => { }); }); - it('should select logged in user as assignee by default', () => { + it('should show logged in user as assignee by default', () => { fixture.detectChanges(); - const assignee = fixture.nativeElement.querySelector('[data-automation-id="adf-people-cloud-search-input"]'); + const assignee = fixture.nativeElement.querySelector('[data-automation-id="adf-people-cloud-chip-currentUser"]'); expect(assignee).toBeDefined(); + expect(assignee.innerText).toContain('Test User'); }); it('should show start task button', () => { diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.spec.ts index a775c0abcd..c45c9344b8 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.spec.ts @@ -58,11 +58,11 @@ describe('EditTaskFilterCloudComponent', () => { service = TestBed.get(TaskFilterCloudService); appsService = TestBed.get(AppsProcessCloudService); dialog = TestBed.get(MatDialog); - spyOn(dialog, 'open').and.returnValue({ afterClosed() { return of({ + spyOn(dialog, 'open').and.returnValue({ afterClosed: of({ action: TaskFilterDialogCloudComponent.ACTION_SAVE, icon: 'icon', name: 'fake-name' - }); }}); + }) }); getTaskFilterSpy = spyOn(service, 'getTaskFilterById').and.returnValue(of(fakeFilter)); getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); fixture.detectChanges(); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts index e045940df3..2c035ebebe 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts @@ -67,6 +67,21 @@ describe('TaskFiltersCloudComponent', () => { taskFilterService = TestBed.get(TaskFilterCloudService); }); + it('should the first element active', async(() => { + spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable); + const change = new SimpleChange(undefined, 'my-app-1', true); + component.ngOnChanges({'appName': change}); + fixture.detectChanges(); + component.showIcons = true; + + fixture.whenStable().then(() => { + fixture.detectChanges(); + const activeElement = fixture.debugElement.nativeElement.querySelector('.adf-active span'); + expect(activeElement).toBeDefined(); + expect(activeElement.innerText).toEqual(fakeGlobalFilter[0].name); + }); + })); + it('should attach specific icon for each filter if hasIcon is true', async(() => { spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable); const change = new SimpleChange(undefined, 'my-app-1', true); diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts index 7b6c2496d6..32a25c129c 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts @@ -124,6 +124,48 @@ describe('TaskListCloudComponent', () => { expect(component.columns.length).toEqual(3); }); + it('should display empty content when process list is empty', () => { + const emptyList = {list: {entries: []}}; + spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(emptyList)); + + fixture.detectChanges(); + expect(component.isLoading).toBe(true); + let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + expect(loadingContent.nativeElement).toBeDefined(); + + const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); + component.ngOnChanges({ appName }); + fixture.detectChanges(); + + loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + expect(loadingContent).toBeFalsy(); + + const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content')); + expect(emptyContent.nativeElement).toBeDefined(); + }); + + it('should load spinner and show the content', () => { + spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(fakeGlobalTask)); + const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); + + fixture.detectChanges(); + expect(component.isLoading).toBe(true); + let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + expect(loadingContent.nativeElement).toBeDefined(); + + component.ngOnChanges({ appName }); + fixture.detectChanges(); + + expect(component.isLoading).toBe(false); + loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + expect(loadingContent).toBeFalsy(); + + const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content')); + expect(emptyContent).toBeFalsy(); + + expect(component.rows.length).toEqual(1); + }); + it('should use the custom schemaColumn from app.config.json', () => { component.presetColumn = 'fakeCustomSchema'; component.ngAfterContentInit();