Skip to content

Commit

Permalink
[ACA-4474]Add isStartProcessButtonEnabled method
Browse files Browse the repository at this point in the history
* [ACA-4474] Add isStartProcessButtonEnabled method

* Refactor tests

* Fix lint error

* Refactor isStartProcessButtonEnabled method

* Fix startProcessWithProcessDefinition method

* Fix tests

* no message

* Fix isStartProcessButtonDisabled method

* Exclude failing e2e
  • Loading branch information
cristinaj committed Jun 8, 2021
1 parent e8824a6 commit 6400fd6
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('Task cloud visibility', async () => {
await startProcessPage.selectFromProcessDropdown(browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.processes.numbervisibilityprocess);

await startProcessPage.enterProcessName(processName);
await startProcessPage.checkStartProcessButtonIsEnabled();
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);
await startProcessPage.clickStartProcessButton();

await editProcessFilter.setFilter({ processName });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('Start Process', () => {
await browser.actions().sendKeys(protractor.Key.ENTER).perform();

await startProcessPage.checkValidationErrorIsDisplayed(requiredError);
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(false);
await expect(await startProcessPage.isStartProcessButtonDisabled()).toEqual(true);

await BrowserActions.closeMenuAndDialogs();
await startProcessPage.clickCancelProcessButton();
Expand All @@ -90,11 +90,11 @@ describe('Start Process', () => {
await startProcessPage.selectFirstOptionFromProcessDropdown();

await startProcessPage.enterProcessName(processName255Characters);
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(true);
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);

await startProcessPage.enterProcessName(processNameBiggerThen255Characters);
await startProcessPage.checkValidationErrorIsDisplayed(lengthValidationError);
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(false);
await expect(await startProcessPage.isStartProcessButtonDisabled()).toEqual(true);
});

it('[C291860] Should be able to start a process', async () => {
Expand All @@ -105,8 +105,7 @@ describe('Start Process', () => {

await startProcessPage.clearField(startProcessPage.processNameInput);
await startProcessPage.enterProcessName(processName);
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(true);
await browser.sleep(400);
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);
await startProcessPage.clickStartProcessButton();
await processFilter.clickOnProcessFilters();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,23 +241,23 @@ describe('Start Task Form', () => {

it('[C311277] Should be able to start a process with a start event form - form validation', async () => {
await expect(await widget.textWidget().getErrorMessage('FirstName')).toContain('Enter no more than 10 characters');
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(false);
await expect(await startProcessPage.isStartProcessButtonDisabled()).toEqual(true);

await widget.textWidget().setValue('FirstName', 'Sam');
await expect(await widget.textWidget().getErrorMessage('FirstName')).toContain('Enter at least 5 characters');
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(false);
await expect(await startProcessPage.isStartProcessButtonDisabled()).toEqual(true);
await widget.numberWidget().setFieldValue('Number07vyx9', 9);
await expect(await widget.numberWidget().getErrorMessage('Number07vyx9')).toContain('Can\'t be less than 10');
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(false);
await expect(await startProcessPage.isStartProcessButtonDisabled()).toEqual(true);
await widget.numberWidget().setFieldValue('Number07vyx9', 99999);
await expect(await widget.numberWidget().getErrorMessage('Number07vyx9')).toContain('Can\'t be greater than 1,000');
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(false);
await expect(await startProcessPage.isStartProcessButtonDisabled()).toEqual(true);
});

it('[C311277] Should be able to start a process with a start event form - claim and complete the process', async () => {
await widget.textWidget().setValue('FirstName', 'Sample');
await widget.numberWidget().setFieldValue('Number07vyx9', 100);
await expect(await startProcessPage.checkStartProcessButtonIsEnabled()).toBe(true);
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);
await startProcessPage.clickStartProcessButton();
await processFilter.clickRunningProcessesFilter();
await expect(await processFilter.getActiveFilterName()).toBe(CONSTANTS.PROCESS_FILTERS.RUNNING);
Expand Down
13 changes: 6 additions & 7 deletions e2e/process-services/process/start-process-component.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ describe('Start Process Component', () => {
await startProcessPage.selectFromProcessDropdown(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);

await expect(await startProcessPage.getDefaultName()).toEqual('My Default Name');

await startProcessPage.checkStartProcessButtonIsEnabled();
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);
});

it('[C260449] Should be possible to start a process with start event', async () => {
Expand Down Expand Up @@ -237,7 +236,7 @@ describe('Start Process Component', () => {
await startProcessPage.checkProcessOptionIsDisplayed(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);
await startProcessPage.checkProcessOptionIsDisplayed(browser.params.resources.Files.APP_WITH_PROCESSES.process_se_name);
await startProcessPage.selectProcessOption(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);
await startProcessPage.checkStartProcessButtonIsEnabled();
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);
});

it('[C286508] Should display only one option when typing an existent process definition', async () => {
Expand All @@ -249,7 +248,7 @@ describe('Start Process Component', () => {
await startProcessPage.checkProcessOptionIsDisplayed(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);
await startProcessPage.checkProcessOptionIsNotDisplayed(browser.params.resources.Files.APP_WITH_PROCESSES.process_se_name);
await startProcessPage.selectProcessOption(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);
await startProcessPage.checkStartProcessButtonIsEnabled();
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);
});

it('[C286509] Should select automatically the processDefinition when the app contains only one', async () => {
Expand All @@ -258,7 +257,7 @@ describe('Start Process Component', () => {
await processFiltersPage.clickCreateProcessButton();
await processFiltersPage.clickNewProcessDropdown();
await expect(await startProcessPage.getProcessDefinitionValue()).toBe(simpleApp.title);
await startProcessPage.checkStartProcessButtonIsEnabled();
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);
});

it('[C286511] Should be able to type the process definition and start a process', async () => {
Expand All @@ -269,7 +268,7 @@ describe('Start Process Component', () => {
await startProcessPage.typeProcessDefinition(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);
await startProcessPage.selectProcessOption(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);
await startProcessPage.enterProcessName('Type');
await startProcessPage.checkStartProcessButtonIsEnabled();
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);
await expect(await startProcessPage.getProcessDefinitionValue()).toBe(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);
await startProcessPage.clickStartProcessButton();
await processFiltersPage.clickRunningFilterButton();
Expand Down Expand Up @@ -441,7 +440,7 @@ describe('Start Process Component', () => {

await startProcessPage.enterProcessName(processName255Characters);
await startProcessPage.selectFromProcessDropdown(browser.params.resources.Files.APP_WITH_PROCESSES.process_wse_name);
await startProcessPage.checkStartProcessButtonIsEnabled();
await expect(await startProcessPage.isStartProcessButtonEnabled()).toEqual(true);

await startProcessPage.enterProcessName(processNameBiggerThen255Characters);
await startProcessPage.checkValidationErrorIsDisplayed(lengthValidationError);
Expand Down
3 changes: 2 additions & 1 deletion e2e/protractor.excludes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"C272819": "https://alfresco.atlassian.net/browse/ADF-5385",
"C290069": "https://alfresco.atlassian.net/browse/ADF-5387",
"C291811": "https://alfresco.atlassian.net/browse/ADF-5405",
"C291809": "https://alfresco.atlassian.net/browse/ADF-5405"
"C291809": "https://alfresco.atlassian.net/browse/ADF-5405",
"C307988": "https://alfresco.atlassian.net/browse/ADF-5421"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class StartProcessCloudPage {
cancelProcessButton = element(by.id('cancel_process'));
formStartProcessButton = element(by.css('button[data-automation-id="adf-form-start process"]'));
startProcessButton = element(by.css('button[data-automation-id="btn-start"]'));
startProcessButtonDisabled = element(by.css('button[data-automation-id="btn-start"][disabled]'));
noProcess = element(by.id('no-process-message'));
processDefinition = element(by.css('input[id="processDefinitionName"]'));
processDefinitionOptionsPanel = element(by.css('div[class*="processDefinitionOptions"]'));
Expand Down Expand Up @@ -83,12 +84,21 @@ export class StartProcessCloudPage {
await BrowserActions.click(this.cancelProcessButton);
}

async checkStartProcessButtonIsEnabled(): Promise<boolean> {
await browser.sleep(2000); // waiting for API response
async isStartProcessButtonEnabled(): Promise<boolean> {
await BrowserVisibility.waitUntilElementIsNotVisible(this.startProcessButtonDisabled);
await BrowserVisibility.waitUntilElementIsVisible(this.startProcessButton);
return this.startProcessButton.isEnabled();
}

async isStartProcessButtonDisabled(): Promise<boolean> {
try {
await BrowserVisibility.waitUntilElementIsVisible(this.startProcessButtonDisabled);
return true;
} catch (error) {
return false;
}
}

async clickStartProcessButton(): Promise<void> {
await BrowserActions.click(this.startProcessButton);
}
Expand All @@ -111,7 +121,8 @@ export class StartProcessCloudPage {
async startProcessWithProcessDefinition(processName: string, processDefinition: string) {
await this.selectFromProcessDropdown(processDefinition);
await this.enterProcessName(processName);
await this.checkStartProcessButtonIsEnabled();
await BrowserVisibility.waitUntilElementIsNotVisible(this.startProcessButtonDisabled);
await BrowserVisibility.waitUntilElementIsVisible(this.startProcessButton);
await this.clickStartProcessButton();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class StartProcessPage {
cancelProcessButton = element(by.id('cancel_process'));
formStartProcessButton = element(by.css('button[data-automation-id="adf-form-start process"]'));
startProcessButton = element(by.css('button[data-automation-id="btn-start"]'));
startProcessButtonDisabled = element(by.css('button[data-automation-id="btn-start"][disabled]'));
noProcess = element(by.css('.adf-empty-content__title'));
processDefinition = element(by.css('input[id="processDefinitionName"]'));
processDefinitionOptionsPanel = element(by.css('div[class*="mat-autocomplete-panel"]'));
Expand Down Expand Up @@ -124,8 +125,9 @@ export class StartProcessPage {
return this.formStartProcessButton.isEnabled();
}

async checkStartProcessButtonIsEnabled() {
await expect(await this.startProcessButton.isEnabled()).toBe(true);
async isStartProcessButtonEnabled() {
await BrowserVisibility.waitUntilElementIsNotVisible(this.startProcessButtonDisabled);
return this.startProcessButton.isEnabled();
}

async checkStartProcessButtonIsDisabled() {
Expand Down

0 comments on commit 6400fd6

Please sign in to comment.