Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACA-3312] Add user-filter util class #6098

Merged
merged 10 commits into from Sep 25, 2020
Merged

Conversation

iuliaib
Copy link
Contributor

@iuliaib iuliaib commented Sep 7, 2020

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation
  • Other... Please describe:
  • Add user-filter.util class that corresponds to user-filters : Retrieve and manage user filters section in APS1.X.
  • Add methods that check if a filter is not highlighted in order to avoid waiting seven seconds for isFilterHighlighted() to return false.

What is the current behaviour? (You can also link to an open issue here)

What is the new behaviour?

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2020

Codecov Report

Merging #6098 into develop will increase coverage by 1.50%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6098      +/-   ##
===========================================
+ Coverage    76.29%   77.80%   +1.50%     
===========================================
  Files          852      143     -709     
  Lines        19067     4005   -15062     
  Branches      3779      801    -2978     
===========================================
- Hits         14548     3116   -11432     
+ Misses        3378      630    -2748     
+ Partials      1141      259     -882     
Impacted Files Coverage Δ
lib/core/models/file.model.ts
lib/core/directives/logout.directive.ts
.../widgets/dynamic-table/editors/date/date.editor.ts
...ons/raphael-icon-google-drive-publish.component.ts
...-services/src/lib/task-list/models/filter.model.ts
lib/core/login/models/login-error.event.ts
...re/form/components/widgets/core/container.model.ts
...gram/components/diagram-sequence-flow.component.ts
lib/core/services/ecm-user.service.ts
...process-list/components/process-audit.directive.ts
... and 699 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b67b3b8...653b5b1. Read the comment docs.

return this.apiService.getInstance().activiti.userFiltersApi.createUserTaskFilter(new UserTaskFilterRepresentation(
{appId: appId, name: newTaskFilterName, icon: iconName, filter: {sort: sortType, state: stateType, assignment: assignmentType}}));
} catch (error) {
Logger.error('Create Task Filter - Service error, Response: ', JSON.parse(JSON.stringify(error)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these cases, don't we want rethrow the error, beside displaying them? Like this, even if an error occurs, we just show a message, but the program's execution will continue. Is it exactly what we want here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the catch block will never be executed in case of the errors in the async createUserTaskFilter. I suggest not using try/catch here at all, as it's a test and we will see the error + stack trace anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@popovicsandras, @DenysVuika thanks for the comments. Regarding the catch's logger.error... I was writing this in the same idea of what we already have (eg. lib/process-services/src/lib/process-list/services/process.service.ts) and I was keeping it like this because I was wondering that if not, we will stop the execution of the tests and the entire class will fail, right? I'm not sure if I'm actually right.
Currently, in a class we have multiple tests, most of them with different preconditions [this is available at least for all the tests from adw->Process Services extension]. If one precondition (required for just one test) will fail, currently the tests will keep running. From my point of view, we could keep using this approach until we will find a way to avoid making an entire class fail because of one precondition needed by a single test. 🤔

@DenysVuika I'm not sure if I've understood correctly the concern, but createUserTaskFilter is an API used directly from js-api package (node_modules/@alfresco/js-api/src/api/activiti-rest-api/api/userFilters.api.ts). If something happens there, shouldn't be caught in async createATaskFilter catch's Logger.error? 🤔

try {
return this.apiService.getInstance().activiti.userFiltersApi.orderUserTaskFilters(new UserFilterOrderRepresentation({appId: appId, order: filtersIdOrder}));
} catch (error) {
Logger.error('Re-order the list of user task filters - Service error, Response: ', JSON.parse(JSON.stringify(error)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

try {
return this.apiService.getInstance().activiti.userFiltersApi.getUserTaskFilters({appId: appId});
} catch (error) {
Logger.error('List task filters - Service error, Response: ', JSON.parse(JSON.stringify(error)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.parse(JSON.stringify(obj)) is a hack to deep clone an object I don't see any reason why we should have it here

});
return chosenTaskFilter;
} catch (error) {
Logger.error('Get user task filters by name - Service error, Response: ', JSON.parse(JSON.stringify(error)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

try {
return this.apiService.getInstance().activiti.userFiltersApi.deleteUserTaskFilter(filterId);
} catch (error) {
Logger.error('Delete a task filter - Service error, Response: ', JSON.parse(JSON.stringify(error)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

return this.apiService.getInstance().activiti.userFiltersApi.updateUserTaskFilter(filterId, new UserTaskFilterRepresentation(
{appId: appId, name: updatedTaskFilterName, icon: updatedIconName, filter: {sort: updatedSortType, state: updatedStateType, assignment: updatedAssignmentType}}));
} catch (error) {
Logger.error('Delete a task filter - Service error, Response: ', JSON.parse(JSON.stringify(error))); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor

@mauriziovitale mauriziovitale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the comments

@mauriziovitale mauriziovitale merged commit df2e531 into develop Sep 25, 2020
@mauriziovitale mauriziovitale deleted the dev-iuliaib-ACA-3312 branch September 25, 2020 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants