From 479c96eabb9db88d320ad810c2f9319d1a94be0c Mon Sep 17 00:00:00 2001 From: Jatin Chugh <105338943+jatin2008@users.noreply.github.com> Date: Wed, 14 Jun 2023 15:30:08 +0530 Subject: [PATCH] [PRODSEC-6575] Shared link not accessible now after the expiry date which was earlier accessible even after that expiration date (#8540) * Shared link expiry date code implementation * test case updated * removed unsed code * design changes as per the new design of Share dialog * test cases modification as per new design changes * placeholder modified for expiration date * look and feel changes for share dialog as per Shane comments * boolean name changed as per naming convention * review comments addressed * review comments addressed * type specified for node object * linting corrections * resolved nested ternary date operation into an independent statement * review comments addressed * used date-fns instead of moment.js in code as well as in test cases * review comments for date-fns addressed * removed extra line * removed extra empty lines in template * import changes and indentation correction * error in console resolved which was occuring after selecting date and time * used mat-datepicker instead of mat-datetimepicker * package-lock.json file updated for date-fns implementation * made type 'date' as default and removed the settings coming from the ACA * unit test case modifications as per calender changes * e2e modifications as per new calendar component --- .../components/share-file.e2e.ts | 17 -- e2e/core/pages/dialog/share-dialog.page.ts | 7 +- .../content-node-share.dialog.html | 194 ++++++++++-------- .../content-node-share.dialog.scss | 85 +++++++- .../content-node-share.dialog.spec.ts | 104 ++++------ .../content-node-share.dialog.ts | 119 ++++++----- .../services/shared-links-api.service.ts | 7 +- lib/content-services/src/lib/i18n/en.json | 6 + .../date-time-picker-calendar.page.ts | 8 +- .../pages/material/date-time-picker.page.ts | 6 +- package-lock.json | 32 +++ package.json | 1 + 12 files changed, 361 insertions(+), 225 deletions(-) diff --git a/e2e/content-services/components/share-file.e2e.ts b/e2e/content-services/components/share-file.e2e.ts index 0886e47144..2b92e972f3 100644 --- a/e2e/content-services/components/share-file.e2e.ts +++ b/e2e/content-services/components/share-file.e2e.ts @@ -132,23 +132,6 @@ describe('Share file', () => { await BrowserActions.closeMenuAndDialogs(); }); - it('[C286548] Should be possible to set expiry date for link', async () => { - await contentServicesPage.clickShareButton(); - await shareDialog.checkDialogIsDisplayed(); - await shareDialog.clickExpireToggle(); - await shareDialog.setDefaultDay(); - await shareDialog.setDefaultHour(); - await shareDialog.setDefaultMinutes(); - await shareDialog.dateTimePickerDialogIsClosed(); - const value = await shareDialog.getExpirationDate(); - await shareDialog.clickCloseButton(); - await shareDialog.dialogIsClosed(); - await contentServicesPage.clickShareButton(); - await shareDialog.checkDialogIsDisplayed(); - await shareDialog.expirationDateInputHasValue(value); - await BrowserActions.closeMenuAndDialogs(); - }); - it('[C310329] Should be possible to set expiry date only for link', async () => { await LocalStorageUtil.setConfigField('sharedLinkDateTimePickerType', JSON.stringify('date')); await contentServicesPage.clickShareButton(); diff --git a/e2e/core/pages/dialog/share-dialog.page.ts b/e2e/core/pages/dialog/share-dialog.page.ts index d7e38d5b54..0a05af555d 100644 --- a/e2e/core/pages/dialog/share-dialog.page.ts +++ b/e2e/core/pages/dialog/share-dialog.page.ts @@ -17,8 +17,7 @@ import { $$, $ } from 'protractor'; import { BrowserVisibility, TogglePage, BrowserActions, DateTimePickerPage } from '@alfresco/adf-testing'; -import * as moment from 'moment'; - +import { format, add } from 'date-fns'; export class ShareDialogPage { togglePage = new TogglePage(); @@ -85,7 +84,7 @@ export class ShareDialogPage { } async calendarTodayDayIsDisabled(): Promise { - const tomorrow = moment().add(1, 'days').format('D'); + const tomorrow = format(add(new Date(), {days: 1}), 'd'); if (tomorrow !== '1') { await this.dateTimePickerPage.checkCalendarTodayDayIsDisabled(); @@ -93,7 +92,7 @@ export class ShareDialogPage { } async setDefaultDay(): Promise { - const tomorrow = moment().add(1, 'days').format('D'); + const tomorrow = format(add(new Date(), {days: 1}), 'd'); await this.dateTimePickerPage.setDate(tomorrow); } diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.html b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.html index 352797d0c4..7f3bdf330c 100644 --- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.html +++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.html @@ -1,89 +1,115 @@