Skip to content

Commit cd08d7f

Browse files
committed
test: updated text for minimal and bundle
1 parent b0a85d4 commit cd08d7f

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

src/blocks/DropArea/DropArea.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ export class DropArea extends LitUploaderBlock {
5555
@state()
5656
private _dropTextKey = 'drop-files-here';
5757

58+
private _isMultiple = false;
59+
private _updateDropText(): void {
60+
const customText = this.text;
61+
if (typeof customText === 'string' && customText.length > 0) {
62+
this._dropTextKey = this.l10n(customText) || customText;
63+
return;
64+
}
65+
this._dropTextKey = this._isMultiple ? this.l10n('drop-files-here') : this.l10n('drop-file-here');
66+
}
67+
5868
private _destroyDropzone: (() => void) | null = null;
5969
private _destroyContentWrapperDropzone: (() => void) | null = null;
6070
private _contentWrapperRef: Ref<HTMLDivElement> = createRef();
@@ -141,22 +151,22 @@ export class DropArea extends LitUploaderBlock {
141151
});
142152

143153
this.subConfigValue('multiple', (val) => {
144-
const customText = this.text;
145-
if (typeof customText === 'string' && customText.length > 0) {
146-
this._dropTextKey = this.l10n(customText) || customText;
147-
return;
148-
}
149-
this._dropTextKey = val ? this.l10n('drop-files-here') : this.l10n('drop-file-here');
154+
this._isMultiple = Boolean(val);
155+
this._updateDropText();
150156
});
151157
}
152158

153-
protected override willUpdate(changedProperties: PropertyValues<this>): void {
159+
protected override willUpdate(changedProperties: PropertyValues<this & { localeId: string }>): void {
154160
super.willUpdate(changedProperties);
155161

156162
if (changedProperties.has('disabled')) {
157163
this._updateIsEnabled();
158164
this._updateVisibility();
159165
}
166+
167+
if (changedProperties.has('text') || changedProperties.has('localeId')) {
168+
this._updateDropText();
169+
}
160170
}
161171

162172
protected override updated(changedProperties: PropertyValues<this>): void {

tests/bundles.e2e.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ describe('Bundles', () => {
158158
</>,
159159
);
160160

161-
await expect.element(page.getByText('Choose file', { exact: true })).toBeVisible();
161+
await expect.element(page.getByText('Choose files', { exact: true })).toBeVisible();
162162
});
163163

164164
test('web/uc-file-uploader-regular.min.js', async () => {

tests/file-uploader-minimal.e2e.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ beforeEach(() => {
2525
describe('File uploader minimal', () => {
2626
describe('Upload button', () => {
2727
it('should be rendered', async () => {
28-
await expect.element(page.getByText('Choose file', { exact: true })).toBeVisible();
28+
await expect.element(page.getByText('Choose files', { exact: true })).toBeVisible();
2929
});
3030

3131
it('should open file dialog on click', async () => {
32-
await page.getByText('Choose file', { exact: true }).click();
32+
await page.getByText('Choose files', { exact: true }).click();
3333
const startFrom = page.getByTestId('uc-start-from');
3434
await expect(startFrom).toBeDefined();
3535
});
@@ -46,7 +46,7 @@ describe('File uploader minimal', () => {
4646
});
4747

4848
it('should open cloud image editor modal on edit button click', async () => {
49-
await page.getByText('Choose file', { exact: true }).click();
49+
await page.getByText('Choose files', { exact: true }).click();
5050
const startFrom = page.getByTestId('uc-start-from');
5151
const uploadList = page.getByTestId('uc-upload-list');
5252

0 commit comments

Comments
 (0)