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 35775a2787f..5dc9f98e45a 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 @@ -83,7 +83,6 @@ data-automation-id="adf-share-link" class="adf-share-link__input" matInput - cdkFocusInitial placeholder="{{ 'SHARE.PUBLIC-LINK' | translate }}" [attr.aria-label]="'SHARE.PUBLIC-LINK' | translate" formControlName="sharedUrl" diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.spec.ts b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.spec.ts index e534164b33a..7c037077ec4 100644 --- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.spec.ts +++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.spec.ts @@ -16,7 +16,7 @@ */ import { TestBed, ComponentFixture } from '@angular/core/testing'; -import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; +import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatDialogModule } from '@angular/material/dialog'; import { of } from 'rxjs'; import { NotificationService } from '@alfresco/adf-core'; import { NodesApiService, RenditionService } from '../common'; @@ -33,7 +33,6 @@ import { MatSlideToggleHarness } from '@angular/material/slide-toggle/testing'; describe('ShareDialogComponent', () => { let loader: HarnessLoader; let node: NodeEntry; - let matDialog: MatDialog; const notificationServiceMock = { openSnackMessage: jasmine.createSpy('openSnackMessage') }; @@ -56,7 +55,7 @@ describe('ShareDialogComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ContentTestingModule], + imports: [ContentTestingModule, MatDialogModule, ShareDialogComponent], providers: [ { provide: NotificationService, useValue: notificationServiceMock }, { @@ -71,7 +70,6 @@ describe('ShareDialogComponent', () => { fixture = TestBed.createComponent(ShareDialogComponent); component = fixture.componentInstance; - matDialog = TestBed.inject(MatDialog); sharedLinksApiService = TestBed.inject(SharedLinksApiService); renditionService = TestBed.inject(RenditionService); nodesApiService = TestBed.inject(NodesApiService); @@ -179,7 +177,8 @@ describe('ShareDialogComponent', () => { }); it('should open a confirmation dialog when unshare button is triggered', async () => { - spyOn(matDialog, 'open').and.returnValue({ beforeClosed: () => of(false) } as any); + const dialog = fixture.debugElement.injector.get(MatDialog); + const openSpy = spyOn(dialog, 'open').and.returnValue({ beforeClosed: () => of(false) } as any); spyOn(sharedLinksApiService, 'deleteSharedLink').and.callThrough(); node.entry.properties['qshare:sharedId'] = 'sharedId'; @@ -194,11 +193,12 @@ describe('ShareDialogComponent', () => { const toggle = await loader.getHarness(MatSlideToggleHarness.with({ selector: shareToggleId })); await toggle.toggle(); - expect(matDialog.open).toHaveBeenCalled(); + expect(openSpy).toHaveBeenCalled(); }); it('should unshare file when confirmation dialog returns true', async () => { - spyOn(matDialog, 'open').and.returnValue({ beforeClosed: () => of(true) } as any); + const dialog = fixture.debugElement.injector.get(MatDialog); + spyOn(dialog, 'open').and.returnValue({ beforeClosed: () => of(true) } as any); spyOn(sharedLinksApiService, 'deleteSharedLink').and.returnValue(of({})); node.entry.properties['qshare:sharedId'] = 'sharedId'; @@ -208,6 +208,7 @@ describe('ShareDialogComponent', () => { }; fixture.detectChanges(); + await fixture.whenStable(); const toggle = await loader.getHarness(MatSlideToggleHarness.with({ selector: shareToggleId })); await toggle.toggle(); @@ -216,7 +217,8 @@ describe('ShareDialogComponent', () => { }); it('should not unshare file when confirmation dialog returns false', async () => { - spyOn(matDialog, 'open').and.returnValue({ beforeClosed: () => of(false) } as any); + const dialog = fixture.debugElement.injector.get(MatDialog); + spyOn(dialog, 'open').and.returnValue({ beforeClosed: () => of(false) } as any); spyOn(sharedLinksApiService, 'deleteSharedLink').and.callThrough(); node.entry.properties['qshare:sharedId'] = 'sharedId'; diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts index c5111a718f2..5f1d241e8af 100644 --- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts +++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts @@ -16,17 +16,24 @@ */ import { Component, Inject, OnInit, ViewEncapsulation, ViewChild, OnDestroy } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { MatSlideToggleChange } from '@angular/material/slide-toggle'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; +import { MatSlideToggleChange, MatSlideToggleModule } from '@angular/material/slide-toggle'; +import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { Subject } from 'rxjs'; import { ContentService } from '../common/services/content.service'; import { SharedLinksApiService } from './services/shared-links-api.service'; import { SharedLinkBodyCreate } from '@alfresco/js-api'; -import { ConfirmDialogComponent } from '@alfresco/adf-core'; +import { ClipboardModule, ConfirmDialogComponent } from '@alfresco/adf-core'; import { ContentNodeShareSettings } from './content-node-share.settings'; import { RenditionService } from '../common/services/rendition.service'; import { format, add, endOfDay, isBefore } from 'date-fns'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatIconModule } from '@angular/material/icon'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatDatepickerModule } from '@angular/material/datepicker'; +import { MatInputModule } from '@angular/material/input'; +import { MatButtonModule } from '@angular/material/button'; interface SharedDialogFormProps { sharedUrl: FormControl; @@ -35,6 +42,20 @@ interface SharedDialogFormProps { @Component({ selector: 'adf-share-dialog', + standalone: true, + imports: [ + CommonModule, + TranslateModule, + MatIconModule, + MatDialogModule, + ReactiveFormsModule, + MatSlideToggleModule, + MatFormFieldModule, + MatDatepickerModule, + MatInputModule, + ClipboardModule, + MatButtonModule + ], templateUrl: './content-node-share.dialog.html', styleUrls: ['./content-node-share.dialog.scss'], host: { class: 'adf-share-dialog' }, diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.directive.spec.ts b/lib/content-services/src/lib/content-node-share/content-node-share.directive.spec.ts index aa19ffa4c82..65b77e4f9a3 100644 --- a/lib/content-services/src/lib/content-node-share/content-node-share.directive.spec.ts +++ b/lib/content-services/src/lib/content-node-share/content-node-share.directive.spec.ts @@ -21,10 +21,12 @@ import { Component } from '@angular/core'; import { DOCUMENT } from '@angular/common'; import { ContentTestingModule } from '../testing/content.testing.module'; import { CoreModule } from '@alfresco/adf-core'; -import { ContentNodeShareModule } from './content-node-share.module'; +import { NodeSharedDirective } from '@alfresco/adf-content-services'; @Component({ selector: 'adf-node-share-test-component', + standalone: true, + imports: [NodeSharedDirective], template: `