Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion src/components/file-input/file-input.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
import {
elementUpdated,
expect,
fixture,
html,
nextFrame,
} from '@open-wc/testing';
import type { TemplateResult } from 'lit';
import { spy } from 'sinon';
import { defineComponents } from '#internals/definitions/defineComponents.js';
Expand All @@ -12,6 +18,7 @@ import {
type ValidationContainerTestsParams,
} from '#internals/testing/validity-helpers.spec.js';
import { firstOf } from '#internals/utils/arrays.js';
import { configureTheme } from '#theming/config.js';
import IgcFileInputComponent from './file-input.js';

describe('File Input component', () => {
Expand Down Expand Up @@ -152,6 +159,40 @@ describe('File Input component', () => {
'Choose a file'
);
});

for (const theme of [
'bootstrap',
'material',
'fluent',
'indigo',
] as const) {
it(`truncates overflowing file names instead of growing (${theme})`, async () => {
configureTheme(theme);
await createFixture(
html`<igc-file-input multiple style="width: 300px"></igc-file-input>`
);

simulateFileUpload(
input,
Array.from(
{ length: 8 },
(_, i) => new File([''], `a-very-long-file-name-number-${i}.txt`)
)
);
await elementUpdated(element);
await nextFrame();

const container = getDOM('[part~="container"]') as HTMLElement;
const names = getDOM('[part="file-names"] > span') as HTMLElement;

expect(container.scrollWidth).to.be.at.most(element.offsetWidth);
expect(names.scrollWidth).to.be.greaterThan(names.clientWidth);
Comment thread
Copilot marked this conversation as resolved.
expect(getComputedStyle(names).textOverflow).to.equal('ellipsis');

configureTheme('bootstrap');
await nextFrame();
});
}
});

describe('Events', () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/file-input/themes/file-input.base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $theme-file-input: file-input.$base;
[part='file-names'] {
display: flex;
align-items: center;
min-width: 0;
max-height: var-get($theme, 'size');
height: 100%;
grid-area: 1 / 3;
Expand Down
Loading