[ACS-10296] Upload new version button made accessible with keyboard (#11242)

This commit is contained in:
MichalKinas
2025-10-03 14:52:33 +02:00
committed by GitHub
parent 3356dab434
commit 25ecfcf5e1
2 changed files with 14 additions and 1 deletions
@@ -15,7 +15,7 @@
[title]="tooltip"
(change)="onFilesAdded($event)"
(click)="onClickUploadButton()"/>
<label for="upload-single-file" class="adf-upload-button-label">
<label tabindex="0" (keydown.enter)="onClickUploadButton()" for="upload-single-file" class="adf-upload-button-label">
<mat-icon class="adf-upload-button-icon">file_upload</mat-icon>
<span id="upload-single-file-label" *ngIf="!staticTitle">
{{ 'FILE_UPLOAD.BUTTON.UPLOAD_FILE' | translate }}</span>
@@ -25,6 +25,7 @@ import { mockUploadErrorPromise } from '../../mock/upload.service.mock';
import { UploadService } from '../../common/services/upload.service';
import { NodesApiService } from '../../common/services/nodes-api.service';
import { FileUploadErrorEvent } from '../../common/events/file.event';
import { UnitTestingUtils } from '@alfresco/adf-core';
describe('UploadButtonComponent', () => {
const file = { name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json' };
@@ -43,6 +44,7 @@ describe('UploadButtonComponent', () => {
let fixture: ComponentFixture<UploadButtonComponent>;
let uploadService: UploadService;
let nodesApiService: NodesApiService;
let unitTestingUtils: UnitTestingUtils;
beforeEach(() => {
TestBed.configureTestingModule({
@@ -53,6 +55,7 @@ describe('UploadButtonComponent', () => {
nodesApiService = TestBed.inject(NodesApiService);
component = fixture.componentInstance;
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
fixture.detectChanges();
});
@@ -200,6 +203,16 @@ describe('UploadButtonComponent', () => {
expect(compiled.querySelector('#uploadFolder-label-static').textContent.trim()).toEqual('test-text');
});
it('should call onClickUploadButton when label for single file receives enter key', () => {
component.uploadFolders = false;
component.multipleFiles = false;
spyOn(component, 'onClickUploadButton');
unitTestingUtils.keyBoardEventByCSS('.adf-upload-button-label', 'keydown', 'Enter', 'Enter');
expect(component.onClickUploadButton).toHaveBeenCalled();
});
describe('fileSize', () => {
const files: File[] = [{ name: 'bigFile.png', size: 1000 } as File, { name: 'smallFile.png', size: 10 } as File];