mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-17666] Remove date cell e2es covered by unit tests (#9153)
This commit is contained in:
@@ -183,7 +183,7 @@
|
|||||||
key="createdAt"
|
key="createdAt"
|
||||||
sortingKey="createdAt"
|
sortingKey="createdAt"
|
||||||
type="date"
|
type="date"
|
||||||
[format]="enableMediumTimeFormat ? 'medium' : 'timeAgo'"
|
[format]="'timeAgo'"
|
||||||
class="adf-ellipsis-cell">
|
class="adf-ellipsis-cell">
|
||||||
</data-column>
|
</data-column>
|
||||||
|
|
||||||
@@ -330,12 +330,6 @@
|
|||||||
</mat-slide-toggle>
|
</mat-slide-toggle>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
|
||||||
<mat-slide-toggle [(ngModel)]="enableMediumTimeFormat" id="enableMediumTimeFormat">
|
|
||||||
Enable medium time format for document list
|
|
||||||
</mat-slide-toggle>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<mat-slide-toggle [(ngModel)]="displayEmptyMetadata" id="displayEmptyMetadata">
|
<mat-slide-toggle [(ngModel)]="displayEmptyMetadata" id="displayEmptyMetadata">
|
||||||
Display Empty Metadata
|
Display Empty Metadata
|
||||||
|
@@ -185,7 +185,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
permissionsStyle: PermissionStyleModel[] = [];
|
permissionsStyle: PermissionStyleModel[] = [];
|
||||||
stickyHeader: boolean;
|
stickyHeader: boolean;
|
||||||
enableMediumTimeFormat = false;
|
|
||||||
displayEmptyMetadata = false;
|
displayEmptyMetadata = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@@ -21,7 +21,6 @@ import { createApiService, LoginPage, StringUtil, UploadActions, UserModel, User
|
|||||||
import { FileModel } from '../../models/ACS/file.model';
|
import { FileModel } from '../../models/ACS/file.model';
|
||||||
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
|
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
|
||||||
import { NodeEntry } from '@alfresco/js-api';
|
import { NodeEntry } from '@alfresco/js-api';
|
||||||
import { format } from 'date-fns';
|
|
||||||
|
|
||||||
describe('Document List Component', () => {
|
describe('Document List Component', () => {
|
||||||
let uploadedFolder: NodeEntry;
|
let uploadedFolder: NodeEntry;
|
||||||
@@ -70,14 +69,6 @@ describe('Document List Component', () => {
|
|||||||
name: browser.params.resources.Files.ADF_DOCUMENTS.DOCX.file_name,
|
name: browser.params.resources.Files.ADF_DOCUMENTS.DOCX.file_name,
|
||||||
location: browser.params.resources.Files.ADF_DOCUMENTS.DOCX.file_path
|
location: browser.params.resources.Files.ADF_DOCUMENTS.DOCX.file_path
|
||||||
});
|
});
|
||||||
const timeAgoFileModel = new FileModel({
|
|
||||||
name: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_name,
|
|
||||||
location: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_path
|
|
||||||
});
|
|
||||||
const mediumFileModel = new FileModel({
|
|
||||||
name: browser.params.resources.Files.ADF_DOCUMENTS.PDF_B.file_name,
|
|
||||||
location: browser.params.resources.Files.ADF_DOCUMENTS.PDF_B.file_path
|
|
||||||
});
|
|
||||||
|
|
||||||
let pdfUploadedNode: NodeEntry;
|
let pdfUploadedNode: NodeEntry;
|
||||||
let docxUploadedNode: NodeEntry;
|
let docxUploadedNode: NodeEntry;
|
||||||
@@ -138,24 +129,6 @@ describe('Document List Component', () => {
|
|||||||
await contentServicesPage.checkColumnCreatedByHeader();
|
await contentServicesPage.checkColumnCreatedByHeader();
|
||||||
await contentServicesPage.checkColumnCreatedHeader();
|
await contentServicesPage.checkColumnCreatedHeader();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('[C279928] Should be able to display date with timeAgo', async () => {
|
|
||||||
await apiService.login(acsUser.username, acsUser.password);
|
|
||||||
timeAgoUploadedNode = await uploadActions.uploadFile(timeAgoFileModel.location, timeAgoFileModel.name, '-my-');
|
|
||||||
await contentServicesPage.goToDocumentList();
|
|
||||||
const dateValue = await contentServicesPage.getColumnValueForRow(timeAgoFileModel.name, 'Created');
|
|
||||||
await expect(dateValue).toMatch(/(ago|few)/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('[C279929] Should be able to display the date with date type', async () => {
|
|
||||||
await apiService.login(acsUser.username, acsUser.password);
|
|
||||||
mediumDateUploadedNode = await uploadActions.uploadFile(mediumFileModel.location, mediumFileModel.name, '-my-');
|
|
||||||
const createdDate = format(new Date(mediumDateUploadedNode.entry.createdAt), 'PP');
|
|
||||||
await contentServicesPage.goToDocumentList();
|
|
||||||
await contentServicesPage.enableMediumTimeFormat();
|
|
||||||
const dateValue = await contentServicesPage.getColumnValueForRow(mediumFileModel.name, 'Created');
|
|
||||||
await expect(dateValue).toContain(createdDate);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Column Sorting', () => {
|
describe('Column Sorting', () => {
|
||||||
|
@@ -235,11 +235,6 @@ export class ContentServicesPage {
|
|||||||
await BrowserVisibility.waitUntilElementIsClickable(this.uploadFileButton);
|
await BrowserVisibility.waitUntilElementIsClickable(this.uploadFileButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
async enableMediumTimeFormat(): Promise<void> {
|
|
||||||
const mediumTimeFormat = $('#enableMediumTimeFormat');
|
|
||||||
await BrowserActions.click(mediumTimeFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
async checkPaginationIsNotDisplayed(): Promise<void> {
|
async checkPaginationIsNotDisplayed(): Promise<void> {
|
||||||
await BrowserVisibility.waitUntilElementIsVisible(this.emptyPagination);
|
await BrowserVisibility.waitUntilElementIsVisible(this.emptyPagination);
|
||||||
}
|
}
|
||||||
|
@@ -2,14 +2,14 @@
|
|||||||
<span
|
<span
|
||||||
[title]="tooltip | adfLocalizedDate: config.tooltipFormat: config.locale"
|
[title]="tooltip | adfLocalizedDate: config.tooltipFormat: config.locale"
|
||||||
class="adf-datatable-cell-value"
|
class="adf-datatable-cell-value"
|
||||||
*ngIf="format === 'timeAgo'; else standard_date">
|
*ngIf="config.format === 'timeAgo'; else standard_date">
|
||||||
{{ date | adfTimeAgo: config.locale }}
|
{{ date | adfTimeAgo: config.locale }}
|
||||||
</span>
|
</span>
|
||||||
<ng-template #standard_date>
|
<ng-template #standard_date>
|
||||||
<span
|
<span
|
||||||
class="adf-datatable-cell-value"
|
class="adf-datatable-cell-value"
|
||||||
[title]="tooltip | adfLocalizedDate: config.tooltipFormat: config.locale">
|
[title]="tooltip | adfLocalizedDate: config.tooltipFormat: config.locale">
|
||||||
{{ date | adfLocalizedDate: format: config.locale }}
|
{{ date | adfLocalizedDate: config.format: config.locale }}
|
||||||
</span>
|
</span>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -175,13 +175,13 @@ describe('DateCellComponent', () => {
|
|||||||
checkDisplayedDate(expectedDate);
|
checkDisplayedDate(expectedDate);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display date and override dateConfig by column format if is provided', () => {
|
it('should display date and override column format by dateConfig if is provided', () => {
|
||||||
component.column = mockColumn;
|
component.column = mockColumn;
|
||||||
const mockDateConfig: DateConfig = {
|
const mockDateConfig: DateConfig = {
|
||||||
format: 'short'
|
format: 'short'
|
||||||
};
|
};
|
||||||
|
|
||||||
const expectedDate = 'Wednesday, October 25, 2023 at 12:00:00 AM GMT+00:00';
|
const expectedDate = '10/25/23, 12:00 AM';
|
||||||
|
|
||||||
renderDateCell(mockDateConfig, mockDate, mockTooltip);
|
renderDateCell(mockDateConfig, mockDate, mockTooltip);
|
||||||
checkDisplayedDate(expectedDate);
|
checkDisplayedDate(expectedDate);
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Input, OnInit, ViewEncapsulation, inject } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, Input, OnInit, ViewEncapsulation, inject } from '@angular/core';
|
||||||
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
||||||
import { AppConfigService } from '../../../app-config/app-config.service';
|
import { AppConfigService } from '../../../app-config/app-config.service';
|
||||||
import { DateConfig } from '../../data/data-column.model';
|
import { DateConfig } from '../../data/data-column.model';
|
||||||
@@ -28,7 +28,8 @@ import { LocalizedDatePipe, TimeAgoPipe } from '../../../pipes';
|
|||||||
selector: 'adf-date-cell',
|
selector: 'adf-date-cell',
|
||||||
templateUrl: './date-cell.component.html',
|
templateUrl: './date-cell.component.html',
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
host: { class: 'adf-datatable-content-cell' }
|
host: { class: 'adf-datatable-content-cell' },
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class DateCellComponent extends DataTableCellComponent implements OnInit {
|
export class DateCellComponent extends DataTableCellComponent implements OnInit {
|
||||||
|
|
||||||
@@ -50,14 +51,36 @@ export class DateCellComponent extends DataTableCellComponent implements OnInit
|
|||||||
this.setConfig();
|
this.setConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
get format(): string {
|
private setConfig(): void {
|
||||||
return this.column?.format ?? this.config.format;
|
if (this.dateConfig) {
|
||||||
|
this.setCustomConfig();
|
||||||
|
} else {
|
||||||
|
this.setDefaultConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private setConfig(): void {
|
private setCustomConfig(): void {
|
||||||
this.config.format = this.dateConfig?.format || this.getAppConfigPropertyValue('dateValues.defaultDateFormat', this.defaultDateConfig.format);
|
this.config.format = this.dateConfig?.format || this.getDefaultFormat();
|
||||||
this.config.tooltipFormat = this.dateConfig?.tooltipFormat || this.getAppConfigPropertyValue('dateValues.defaultTooltipDateFormat', this.defaultDateConfig.tooltipFormat);
|
this.config.tooltipFormat = this.dateConfig?.tooltipFormat || this.getDefaultTooltipFormat();
|
||||||
this.config.locale = this.dateConfig?.locale || this.getAppConfigPropertyValue('dateValues.defaultLocale', this.defaultDateConfig.locale);
|
this.config.locale = this.dateConfig?.locale || this.getDefaultLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
private setDefaultConfig(): void {
|
||||||
|
this.config.format = this.getDefaultFormat();
|
||||||
|
this.config.tooltipFormat = this.getDefaultTooltipFormat();
|
||||||
|
this.config.locale = this.getDefaultLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDefaultFormat(): string {
|
||||||
|
return this.column?.format || this.getAppConfigPropertyValue('dateValues.defaultDateFormat', this.defaultDateConfig.format);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDefaultLocale(): string {
|
||||||
|
return this.getAppConfigPropertyValue('dateValues.defaultLocale', this.defaultDateConfig.locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDefaultTooltipFormat(): string {
|
||||||
|
return this.getAppConfigPropertyValue('dateValues.defaultTooltipDateFormat', this.defaultDateConfig.tooltipFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAppConfigPropertyValue(key: string, defaultValue: string): string {
|
private getAppConfigPropertyValue(key: string, defaultValue: string): string {
|
||||||
|
Reference in New Issue
Block a user