diff --git a/apps/code-examples/src/app/code-examples/forms/file-drop/basic/demo.component.spec.ts b/apps/code-examples/src/app/code-examples/forms/file-drop/basic/demo.component.spec.ts index 46091ab1d5..75cb9d2b78 100644 --- a/apps/code-examples/src/app/code-examples/forms/file-drop/basic/demo.component.spec.ts +++ b/apps/code-examples/src/app/code-examples/forms/file-drop/basic/demo.component.spec.ts @@ -55,7 +55,7 @@ describe('Basic file drop demo', () => { ); await expectAsync(harness.isStacked()).toBeResolvedTo(true); - const linkUploadHarness = await harness.getLinkUpload(); + const linkUploadHarness = await harness.getLinkUploadHarness(); await expectAsync(linkUploadHarness.getHintText()).toBeResolvedTo( 'Start with http:// or https://', @@ -95,7 +95,10 @@ describe('Basic file drop demo', () => { ).toBeResolvedTo(false); expect(formControl.valid).toBe(true); - await harness.uploadLink('link.to.upload'); + const uploadLinkHarness = await harness.getLinkUploadHarness(); + await uploadLinkHarness.enterText('foo.bar'); + await uploadLinkHarness.clickDoneButton(); + expect(formControl.value?.length).toBe(4); await expectAsync( harness.hasCustomError('maxNumberOfFilesReached'), diff --git a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-harness.spec.ts b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-harness.spec.ts index d2c168bb8c..4ca7c6c9d2 100644 --- a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-harness.spec.ts +++ b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-harness.spec.ts @@ -159,7 +159,7 @@ describe('File drop harness', () => { ); spyOn(input, 'click'); - await harness.clickFileUploadButton(); + await harness.clickFileDropTarget(); expect(input.click).toHaveBeenCalled(); }); @@ -211,18 +211,6 @@ describe('File drop harness', () => { await expectAsync(harness.getLabelText()).toBeResolvedTo('File upload'); }); - it('should load a file', async () => { - const { fixture, harness } = await setupTest(); - - await harness.uploadLink('foo.bar'); - - expect(fixture.componentInstance.fileDrop.value).toEqual([ - { - url: 'foo.bar', - }, - ]); - }); - it('should get whether the label is hidden', async () => { const { fixture, harness } = await setupTest(); @@ -262,7 +250,7 @@ describe('File drop harness', () => { fixture.componentInstance.required = true; fixture.detectChanges(); - const input = await (await harness.getLinkUpload()).getInput(); + const input = await (await harness.getLinkUploadHarness()).getInput(); await input.focus(); await input.blur(); @@ -349,7 +337,7 @@ describe('File drop harness', () => { fixture.detectChanges(); await expectAsync( - (await harness.getLinkUpload()).getAriaLabel(), + (await harness.getLinkUploadHarness()).getAriaLabel(), ).toBeResolvedTo('upload aria-label'); }); @@ -360,7 +348,7 @@ describe('File drop harness', () => { fixture.detectChanges(); await expectAsync( - (await harness.getLinkUpload()).getHintText(), + (await harness.getLinkUploadHarness()).getHintText(), ).toBeResolvedTo('link hint text'); }); @@ -368,7 +356,7 @@ describe('File drop harness', () => { const { harness } = await setupTest(); await expectAsync( - (await harness.getLinkUpload()).clickDoneButton(), + (await harness.getLinkUploadHarness()).clickDoneButton(), ).toBeRejectedWithError('Done button is disabled and cannot be clicked.'); }); @@ -378,10 +366,25 @@ describe('File drop harness', () => { fixture.componentInstance.allowLinks = false; fixture.detectChanges(); - await expectAsync(harness.getLinkUpload()).toBeRejectedWithError( + await expectAsync(harness.getLinkUploadHarness()).toBeRejectedWithError( 'Link upload cannot be found. Set `allowLinks` property to `true`.', ); }); + + it('should upload a link', async () => { + const { fixture, harness } = await setupTest(); + + const linkUploadHarness = await harness.getLinkUploadHarness(); + + await linkUploadHarness.enterText('foo.bar'); + await linkUploadHarness.clickDoneButton(); + + expect(fixture.componentInstance.fileDrop.value).toEqual([ + { + url: 'foo.bar', + }, + ]); + }); }); describe('sky file item harness', () => { diff --git a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-harness.ts b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-harness.ts index 379cd6f16b..aca0e445c6 100644 --- a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-harness.ts +++ b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-harness.ts @@ -33,9 +33,9 @@ export class SkyFileDropHarness extends SkyComponentHarness { } /** - * Clicks the file upload button. + * Clicks the file drop target. */ - public async clickFileUploadButton(): Promise { + public async clickFileDropTarget(): Promise { return await (await this.#fileUploadButton()).click(); } @@ -102,8 +102,8 @@ export class SkyFileDropHarness extends SkyComponentHarness { /** * Gets the link upload harness. */ - public async getLinkUpload(): Promise { - return await this.#getLinkUpload(); + public async getLinkUploadHarness(): Promise { + return await this.#getLinkUploadHarness(); } /** @@ -178,14 +178,6 @@ export class SkyFileDropHarness extends SkyComponentHarness { return await this.#dropFiles(files); } - /** - * Uploads a link. - */ - public async uploadLink(link: string): Promise { - await (await this.getLinkUpload()).enterLink(link); - await (await this.getLinkUpload()).clickDoneButton(); - } - async #dropFiles(files: File[] | null): Promise { const dropTarget = await this.#getDropTarget(); @@ -216,7 +208,7 @@ export class SkyFileDropHarness extends SkyComponentHarness { throw Error('No help inline found.'); } - async #getLinkUpload(): Promise { + async #getLinkUploadHarness(): Promise { const linkUpload = await this.locatorForOptional( SkyFileDropLinkUploadHarness, )(); diff --git a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-link-upload-harness.ts b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-link-upload-harness.ts index ad47b6daa5..3418106cb6 100644 --- a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-link-upload-harness.ts +++ b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-drop-link-upload-harness.ts @@ -5,7 +5,7 @@ import { SkyInputBoxHarness } from '../../input-box/input-box-harness'; import { SkyFileDropLinkUploadInputHarness } from './file-drop-link-upload-input-harness'; /** - * Harness for interacting with a file drop link upload component in tests. + * Harness for interacting with file drop component's link upload feature in tests. */ export class SkyFileDropLinkUploadHarness extends SkyComponentHarness { /** @@ -28,9 +28,9 @@ export class SkyFileDropLinkUploadHarness extends SkyComponentHarness { } /** - * Sets the input value. + * Enters text into the link upload input. */ - public async enterLink(link: string): Promise { + public async enterText(link: string): Promise { return await (await this.#input()).setValue(link); } diff --git a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-item-harness-filters.ts b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-item-harness-filters.ts index b3b1beaaf5..0a32805352 100644 --- a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-item-harness-filters.ts +++ b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-item-harness-filters.ts @@ -2,7 +2,6 @@ import { SkyHarnessFilters } from '@skyux/core/testing'; /** * A set of criteria that can be used to filter a list of `SkyFileItemHarness` instances. - * @internal */ // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type export interface SkyFileItemHarnessFilters extends SkyHarnessFilters { diff --git a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-item-harness.ts b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-item-harness.ts index b0654e0a56..e4f4739b84 100644 --- a/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-item-harness.ts +++ b/libs/components/forms/testing/src/modules/file-attachment/file-drop/file-item-harness.ts @@ -19,7 +19,7 @@ export class SkyFileItemHarness extends ComponentHarness { filters: SkyFileItemHarnessFilters, ): HarnessPredicate { return new HarnessPredicate(SkyFileItemHarness, filters).addOption( - 'name', + 'fileName', filters.fileName, async (harness, fileName) => { const harnessFileName = await harness.getFileName();