Skip to content

Commit

Permalink
Fix e2e testcases (#1917)
Browse files Browse the repository at this point in the history
* adding optional chaining

* udpate templates render functionality

* refactore code
  • Loading branch information
devketanpro authored Feb 16, 2024
1 parent 01dbc5e commit d75cbda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/api/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function update(original: IEventItem, updates: Partial<IEventItem>): Promise<Arr
return superdeskApi.dataApi.patch<IEventItem>('events', original, {
...updates,
associated_plannings: undefined,
embedded_planning: updates.associated_plannings.map((planning) => ({
embedded_planning: updates?.associated_plannings?.map((planning) => ({
planning_id: planning._id.startsWith(TEMP_ID_PREFIX) ? undefined : planning._id,
update_method: planning.update_method,
coverages: planning.coverages.map((coverage) => ({
Expand Down
7 changes: 5 additions & 2 deletions client/components/Main/CreateNewSubnavDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class CreateNewSubnavDropdownFn extends React.PureComponent<IProps> {
const sortedTemplates = eventTemplates
.sort((templ1, templ2) => templ1.template_name.localeCompare(templ2.template_name));

recentTemplates
const templates = recentTemplates.length === 0 ? sortedTemplates : recentTemplates;

templates
.forEach((template) => {
items.push({
label: template.template_name,
Expand All @@ -74,7 +76,8 @@ class CreateNewSubnavDropdownFn extends React.PureComponent<IProps> {
});
});

if (sortedTemplates.length > MORE_TEMPLATES_THRESHOLD) {
if (recentTemplates.length < MORE_TEMPLATES_THRESHOLD ||
sortedTemplates.length > MORE_TEMPLATES_THRESHOLD) {
items.push({
label: gettext('More templates...'),
icon: 'icon-event icon--blue',
Expand Down

0 comments on commit d75cbda

Please sign in to comment.