mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-2107] Move e2e to Unit test (#5535)
* [AAE-2107] Move e2e to Unit test * * fixed namings * * more unit test added * * minor changes
This commit is contained in:
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
@@ -69,33 +69,4 @@ describe('Datatable component - selection', () => {
|
|||||||
await dataTablePage.checkNoRowIsSelected();
|
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();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@@ -227,18 +227,6 @@ describe('Process list cloud', () => {
|
|||||||
await expect(await processCloudDemoPage.processListCloudComponent().getDataTable().checkListIsSorted('DESC', 'Business Key')).toBe(true);
|
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 () => {
|
it('[C297697] The value of the filter should be preserved when saving it', async () => {
|
||||||
await processCloudDemoPage.editProcessFilterCloudComponent().openFilter();
|
await processCloudDemoPage.editProcessFilterCloudComponent().openFilter();
|
||||||
await processCloudDemoPage.editProcessFilterCloudComponent().setProcessInstanceId(completedProcess.entry.id);
|
await processCloudDemoPage.editProcessFilterCloudComponent().setProcessInstanceId(completedProcess.entry.id);
|
||||||
@@ -297,32 +285,5 @@ describe('Process list cloud', () => {
|
|||||||
await BrowserActions.closeMenuAndDialogs();
|
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();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -184,14 +184,6 @@ describe('Process filters cloud', () => {
|
|||||||
await processCloudDemoPage.processListCloudComponent().checkContentIsNotDisplayedByName(differentAppUserProcessInstance.entry.name);
|
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 () => {
|
it('[C311315] Should be able to filter by process definition id', async () => {
|
||||||
await processCloudDemoPage.editProcessFilterCloudComponent().openFilter();
|
await processCloudDemoPage.editProcessFilterCloudComponent().openFilter();
|
||||||
await processCloudDemoPage.editProcessFilterCloudComponent().setProperty('processDefinitionId', processDefinition.entry.id);
|
await processCloudDemoPage.editProcessFilterCloudComponent().setProperty('processDefinitionId', processDefinition.entry.id);
|
||||||
|
@@ -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 { 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 { TasksCloudDemoPage } from '../pages/adf/demo-shell/process-services/tasks-cloud-demo.page';
|
||||||
import { NavigationBarPage } from '../pages/adf/navigation-bar.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 { EditProcessFilterConfiguration } from './config/edit-process-filter.config';
|
||||||
import { ProcessListCloudConfiguration } from './config/process-list-cloud.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', () => {
|
describe('Process filters cloud', () => {
|
||||||
const loginSSOPage = new LoginSSOPage();
|
const loginSSOPage = new LoginSSOPage();
|
||||||
@@ -45,7 +48,6 @@ describe('Process filters cloud', () => {
|
|||||||
const processDetailsCloudDemoPage = new ProcessDetailsCloudDemoPage();
|
const processDetailsCloudDemoPage = new ProcessDetailsCloudDemoPage();
|
||||||
const taskHeaderCloudPage = new TaskHeaderCloudPage();
|
const taskHeaderCloudPage = new TaskHeaderCloudPage();
|
||||||
const taskFormCloudComponent = new TaskFormCloudComponent();
|
const taskFormCloudComponent = new TaskFormCloudComponent();
|
||||||
const processListPage = new ProcessListPage();
|
|
||||||
const apiService = new ApiService(
|
const apiService = new ApiService(
|
||||||
browser.params.config.oauth2.clientId,
|
browser.params.config.oauth2.clientId,
|
||||||
browser.params.config.bpmHost, browser.params.config.oauth2.host, browser.params.config.providers
|
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();
|
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 () => {
|
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().openFilter();
|
||||||
await processCloudDemoPage.editProcessFilterCloudComponent().setAppNameDropDown(simpleApp);
|
await processCloudDemoPage.editProcessFilterCloudComponent().setAppNameDropDown(simpleApp);
|
||||||
|
@@ -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');
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -199,13 +199,6 @@ describe('Start Task', () => {
|
|||||||
await expect(await tasksCloudDemoPage.taskFilterCloudComponent.getActiveFilterName()).toBe('My Tasks');
|
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 () => {
|
it('[C305050] Should be able to reassign the removed user when starting a new task', async () => {
|
||||||
await tasksCloudDemoPage.openNewTaskForm();
|
await tasksCloudDemoPage.openNewTaskForm();
|
||||||
await startTask.checkFormIsDisplayed();
|
await startTask.checkFormIsDisplayed();
|
||||||
|
@@ -63,11 +63,6 @@ describe('Task filters cloud', () => {
|
|||||||
await appListCloudComponent.goToApp(simpleApp);
|
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 () => {
|
it('[C290009] Should display default filters and created task', async () => {
|
||||||
tasksService = new TasksService(apiService);
|
tasksService = new TasksService(apiService);
|
||||||
|
|
||||||
@@ -101,9 +96,5 @@ describe('Task filters cloud', () => {
|
|||||||
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(completedTask);
|
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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -23,17 +23,26 @@ import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
|
|||||||
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||||
import { CardViewDateItemComponent } from './card-view-dateitem.component';
|
import { CardViewDateItemComponent } from './card-view-dateitem.component';
|
||||||
import { CoreTestingModule } from '../../../testing/core.testing.module';
|
import { CoreTestingModule } from '../../../testing/core.testing.module';
|
||||||
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
|
|
||||||
describe('CardViewDateItemComponent', () => {
|
describe('CardViewDateItemComponent', () => {
|
||||||
|
|
||||||
let fixture: ComponentFixture<CardViewDateItemComponent>;
|
let fixture: ComponentFixture<CardViewDateItemComponent>;
|
||||||
let component: CardViewDateItemComponent;
|
let component: CardViewDateItemComponent;
|
||||||
|
let appConfigService: AppConfigService;
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [CoreTestingModule]
|
imports: [CoreTestingModule]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
appConfigService = TestBed.get(AppConfigService);
|
||||||
|
appConfigService.config.dateValues = {
|
||||||
|
defaultDateFormat: 'shortDate',
|
||||||
|
defaultDateTimeFormat: 'M/d/yy, h:mm a',
|
||||||
|
defaultLocale: 'uk'
|
||||||
|
};
|
||||||
|
|
||||||
fixture = TestBed.createComponent(CardViewDateItemComponent);
|
fixture = TestBed.createComponent(CardViewDateItemComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.property = new CardViewDateItemModel({
|
component.property = new CardViewDateItemModel({
|
||||||
@@ -46,8 +55,10 @@ describe('CardViewDateItemComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => fixture.destroy());
|
||||||
fixture.destroy();
|
|
||||||
|
it('should pick date format from appConfigService', () => {
|
||||||
|
expect(component.dateFormat).toEqual('shortDate');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the label and value', () => {
|
it('should render the label and value', () => {
|
||||||
@@ -153,6 +164,7 @@ describe('CardViewDateItemComponent', () => {
|
|||||||
component.property.editable = true;
|
component.property.editable = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.isEditable()).toBe(false);
|
||||||
const datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-${component.property.key}"]`));
|
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}"]`));
|
const datePickerToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepickertoggle-${component.property.key}"]`));
|
||||||
expect(datePicker).toBeNull('Datepicker should NOT be in DOM');
|
expect(datePicker).toBeNull('Datepicker should NOT be in DOM');
|
||||||
@@ -206,6 +218,7 @@ describe('CardViewDateItemComponent', () => {
|
|||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
describe('clear icon', () => {
|
||||||
it('should render the clear icon in case of displayClearAction:true', () => {
|
it('should render the clear icon in case of displayClearAction:true', () => {
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
component.property.editable = true;
|
component.property.editable = true;
|
||||||
@@ -273,34 +286,43 @@ describe('CardViewDateItemComponent', () => {
|
|||||||
component.property.default = 'Jul 10 2017';
|
component.property.default = 'Jul 10 2017';
|
||||||
component.property.value = 'Jul 10 2017';
|
component.property.value = 'Jul 10 2017';
|
||||||
fixture.detectChanges();
|
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();
|
component.onDateClear();
|
||||||
|
|
||||||
fixture.whenStable().then(
|
fixture.whenStable().then(() => {
|
||||||
() => {
|
|
||||||
expect(component.property.value).toBeNull();
|
expect(component.property.value).toBeNull();
|
||||||
expect(component.property.default).toBeNull();
|
expect(component.property.default).toBeNull();
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}));
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
it('should be possible update a date/date-time', async(() => {
|
it('should be possible update a date-time', async () => {
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
component.property.editable = true;
|
component.property.editable = true;
|
||||||
component.property.default = 'Jul 10 2017';
|
component.property.default = 'Jul 10 2017 00:01:00';
|
||||||
component.property.key = 'fake-key';
|
component.property.key = 'fake-key';
|
||||||
component.property.value = 'Jul 10 2017';
|
component.dateFormat = 'M/d/yy, h:mm a';
|
||||||
const expectedDate = moment('Jul 10 2018', 'MMM DD YY');
|
component.property.value = 'Jul 10 2017 00:01:00';
|
||||||
|
const expectedDate = moment('Jul 10 2018', 'MMM DD YY h:m:s');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
await fixture.whenStable();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const element = fixture.debugElement.nativeElement.querySelector('span[data-automation-id="card-date-value-fake-key"]');
|
const element = fixture.debugElement.nativeElement.querySelector('span[data-automation-id="card-date-value-fake-key"]');
|
||||||
expect(element).toBeDefined();
|
expect(element).toBeDefined();
|
||||||
expect(element.innerText).toEqual('Jul 10, 2017');
|
expect(element.innerText).toEqual('Jul 10, 2017');
|
||||||
component.onDateChanged({ value: expectedDate });
|
component.onDateChanged({ value: expectedDate });
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => expect(component.property.value).toEqual(expectedDate.toDate()));
|
expect(component.property.value).toEqual(expectedDate.toDate());
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
@@ -66,12 +66,14 @@ describe('CardViewKeyValuePairsItemComponent', () => {
|
|||||||
component.property = new CardViewKeyValuePairsItemModel({
|
component.property = new CardViewKeyValuePairsItemModel({
|
||||||
label: 'Key Value Pairs',
|
label: 'Key Value Pairs',
|
||||||
value: mockData,
|
value: mockData,
|
||||||
key: 'key-value-pairs'
|
key: 'key-value-pairs',
|
||||||
|
editable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
component.ngOnChanges();
|
component.ngOnChanges();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.isEditable()).toBe(false);
|
||||||
const table = fixture.debugElement.query(By.css('.adf-card-view__key-value-pairs__read-only'));
|
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'));
|
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"]`));
|
const valueInput = fixture.debugElement.query(By.css(`[data-automation-id="card-${component.property.key}-value-input-0"]`));
|
||||||
expect(nameInput).not.toBeNull();
|
expect(nameInput).not.toBeNull();
|
||||||
expect(valueInput).not.toBeNull();
|
expect(valueInput).not.toBeNull();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove an item from list on REMOVE button click', () => {
|
it('should remove an item from list on REMOVE button click', () => {
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { OverlayContainer } from '@angular/cdk/overlay';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { CardViewSelectItemModel } from '../../models/card-view-selectitem.model';
|
import { CardViewSelectItemModel } from '../../models/card-view-selectitem.model';
|
||||||
import { CardViewSelectItemComponent } from './card-view-selectitem.component';
|
import { CardViewSelectItemComponent } from './card-view-selectitem.component';
|
||||||
@@ -27,6 +28,7 @@ describe('CardViewSelectItemComponent', () => {
|
|||||||
|
|
||||||
let fixture: ComponentFixture<CardViewSelectItemComponent>;
|
let fixture: ComponentFixture<CardViewSelectItemComponent>;
|
||||||
let component: CardViewSelectItemComponent;
|
let component: CardViewSelectItemComponent;
|
||||||
|
let overlayContainer: OverlayContainer;
|
||||||
const mockData = [{ key: 'one', label: 'One' }, { key: 'two', label: 'Two' }, { key: 'three', label: 'Three' }];
|
const mockData = [{ key: 'one', label: 'One' }, { key: 'two', label: 'Two' }, { key: 'three', label: 'Three' }];
|
||||||
const mockDefaultProps = {
|
const mockDefaultProps = {
|
||||||
label: 'Select box label',
|
label: 'Select box label',
|
||||||
@@ -43,6 +45,7 @@ describe('CardViewSelectItemComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(CardViewSelectItemComponent);
|
fixture = TestBed.createComponent(CardViewSelectItemComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
overlayContainer = TestBed.get(OverlayContainer);
|
||||||
component.property = new CardViewSelectItemModel(mockDefaultProps);
|
component.property = new CardViewSelectItemModel(mockDefaultProps);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -75,6 +78,50 @@ describe('CardViewSelectItemComponent', () => {
|
|||||||
expect(selectBox).toBeNull();
|
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', () => {
|
it('should render select box if editable property is TRUE', () => {
|
||||||
component.ngOnChanges();
|
component.ngOnChanges();
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
|
@@ -22,11 +22,13 @@ import { CardViewUpdateService } from '../../services/card-view-update.service';
|
|||||||
import { CardViewTextItemComponent } from './card-view-textitem.component';
|
import { CardViewTextItemComponent } from './card-view-textitem.component';
|
||||||
import { setupTestBed } from '../../../testing/setup-test-bed';
|
import { setupTestBed } from '../../../testing/setup-test-bed';
|
||||||
import { CoreTestingModule } from '../../../testing/core.testing.module';
|
import { CoreTestingModule } from '../../../testing/core.testing.module';
|
||||||
|
import { CardViewItemFloatValidator, CardViewItemIntValidator } from '@alfresco/adf-core';
|
||||||
|
|
||||||
describe('CardViewTextItemComponent', () => {
|
describe('CardViewTextItemComponent', () => {
|
||||||
|
|
||||||
let fixture: ComponentFixture<CardViewTextItemComponent>;
|
let fixture: ComponentFixture<CardViewTextItemComponent>;
|
||||||
let component: CardViewTextItemComponent;
|
let component: CardViewTextItemComponent;
|
||||||
|
const mouseEvent = new MouseEvent('click');
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [CoreTestingModule]
|
imports: [CoreTestingModule]
|
||||||
@@ -109,128 +111,6 @@ describe('CardViewTextItemComponent', () => {
|
|||||||
expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY');
|
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', () => {
|
it('should render value when editable:true', () => {
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
component.property.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', () => {
|
describe('Update', () => {
|
||||||
const event = new MouseEvent('click');
|
const event = new MouseEvent('click');
|
||||||
|
|
||||||
@@ -416,7 +432,7 @@ describe('CardViewTextItemComponent', () => {
|
|||||||
editInput.nativeElement.dispatchEvent(enterKeyboardEvent);
|
editInput.nativeElement.dispatchEvent(enterKeyboardEvent);
|
||||||
fixture.detectChanges();
|
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(textItemReadOnly.nativeElement.textContent).toEqual(expectedText);
|
||||||
expect(component.property.value).toBe(expectedText);
|
expect(component.property.value).toBe(expectedText);
|
||||||
}));
|
}));
|
||||||
@@ -439,9 +455,294 @@ describe('CardViewTextItemComponent', () => {
|
|||||||
editInput.nativeElement.dispatchEvent(enterKeyboardEvent);
|
editInput.nativeElement.dispatchEvent(enterKeyboardEvent);
|
||||||
fixture.detectChanges();
|
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(textItemReadOnly.nativeElement.textContent).toEqual('Lorem ipsum');
|
||||||
expect(component.property.value).toBe('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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@@ -890,6 +890,25 @@ describe('DataTable', () => {
|
|||||||
expect(dataTable.isSelectAllChecked).toBe(true);
|
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], <MatCheckboxChange> { checked: true });
|
||||||
|
expect(rows[0].isSelected).toBe(false);
|
||||||
|
expect(rows[1].isSelected).toBe(true);
|
||||||
|
|
||||||
|
dataTable.onCheckboxChange(rows[0], <MatCheckboxChange> { checked: true });
|
||||||
|
expect(rows[0].isSelected).toBe(true);
|
||||||
|
expect(rows[1].isSelected).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('should require multiselect option to toggle row state', () => {
|
it('should require multiselect option to toggle row state', () => {
|
||||||
const data = new ObjectDataTableAdapter([{}, {}, {}], []);
|
const data = new ObjectDataTableAdapter([{}, {}, {}], []);
|
||||||
const rows = data.getRows();
|
const rows = data.getRows();
|
||||||
|
@@ -15,12 +15,19 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { Component, SimpleChange, ViewChild } from '@angular/core';
|
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 { 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 { ProcessListCloudService } from '../services/process-list-cloud.service';
|
||||||
import { ProcessListCloudComponent } from './process-list-cloud.component';
|
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 { of } from 'rxjs';
|
||||||
import { ProcessListCloudTestingModule } from '../testing/process-list.testing.module';
|
import { ProcessListCloudTestingModule } from '../testing/process-list.testing.module';
|
||||||
import { ProcessListCloudModule } from '../process-list-cloud.module';
|
import { ProcessListCloudModule } from '../process-list-cloud.module';
|
||||||
@@ -65,7 +72,8 @@ describe('ProcessListCloudComponent', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
ProcessListCloudTestingModule, ProcessListCloudModule
|
ProcessListCloudTestingModule,
|
||||||
|
ProcessListCloudModule
|
||||||
],
|
],
|
||||||
providers: [ProcessListCloudService]
|
providers: [ProcessListCloudService]
|
||||||
});
|
});
|
||||||
@@ -97,14 +105,57 @@ describe('ProcessListCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => fixture.destroy());
|
||||||
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', () => {
|
it('should display empty content when process list is empty', () => {
|
||||||
component.ngAfterContentInit();
|
const emptyList = {list: {entries: []}};
|
||||||
expect(component.columns).toBeDefined();
|
spyOn(processListCloudService, 'getProcessByRequest').and.returnValue(of(emptyList));
|
||||||
expect(component.columns.length).toEqual(2);
|
|
||||||
|
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', () => {
|
it('should use the custom schemaColumn from app.config.json', () => {
|
||||||
|
@@ -97,3 +97,71 @@ export let fakeCustomSchema =
|
|||||||
'sortable': true
|
'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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@@ -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();
|
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).toBeDefined();
|
||||||
|
expect(assignee.innerText).toContain('Test User');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show start task button', () => {
|
it('should show start task button', () => {
|
||||||
|
@@ -58,11 +58,11 @@ describe('EditTaskFilterCloudComponent', () => {
|
|||||||
service = TestBed.get(TaskFilterCloudService);
|
service = TestBed.get(TaskFilterCloudService);
|
||||||
appsService = TestBed.get(AppsProcessCloudService);
|
appsService = TestBed.get(AppsProcessCloudService);
|
||||||
dialog = TestBed.get(MatDialog);
|
dialog = TestBed.get(MatDialog);
|
||||||
spyOn(dialog, 'open').and.returnValue({ afterClosed() { return of({
|
spyOn(dialog, 'open').and.returnValue({ afterClosed: of({
|
||||||
action: TaskFilterDialogCloudComponent.ACTION_SAVE,
|
action: TaskFilterDialogCloudComponent.ACTION_SAVE,
|
||||||
icon: 'icon',
|
icon: 'icon',
|
||||||
name: 'fake-name'
|
name: 'fake-name'
|
||||||
}); }});
|
}) });
|
||||||
getTaskFilterSpy = spyOn(service, 'getTaskFilterById').and.returnValue(of(fakeFilter));
|
getTaskFilterSpy = spyOn(service, 'getTaskFilterById').and.returnValue(of(fakeFilter));
|
||||||
getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance));
|
getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@@ -67,6 +67,21 @@ describe('TaskFiltersCloudComponent', () => {
|
|||||||
taskFilterService = TestBed.get(TaskFilterCloudService);
|
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(() => {
|
it('should attach specific icon for each filter if hasIcon is true', async(() => {
|
||||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
|
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
|
||||||
const change = new SimpleChange(undefined, 'my-app-1', true);
|
const change = new SimpleChange(undefined, 'my-app-1', true);
|
||||||
|
@@ -124,6 +124,48 @@ describe('TaskListCloudComponent', () => {
|
|||||||
expect(component.columns.length).toEqual(3);
|
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', () => {
|
it('should use the custom schemaColumn from app.config.json', () => {
|
||||||
component.presetColumn = 'fakeCustomSchema';
|
component.presetColumn = 'fakeCustomSchema';
|
||||||
component.ngAfterContentInit();
|
component.ngAfterContentInit();
|
||||||
|
Reference in New Issue
Block a user