diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml index 958b011944..93488de3cc 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/npmpublish.yml @@ -52,7 +52,7 @@ jobs: name: code-coverage-report path: coverage - name: Analyze with SonarCloud - uses: sonarsource/sonarcloud-github-action@master + uses: sonarsource/sonarcloud-github-action@v3.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 387b6fee80..3c9ee1e1bf 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,9 @@ ## RELEASE NOTES +### Version 7.0.67 +**EXUI-2146** Case file view time is 1 hour behind +**EXUI-2230** Case File View date/time as GMT rather than Local BST + ### Version 7.0.66 **EXUI-2148** Additional checks on task completion from session storage **EXUI-2057** A frozen screen is seen when attempting to complete a current task... diff --git a/package.json b/package.json index cdf5356c3c..9261aee755 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.66", + "version": "7.0.67", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index 222880d484..c52eb45cfe 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.66", + "version": "7.0.67", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/components/case-file-view-folder/case-file-view-folder.component.html b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/components/case-file-view-folder/case-file-view-folder.component.html index 9784688d5a..49bc563249 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/components/case-file-view-folder/case-file-view-folder.component.html +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/components/case-file-view-folder/case-file-view-folder.component.html @@ -36,7 +36,7 @@ {{node.name}}
- {{node.upload_timestamp | date:"dd MMM YYYY HH:mm"}} + {{node.upload_timestamp | ccdDate : 'local' | date:"dd MMM YYYY HH:mm"}}
{ let component: CaseFileViewFolderComponent; @@ -34,7 +36,7 @@ describe('CaseFileViewFolderComponent', () => { document_filename: 'Lager encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '11 May 2023 00:00:00' + upload_timestamp: '2023-05-11T11:15:10.00' }, { name: 'Beers encyclopedia', @@ -42,7 +44,7 @@ describe('CaseFileViewFolderComponent', () => { document_filename: 'Beers encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '14 Apr 2023 00:00:00' + upload_timestamp: '2023-04-14T15:30:00.00' }, { name: 'Ale encyclopedia', @@ -50,10 +52,34 @@ describe('CaseFileViewFolderComponent', () => { document_filename: 'Ale encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '12 Mar 2023 01:23:01' + upload_timestamp: '2023-03-12T01:23:01.00' } ]); + // Method used to resolve discrepancies between GitHub Actions and local machine timezones. + // This function adjusts the given UTC date string to the local timezone of the machine + // running the code. It uses the Moment.js library to detect the current system's timezone + // dynamically and converts the date accordingly, formatting it to "D MMM YYYY HH:mm". + function adjustDateToLocal(dateString: Date | string): string { + // Determine the local time zone dynamically + const localTimeZone = moment.tz.guess(); + console.log(`Detected Local Time Zone: ${localTimeZone}`); + + // Create a Moment object from the date string in UTC + const utcDate = moment.tz(dateString, 'UTC'); + console.log('Original UTC Date:', utcDate.format()); + + // Convert the UTC date to the local time zone + const localDate = utcDate.clone().tz(localTimeZone); + console.log(`Converted to Local Time (${localTimeZone}):`, localDate.format()); + + // Format the adjusted date to the desired string format: "11 May 2023 12:15" + const formattedDate = localDate.format('D MMM YYYY HH:mm'); + console.log(`Formatted Date: ${formattedDate}`); + + return formattedDate; + } + beforeEach(waitForAsync(() => { const mockWindowService = createSpyObj('WindowService', ['setLocalStorage', 'openOnNewTab']); mockAppConfig = jasmine.createSpyObj('AbstractAppConfig', ['getEnableCaseFileViewVersion1_1']); @@ -66,12 +92,14 @@ describe('CaseFileViewFolderComponent', () => { MatDialogModule ], declarations: [ - CaseFileViewFolderComponent + CaseFileViewFolderComponent, + DatePipe ], providers: [ { provide: WindowService, useValue: mockWindowService }, { provide: DocumentManagementService, useValue: mockDocumentManagementService }, - { provide: AbstractAppConfig, useValue: mockAppConfig } + { provide: AbstractAppConfig, useValue: mockAppConfig }, + FormatTranslatorService ] }).compileComponents(); @@ -90,11 +118,11 @@ describe('CaseFileViewFolderComponent', () => { documentFilterInputEl.dispatchEvent(new Event('input')); fixture.detectChanges(); await fixture.whenStable(); - component.sortDataSourceDescending(1) + component.sortDataSourceDescending(1); fixture.detectChanges(); expect(component.filter).toHaveBeenCalled(); - expect(treeData[3].children[0].upload_timestamp).toEqual('17 Nov 2022 00:00:00'); + expect(treeData[3].children[0].upload_timestamp).toEqual('2022-11-17T00:00:00.00'); }); it('should generate tree data from categorised data', () => { @@ -116,19 +144,24 @@ describe('CaseFileViewFolderComponent', () => { fixture.detectChanges(); const documentTreeContainerEl = nativeElement.querySelector('.document-tree-container'); expect(documentTreeContainerEl).toBeDefined(); + const timestampElements = nativeElement.querySelectorAll('.node__document-upload-timestamp'); - expect(timestampElements[0].textContent).toEqual('11 May 2023 00:00'); - expect(timestampElements[1].textContent).toEqual('14 Apr 2023 00:00'); - expect(timestampElements[2].textContent).toEqual('12 Mar 2023 01:23'); - expect(timestampElements[3].textContent).toEqual(''); - expect(timestampElements[4].textContent).toEqual('10 Feb 2023 00:00'); - expect(timestampElements[5].textContent).toEqual('12 Apr 2023 00:00'); - expect(timestampElements[6].textContent).toEqual('16 Mar 2023 00:00'); - expect(timestampElements[7].textContent).toEqual('21 Jun 2022 00:00'); - expect(timestampElements[8].textContent).toEqual('04 Nov 2022 00:00'); - expect(timestampElements[9].textContent).toEqual('28 Dec 2022 00:00'); - expect(timestampElements[10].textContent).toEqual('17 Nov 2022 00:00'); - expect(timestampElements[11].textContent).toEqual('23 Feb 2023 00:00'); + const documents = categoriesAndDocumentsTestData.categories[0]?.documents || []; + + // Loop over the timestamp elements and adjust based on the documents array length + timestampElements.forEach((element, index) => { + // Ensure the document exists at the current index + const document = documents[index]; + if (!document) { + return; // Skip this iteration + } + + // Adjust the document timestamp to local time + const adjustedTimestamp = adjustDateToLocal(document.upload_timestamp); + + // Verify that the element's text content matches the adjusted timestamp + expect(element.textContent).toEqual(adjustedTimestamp); + }); }); it('should call sortChildrenAscending on all children of nestedDataSource when calling sortDataSourceAscAlphabetically', () => { diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/components/case-file-view-folder/case-file-view-folder.component.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/components/case-file-view-folder/case-file-view-folder.component.ts index dd99b75286..6520bbb1c4 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/components/case-file-view-folder/case-file-view-folder.component.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/components/case-file-view-folder/case-file-view-folder.component.ts @@ -3,7 +3,6 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angu import { FormControl, FormGroup } from '@angular/forms'; import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { Router } from '@angular/router'; -import moment from 'moment/moment'; import { Observable, Subscription, of } from 'rxjs'; import { switchMap, tap } from 'rxjs/operators'; import { AbstractAppConfig } from '../../../../../../app.config'; @@ -130,7 +129,7 @@ export class CaseFileViewFolderComponent implements OnInit, OnDestroy { documentTreeNode.document_binary_url = document.document_binary_url; documentTreeNode.attribute_path = document.attribute_path; documentTreeNode.upload_timestamp = this.appConfig.getEnableCaseFileViewVersion1_1() - && document.upload_timestamp ? moment(document.upload_timestamp).format('DD MMM YYYY HH:mm:ss') : ''; + && document.upload_timestamp ? document.upload_timestamp.toString() : ''; documentsToReturn.push(documentTreeNode); }); @@ -148,7 +147,7 @@ export class CaseFileViewFolderComponent implements OnInit, OnDestroy { documentTreeNode.document_binary_url = document.document_binary_url; documentTreeNode.attribute_path = document.attribute_path; documentTreeNode.upload_timestamp = this.appConfig.getEnableCaseFileViewVersion1_1() - && document.upload_timestamp ? moment(document.upload_timestamp).format('DD MMM YYYY HH:mm:ss') : ''; + && document.upload_timestamp ? document.upload_timestamp.toString() : ''; documents.push(documentTreeNode); }); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/test-data/categories-and-documents-test-data.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/test-data/categories-and-documents-test-data.ts index 852c3b67c5..d28c724d30 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/test-data/categories-and-documents-test-data.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/test-data/categories-and-documents-test-data.ts @@ -13,7 +13,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Lager encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2023, 4, 11, 0, 0, 0, 0), + upload_timestamp: '2023-05-11T11:15:10.00', content_type: '' }, { @@ -21,7 +21,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Beers encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2023, 3, 14, 0, 0, 0, 0), + upload_timestamp: '2023-04-14T15:30:00.00', content_type: '' }, { @@ -29,7 +29,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Ale encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2023, 2, 12, 1, 23, 1, 0), + upload_timestamp: '2023-03-12T01:23:01.00', content_type: '' } ], @@ -88,7 +88,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Details about white wine', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2023, 1, 10, 0, 0, 0, 0), + upload_timestamp: '2023-02-10T00:00:00.00', content_type: '' }, { @@ -96,7 +96,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Details about Prosecco', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2023, 3, 12, 0, 0, 0, 0), + upload_timestamp: '2023-04-12T00:00:00.00', content_type: '' }, { @@ -104,7 +104,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Details about Pinot Grigio', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2023, 2, 16, 0, 0, 0, 0), + upload_timestamp: '2023-03-16T00:00:00.00', content_type: '' } ], @@ -155,7 +155,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Details about Whisky Lowland 1', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2022, 5, 21, 0, 0, 0, 0), + upload_timestamp: '2022-06-21T00:00:00.00', content_type: '' } ], @@ -180,7 +180,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Details about Whisky Islay', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2022, 10, 4, 0, 0, 0, 0), + upload_timestamp: '2022-11-04T00:00:00.00', content_type: '' }, { @@ -188,7 +188,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'More information about Whisky Islay', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2022, 11, 28, 0, 0, 0, 0), + upload_timestamp: '2022-12-28T00:00:00.00', content_type: '' } ], @@ -219,7 +219,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Uncategorised document 1', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2022, 10, 17, 0, 0, 0, 0), + upload_timestamp: '2022-11-17T00:00:00.00', content_type: '' }, { @@ -227,7 +227,7 @@ export const categoriesAndDocumentsTestData: CategoriesAndDocuments = { document_filename: 'Uncategorised document 2', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: new Date(2023, 1, 23, 0, 0, 0, 0), + upload_timestamp: '2023-02-23T00:00:00.00', content_type: '' } ] diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/test-data/document-tree-node-test-data.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/test-data/document-tree-node-test-data.ts index 4d04382a0b..3de6cc57c4 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/test-data/document-tree-node-test-data.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-file-view/test-data/document-tree-node-test-data.ts @@ -7,7 +7,7 @@ export const lagerEncyclopedia = { document_filename: 'Lager encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '11 May 2023 00:00:00' + upload_timestamp: '2023-05-11T11:15:10.00' }; export const beersEncyclopedia = { @@ -16,7 +16,7 @@ export const beersEncyclopedia = { document_filename: 'Beers encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '14 Apr 2023 00:00:00' + upload_timestamp: '2023-04-14T15:30:00.00' }; export const aleEncyclopedia = { @@ -25,7 +25,7 @@ export const aleEncyclopedia = { document_filename: 'Ale encyclopedia', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '12 Mar 2023 01:23:01' + upload_timestamp: '2023-03-12T01:23:01.00' }; export const whiskyHighland = { @@ -48,7 +48,7 @@ export const whiskyLowland1 = { document_filename: 'Details about Whisky Lowland 1', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '21 Jun 2022 00:00:00' + upload_timestamp: '2022-06-21T00:00:00.00' }; export const whiskyLowland = { @@ -79,7 +79,7 @@ export const whiskyIslayDetails = { document_filename: 'Details about Whisky Islay', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '04 Nov 2022 00:00:00' + upload_timestamp: '2022-11-04T00:00:00.00' }; export const whiskyIslayMoreInformation = { @@ -88,7 +88,7 @@ export const whiskyIslayMoreInformation = { document_filename: 'More information about Whisky Islay', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '28 Dec 2022 00:00:00' + upload_timestamp: '2022-12-28T00:00:00.00' }; export const whiskySpeyside = { @@ -120,7 +120,7 @@ export const whiteWineItalian = { document_filename: 'Details about white wine', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '10 Feb 2023 00:00:00' + upload_timestamp: '2023-02-10T00:00:00.00' }; export const proseccoItalian = { @@ -129,7 +129,7 @@ export const proseccoItalian = { document_filename: 'Details about Prosecco', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '12 Apr 2023 00:00:00' + upload_timestamp: '2023-04-12T00:00:00.00' }; export const pinotGrigioItalian = { @@ -138,7 +138,7 @@ export const pinotGrigioItalian = { document_filename: 'Details about Pinot Grigio', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '16 Mar 2023 00:00:00' + upload_timestamp: '2023-03-16T00:00:00.00' }; export const beersAlphabeticallyAsc = { @@ -306,7 +306,7 @@ export const uncategorisedDocument1 = { document_filename: 'Uncategorised document 1', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '17 Nov 2022 00:00:00' + upload_timestamp: '2022-11-17T00:00:00.00' }; export const uncategorisedDocument2 = { @@ -315,7 +315,7 @@ export const uncategorisedDocument2 = { document_filename: 'Uncategorised document 2', document_binary_url: '/test/binary', attribute_path: '', - upload_timestamp: '23 Feb 2023 00:00:00' + upload_timestamp: '2023-02-23T00:00:00.00' }; export const categorisedTreeData: DocumentTreeNode[] = plainToClass(DocumentTreeNode, [