Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(kit)!: InputFiles refactor API and get rid of built-in rejections #6706

Merged
merged 7 commits into from
Feb 21, 2024
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
72 changes: 25 additions & 47 deletions projects/cdk/directives/droppable/droppable.directive.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,38 @@
import {Directive, ElementRef, Inject, Output, Self} from '@angular/core';
import {Directive, ElementRef, inject, Output} from '@angular/core';
import {tuiPreventDefault, tuiTypedFromEvent} from '@taiga-ui/cdk/observables';
import {TuiDestroyService} from '@taiga-ui/cdk/services';
import {tuiIsPresent} from '@taiga-ui/cdk/utils/miscellaneous';
import {
distinctUntilChanged,
filter,
map,
merge,
Observable,
startWith,
switchMap,
takeUntil,
} from 'rxjs';
import {distinctUntilChanged, filter, map, merge, startWith, switchMap} from 'rxjs';

@Directive({
standalone: true,
selector: '[tuiDroppableDropped], [tuiDroppableDragOverChange]',
providers: [TuiDestroyService],
host: {
'(dragover.prevent.silent)': '0',
},
})
export class TuiDroppableDirective {
@Output()
readonly tuiDroppableDropped: Observable<DataTransfer>;
private readonly el: HTMLElement = inject(ElementRef).nativeElement;

@Output()
readonly tuiDroppableDragOverChange: Observable<DataTransfer | null>;

constructor(
@Inject(ElementRef) {nativeElement}: ElementRef<HTMLElement>,
@Self() @Inject(TuiDestroyService) destroy$: Observable<void>,
) {
this.tuiDroppableDropped = tuiTypedFromEvent(nativeElement, 'drop').pipe(
tuiPreventDefault(),
map(event => event.dataTransfer),
filter(tuiIsPresent),
);
readonly tuiDroppableDropped = tuiTypedFromEvent(this.el, 'drop').pipe(
tuiPreventDefault(),
map(event => event.dataTransfer),
filter(tuiIsPresent),
);

this.tuiDroppableDragOverChange = tuiTypedFromEvent(
nativeElement,
'dragenter',
).pipe(
switchMap(({target, dataTransfer}) =>
merge(
tuiTypedFromEvent(nativeElement, 'dragleave').pipe(
filter(event => event.target === target),
),
tuiTypedFromEvent(nativeElement, 'drop'),
).pipe(
map(() => null),
startWith(dataTransfer),
@Output()
readonly tuiDroppableDragOverChange = tuiTypedFromEvent(this.el, 'dragenter').pipe(
switchMap(({target, dataTransfer}) =>
merge(
tuiTypedFromEvent(this.el, 'dragleave').pipe(
filter(event => event.target === target),
),
tuiTypedFromEvent(this.el, 'drop'),
).pipe(
map(() => null),
startWith(dataTransfer),
),
distinctUntilChanged((a, b) => (!!a && !!b) || (!a && !b)),
);

// Required by Drag and Drop API to stop redirecting
tuiTypedFromEvent(nativeElement, 'dragover')
.pipe(tuiPreventDefault(), takeUntil(destroy$))
.subscribe();
}
),
distinctUntilChanged((a, b) => (!!a && !!b) || (!a && !b)),
);
}
9 changes: 0 additions & 9 deletions projects/cdk/directives/droppable/droppable.module.ts

This file was deleted.

1 change: 0 additions & 1 deletion projects/cdk/directives/droppable/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './droppable.directive';
export * from './droppable.module';
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {TuiDroppableDirective} from '@taiga-ui/cdk';
import {TuiMockEvent} from '@taiga-ui/testing';
import {NG_EVENT_PLUGINS} from '@tinkoff/ng-event-plugins';

describe('TuiDroppable Directive', () => {
@Component({
Expand All @@ -26,8 +27,9 @@ describe('TuiDroppable Directive', () => {

beforeEach(async () => {
TestBed.configureTestingModule({
imports: [],
declarations: [TestComponent, TuiDroppableDirective],
imports: [TuiDroppableDirective],
declarations: [TestComponent],
providers: [NG_EVENT_PLUGINS],
});
await TestBed.compileComponents();
fixture = TestBed.createComponent(TestComponent);
Expand Down
1 change: 0 additions & 1 deletion projects/cdk/directives/validator/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './validator.directive';
export * from './validator.module';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {CommonModule} from '@angular/common';
import {Component} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {FormControl, ReactiveFormsModule, Validators} from '@angular/forms';
import {TuiValidatorModule} from '@taiga-ui/cdk';
import {TuiValidatorDirective} from '@taiga-ui/cdk';

describe('TuiValidator directive', () => {
@Component({
Expand All @@ -27,7 +27,7 @@ describe('TuiValidator directive', () => {

beforeEach(async () => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, CommonModule, TuiValidatorModule],
imports: [ReactiveFormsModule, CommonModule, TuiValidatorDirective],
declarations: [TestComponent],
});
await TestBed.compileComponents();
Expand Down
1 change: 1 addition & 0 deletions projects/cdk/directives/validator/validator.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import {EMPTY_FUNCTION} from '@taiga-ui/cdk/constants';

@Directive({
standalone: true,
selector: '[tuiValidator]',
providers: [
{
Expand Down
9 changes: 0 additions & 9 deletions projects/cdk/directives/validator/validator.module.ts

This file was deleted.

4 changes: 2 additions & 2 deletions projects/cdk/observables/control-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {Observable, startWith} from 'rxjs';
* Turns AbstractControl/Abstract-control-directive valueChanges into ReplaySubject(1)
*/
export function tuiControlValue<T>(
control: AbstractControl | AbstractControlDirective,
control: AbstractControl | AbstractControlDirective | null,
): Observable<T> {
return new Observable(subscriber => {
if (!control.valueChanges) {
if (!control?.valueChanges) {
throw new TuiValueChangesException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ export const IDENTIFIERS_TO_REPLACE: ReplacementIdentifier[] = [
from: {name: 'TuiPortalModule', moduleSpecifier: '@taiga-ui/cdk'},
to: {name: 'TuiDropdownPortalDirective', moduleSpecifier: '@taiga-ui/core'},
},
{
from: {name: 'TuiDroppableModule', moduleSpecifier: '@taiga-ui/cdk'},
to: {name: 'TuiDroppableDirective', moduleSpecifier: '@taiga-ui/cdk'},
},
{
from: {name: 'TuiValidatorModule', moduleSpecifier: '@taiga-ui/cdk'},
to: {name: 'TuiValidatorDirective', moduleSpecifier: '@taiga-ui/cdk'},
},
{
from: {name: 'TuiAmountModule', moduleSpecifier: '@taiga-ui/experimental'},
to: {name: 'TuiAmountPipe', moduleSpecifier: '@taiga-ui/addon-commerce'},
Expand Down
12 changes: 8 additions & 4 deletions projects/core/components/group/group.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,27 @@
&_rounded.tui-group_orientation_horizontal {
& > * {
&:first-child {
border-radius: var(--t-radius) 0 0 var(--t-radius);
border-top-left-radius: var(--t-radius);
border-bottom-left-radius: var(--t-radius);
}

&:last-child {
border-radius: 0 var(--t-radius) var(--t-radius) 0;
border-top-right-radius: var(--t-radius);
border-bottom-right-radius: var(--t-radius);
}
}
}

&_rounded.tui-group_orientation_vertical {
& > * {
&:first-child {
border-radius: var(--t-radius) var(--t-radius) 0 0;
border-top-left-radius: var(--t-radius);
border-top-right-radius: var(--t-radius);
}

&:last-child {
border-radius: 0 0 var(--t-radius) var(--t-radius);
border-bottom-left-radius: var(--t-radius);
border-bottom-right-radius: var(--t-radius);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions projects/core/directives/appearance/appearance.options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {InjectionToken, Provider} from '@angular/core';
import {Provider, ProviderToken} from '@angular/core';
import {tuiCreateToken} from '@taiga-ui/cdk';

export interface TuiAppearanceOptions {
Expand All @@ -12,7 +12,7 @@ export const TUI_APPEARANCE_DEFAULT_OPTIONS: TuiAppearanceOptions = {
export const TUI_APPEARANCE_OPTIONS = tuiCreateToken(TUI_APPEARANCE_DEFAULT_OPTIONS);

export function tuiAppearanceOptionsProvider(
useExisting: InjectionToken<TuiAppearanceOptions>,
useExisting: ProviderToken<TuiAppearanceOptions>,
): Provider {
return {provide: TUI_APPEARANCE_OPTIONS, useExisting};
}
9 changes: 6 additions & 3 deletions projects/core/styles/mixins/appearance.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.appearance-hover(@ruleset) {
.interactive({
@media (hover: hover) {
&:hover:not([data-state]) {
&:hover:not(:disabled):not([data-state]) {
@ruleset();
}
}
Expand All @@ -16,7 +16,7 @@

.appearance-active(@ruleset) {
.interactive({
&:active:not([data-state]) {
&:active:not(:disabled):not([data-state]) {
@ruleset();
}
});
Expand All @@ -34,7 +34,10 @@
}

.appearance-focus(@ruleset) {
&:focus-visible:not([data-focus='false']),
&:focus-visible:not([data-focus='false']) {
@ruleset();
}

&[data-focus='true'] {
@ruleset();
}
Expand Down
5 changes: 4 additions & 1 deletion projects/core/styles/mixins/appearance.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
}

@mixin appearance-focus {
&:focus-visible:not([data-focus='false']),
&:focus-visible:not([data-focus='false']) {
@content;
}

&[data-focus='true'] {
@content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,23 @@
});

await example
.locator('[tuiInputFiles]')
.locator('input[tuiInputFiles]')
.setInputFiles(join(__dirname, '../../../stubs/web-api.svg'));
await expect(example).toHaveScreenshot(`01-${language}-input-files.png`);

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: english)

1) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: english) Error: Screenshot comparison failed: 3382 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-english-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-english--chromium/01-english-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-english--chromium/01-english-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 3382 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 3382 pixels (ratio 0.01 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: english)

1) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: english) Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 3803 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-english-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-english--chromium-retry1/01-english-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-english--chromium-retry1/01-english-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 3803 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 3803 pixels (ratio 0.02 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: english)

1) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: english) Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 3382 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-english-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-english--chromium-retry2/01-english-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-english--chromium-retry2/01-english-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 3382 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 3382 pixels (ratio 0.01 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: dutch)

2) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: dutch) Error: Screenshot comparison failed: 3616 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-dutch-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-dutch--chromium/01-dutch-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-dutch--chromium/01-dutch-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 3616 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 3616 pixels (ratio 0.02 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: dutch)

2) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: dutch) Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 4037 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-dutch-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-dutch--chromium-retry1/01-dutch-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-dutch--chromium-retry1/01-dutch-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 4037 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 4037 pixels (ratio 0.02 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: dutch)

2) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: dutch) Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 3616 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-dutch-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-dutch--chromium-retry2/01-dutch-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-dutch--chromium-retry2/01-dutch-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 3616 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 3616 pixels (ratio 0.02 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: russian)

3) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: russian) Error: Screenshot comparison failed: 3618 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-russian-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-russian--chromium/01-russian-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-russian--chromium/01-russian-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 3618 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 3618 pixels (ratio 0.02 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: russian)

3) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: russian) Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 4039 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-russian-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-russian--chromium-retry1/01-russian-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-russian--chromium-retry1/01-russian-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 4039 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 4039 pixels (ratio 0.02 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35

Check failure on line 21 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: russian)

3) [chromium] › tests/kit/input-files/input-files.spec.ts:13:13 › InputFiles › Wrong file type (i18n: russian) Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 3618 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/01-russian-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-russian--chromium-retry2/01-russian-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-Wrong-file-type-i18n-russian--chromium-retry2/01-russian-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 3618 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 3618 pixels (ratio 0.02 of all image pixels) are different. 19 | .locator('input[tuiInputFiles]') 20 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 21 | await expect(example).toHaveScreenshot(`01-${language}-input-files.png`); | ^ 22 | }), 23 | ); 24 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:21:35
}),
);

['english', 'dutch', 'russian'].forEach(language =>
test(`File is too large (i18n: ${language})`, async ({page}) => {
test(`File is bigger than (i18n: ${language})`, async ({page}) => {
await tuiGoto(
page,
'/components/input-files/API?accept=image/*&maxFileSize=2000',
{language},
);
await example
.locator('[tuiInputFiles]')
.locator('input[tuiInputFiles]')
.setInputFiles(join(__dirname, '../../../stubs/web-api.svg'));
await expect(example).toHaveScreenshot(`02-${language}-input-files.png`);

Check failure on line 35 in projects/demo-playwright/tests/kit/input-files/input-files.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (6 of 8)

[chromium] › tests/kit/input-files/input-files.spec.ts:26:13 › InputFiles › File is bigger than (i18n: english)

4) [chromium] › tests/kit/input-files/input-files.spec.ts:26:13 › InputFiles › File is bigger than (i18n: english) Error: Screenshot comparison failed: 3382 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-files/input-files.spec.ts-snapshots/02-english-input-files-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-File-is-bigger-than-i18n-english--chromium/02-english-input-files-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-files-input-files-InputFiles-File-is-bigger-than-i18n-english--chromium/02-english-input-files-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - 3382 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content') - locator resolved to <div id="demo-content" _ngcontent-tui-demo-c130="">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - waiting for element to be visible and stable - element is visible and stable - captured a stable screenshot - 3382 pixels (ratio 0.01 of all image pixels) are different. 33 | .locator('input[tuiInputFiles]') 34 | .setInputFiles(join(__dirname, '../../../stubs/web-api.svg')); > 35 | await expect(example).toHaveScreenshot(`02-${language}-input-files.png`); | ^ 36 | }), 37 | ); 38 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-files/input-files.spec.ts:35:35
}),
);

test('Link text is too long', async ({page}) => {
await page.setViewportSize({width: 550, height: 500});
await tuiGoto(
page,
'/components/input-files/API?link=Select%20a%20file%20with%20a%20too%20long%20name.%20Long%20filename.%20Very%20long%20filename',
);
await example
.locator('[tuiInputFiles]')
.setInputFiles(join(__dirname, '../../../stubs/web-api.svg'));
await expect(example).toHaveScreenshot('03-input-files.png');
});
});
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
<tui-input-files
<label
*ngIf="!control.value"
accept="image/*"
[formControl]="control"
(reject)="onReject($event)"
></tui-input-files>
tuiInputFiles
>
<input
accept="image/*"
tuiInputFiles
[formControl]="control"
/>
</label>

<tui-files class="tui-space_top-1">
<tui-file
*ngIf="control.value | tuiFileRejected: {accept: 'image/*'} | async as file"
state="error"
[file]="file"
(remove)="removeFile()"
></tui-file>

<tui-file
*ngIf="loadedFiles$ | async as file"
[file]="file"
[showDelete]="control.enabled"
(removed)="removeFile()"
(remove)="removeFile()"
></tui-file>

<tui-file
*ngIf="rejectedFiles$ | async as file"
*ngIf="failedFiles$ | async as file"
state="error"
[file]="file"
[showDelete]="control.enabled"
(removed)="clearRejected()"
(remove)="removeFile()"
></tui-file>

<tui-file
*ngIf="loadingFiles$ | async as file"
state="loading"
[file]="file"
[showDelete]="control.enabled"
(remove)="removeFile()"
></tui-file>
</tui-files>
Loading
Loading