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

feat(core): tuiHintDirection priority list #9669

Merged
merged 8 commits into from
Nov 5, 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
2 changes: 1 addition & 1 deletion projects/core/directives/hint/hint-options.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const TUI_HINT_DIRECTIONS: readonly TuiHintDirection[] = [

export interface TuiHintOptions {
readonly appearance: string;
readonly direction: TuiHintDirection;
readonly direction: TuiHintDirection | TuiHintDirection[];
readonly hideDelay: number;
readonly icon: string;
readonly showDelay: number;
Expand Down
9 changes: 5 additions & 4 deletions projects/core/directives/hint/hint-position.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ export class TuiHintPosition extends TuiPositionAccessor {
this.points['right-bottom'][TOP] = this.points['left-bottom'][TOP];
this.points['right-bottom'][LEFT] = this.points['right-top'][LEFT];

if (this.checkPosition(this.points[this.direction], width, height)) {
return this.points[this.direction];
}
const priorityDirections = Array.isArray(this.direction)
? this.direction
: [this.direction];
const sortedDirections = priorityDirections.concat(TUI_HINT_DIRECTIONS);

const direction = TUI_HINT_DIRECTIONS.find((direction) =>
const direction = sortedDirections.find((direction) =>
this.checkPosition(this.points[direction], width, height),
);

Expand Down
25 changes: 21 additions & 4 deletions projects/demo-playwright/tests/core/hint/hint.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {DemoRoute} from '@demo/routes';
import {TuiDocumentationPagePO, tuiGoto} from '@demo-playwright/utils';
import {expect, test} from '@playwright/test';
import type {TuiHintDirection} from '@taiga-ui/core';
import type {TuiHintOptions} from '@taiga-ui/core';

test.describe('TuiHint', () => {
test('TuiHint works', async ({page}) => {
Expand All @@ -14,7 +14,7 @@
});

test.describe('Manual hint works', () => {
const directions: readonly TuiHintDirection[] = [
const directions: Array<TuiHintOptions['direction']> = [
'bottom-left',
'bottom-right',
'bottom',
Expand All @@ -27,21 +27,22 @@
'top-left',
'top-right',
'top',
['bottom', 'left'],
];

directions.forEach((direction) => {
directions.forEach((direction, directionIndex) => {
[256, 1280].forEach((width) => {
test(`tuiHintDirection is ${direction}, viewport width is ${width}px`, async ({
page,
}) => {
await page.setViewportSize({width, height: 300});
await tuiGoto(
page,
`/directives/hint-manual/API?tuiHintManual=true&tuiHintDirection=${direction}`,
`/directives/hint-manual/API?tuiHintManual=true&tuiHintDirection$=${directionIndex}`,
);
await new TuiDocumentationPagePO(page).prepareBeforeScreenshot();

await expect(page).toHaveScreenshot(

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom-left

1) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom-left, viewport width is 1280px Error: Screenshot comparison failed: 23900 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-1280-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium/02-hint-manual-direction-bottom-left-and-width-1280-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium/02-hint-manual-direction-bottom-left-and-width-1280-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom-left-and-width__1280.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 23900 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 23900 pixels (ratio 0.02 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom-left

1) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom-left, viewport width is 1280px Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 23900 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-1280-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium-retry1/02-hint-manual-direction-bottom-left-and-width-1280-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium-retry1/02-hint-manual-direction-bottom-left-and-width-1280-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom-left-and-width__1280.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 23900 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 23900 pixels (ratio 0.02 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom-left

1) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom-left, viewport width is 1280px Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 23900 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-1280-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium-retry2/02-hint-manual-direction-bottom-left-and-width-1280-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium-retry2/02-hint-manual-direction-bottom-left-and-width-1280-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom-left-and-width__1280.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 23900 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 23900 pixels (ratio 0.02 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom

2) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom,left, viewport width is 256px Error: Screenshot comparison failed: 30576 pixels (ratio 0.10 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-256-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-db0fa-eft-viewport-width-is-256px-chromium/02-hint-manual-direction-bottom-left-and-width-256-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-db0fa-eft-viewport-width-is-256px-chromium/02-hint-manual-direction-bottom-left-and-width-256-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom,left-and-width__256.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 30576 pixels (ratio 0.10 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 30576 pixels (ratio 0.10 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom

2) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom,left, viewport width is 256px Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 30576 pixels (ratio 0.10 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-256-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-db0fa-eft-viewport-width-is-256px-chromium-retry1/02-hint-manual-direction-bottom-left-and-width-256-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-db0fa-eft-viewport-width-is-256px-chromium-retry1/02-hint-manual-direction-bottom-left-and-width-256-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom,left-and-width__256.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 30576 pixels (ratio 0.10 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 30576 pixels (ratio 0.10 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom

2) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom,left, viewport width is 256px Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 30576 pixels (ratio 0.10 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-256-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-db0fa-eft-viewport-width-is-256px-chromium-retry2/02-hint-manual-direction-bottom-left-and-width-256-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-db0fa-eft-viewport-width-is-256px-chromium-retry2/02-hint-manual-direction-bottom-left-and-width-256-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom,left-and-width__256.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 30576 pixels (ratio 0.10 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 30576 pixels (ratio 0.10 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom

3) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom,left, viewport width is 1280px Error: Screenshot comparison failed: 30594 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-1280-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium/02-hint-manual-direction-bottom-left-and-width-1280-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium/02-hint-manual-direction-bottom-left-and-width-1280-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom,left-and-width__1280.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 30594 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 30594 pixels (ratio 0.02 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom

3) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom,left, viewport width is 1280px Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 30594 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-1280-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium-retry1/02-hint-manual-direction-bottom-left-and-width-1280-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium-retry1/02-hint-manual-direction-bottom-left-and-width-1280-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom,left-and-width__1280.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 30594 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 30594 pixels (ratio 0.02 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40

Check failure on line 45 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom

3) [chromium] › tests/core/hint/hint.spec.ts:35:21 › TuiHint › Manual hint works › tuiHintDirection is bottom,left, viewport width is 1280px Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 30594 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/02-hint-manual-direction-bottom-left-and-width-1280-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium-retry2/02-hint-manual-direction-bottom-left-and-width-1280-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-991d4-ft-viewport-width-is-1280px-chromium-retry2/02-hint-manual-direction-bottom-left-and-width-1280-diff.png Call log: - expect.toHaveScreenshot(02-hint-manual-direction__bottom,left-and-width__1280.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 30594 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 30594 pixels (ratio 0.02 of all image pixels) are different. 43 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 44 | > 45 | await expect(page).toHaveScreenshot( | ^ 46 | `02-hint-manual-direction__${direction}-and-width__${width}.png`, 47 | ); 48 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:45:40
`02-hint-manual-direction__${direction}-and-width__${width}.png`,
);
});
Expand Down Expand Up @@ -115,4 +116,20 @@

await expect(example).toHaveScreenshot('05-tooltip-bottom.png');
});

test('Hint direction with priority -> bottom, left', async ({page}) => {
await page.setViewportSize({width: 1280, height: 300});
await tuiGoto(
page,
'/directives/hint-manual/API?tuiHintManual=true&tuiHintDirection$=12',
);

await new TuiDocumentationPagePO(page).prepareBeforeScreenshot();

await expect(page).toHaveScreenshot('06-hint-direction__bottom.png');

Check failure on line 129 in projects/demo-playwright/tests/core/hint/hint.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / (2 of 9)

[chromium] › tests/core/hint/hint.spec.ts:120:9 › TuiHint › Hint direction with priority -> bottom

4) [chromium] › tests/core/hint/hint.spec.ts:120:9 › TuiHint › Hint direction with priority -> bottom, left Error: Screenshot comparison failed: 30594 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.spec.ts-snapshots/06-hint-direction-bottom-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-673a9-with-priority---bottom-left-chromium/06-hint-direction-bottom-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint-TuiHi-673a9-with-priority---bottom-left-chromium/06-hint-direction-bottom-diff.png Call log: - expect.toHaveScreenshot(06-hint-direction__bottom.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 30594 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 30594 pixels (ratio 0.02 of all image pixels) are different. 127 | await new TuiDocumentationPagePO(page).prepareBeforeScreenshot(); 128 | > 129 | await expect(page).toHaveScreenshot('06-hint-direction__bottom.png'); | ^ 130 | 131 | await page.setViewportSize({width: 1280, height: 150}); 132 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.spec.ts:129:28

await page.setViewportSize({width: 1280, height: 150});

await expect(page).toHaveScreenshot('06-hint-direction__left.png');
});
});
6 changes: 5 additions & 1 deletion projects/demo/src/modules/components/abstract/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {AbstractControl} from '@angular/forms';
import type {
TuiDropdownAlign,
TuiDropdownWidth,
TuiHintDirection,
TuiSizeL,
TuiSizeS,
TuiVerticalDirection,
Expand Down Expand Up @@ -34,7 +35,10 @@ export abstract class AbstractExampleTuiControl

public readonly hintContentVariants: readonly string[] = ['', 'Some content'];

public readonly hintDirectionVariants = TUI_HINT_DIRECTIONS;
public readonly hintDirectionVariants = [
...TUI_HINT_DIRECTIONS,
['bottom', 'left'] satisfies TuiHintDirection[],
];

public readonly hintAppearanceVariants = ['', 'error', 'dark'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h6 class="tui-text_h6">
<ng-template
documentationPropertyMode="input"
documentationPropertyName="tuiHintDirection"
documentationPropertyType="TuiHintDirection"
documentationPropertyType="TuiHintDirection | TuiHintDirection[]"
[documentationPropertyValues]="documentedComponent.hintDirectionVariants"
[(documentationPropertyValue)]="documentedComponent.hintDirection"
>
Expand Down
6 changes: 5 additions & 1 deletion projects/demo/src/modules/components/abstract/hint.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import type {TuiHintDirection} from '@taiga-ui/core';
import {TUI_HINT_DIRECTIONS} from '@taiga-ui/core';

export abstract class AbstractExampleTuiHint {
public readonly appearanceVariants = ['', 'error', 'dark'];

public appearance = this.appearanceVariants[0]!;

public readonly directionVariants = TUI_HINT_DIRECTIONS;
public readonly directionVariants = [
...TUI_HINT_DIRECTIONS,
['bottom', 'left'] satisfies TuiHintDirection[],
];

public direction = this.directionVariants[0]!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h6 class="tui-text_h6">
<ng-template
documentationPropertyMode="input"
documentationPropertyName="tuiHintDirection"
documentationPropertyType="TuiHintDirection"
documentationPropertyType="TuiHintDirection | TuiHintDirection[]"
[documentationPropertyValues]="directionVariants"
[(documentationPropertyValue)]="documentedComponent.direction"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TuiDocDocumentation,
TuiDocDocumentationPropertyConnector,
} from '@taiga-ui/addon-doc';
import type {TuiHintDirection} from '@taiga-ui/core';
import {TUI_HINT_DIRECTIONS} from '@taiga-ui/core';

import {ABSTRACT_PROPS_ACCESSOR} from '../abstract-props-accessor';
Expand Down Expand Up @@ -35,7 +36,11 @@ import {TextfieldControllerDocumentation} from '../textfield-controller-document
})
export class InheritedDocumentation {
protected readonly booleanVariants: readonly boolean[] = [false, true];
protected readonly directionVariants = TUI_HINT_DIRECTIONS;
protected readonly directionVariants = [
...TUI_HINT_DIRECTIONS,
['bottom', 'left'] satisfies TuiHintDirection[],
];

protected readonly appearanceVariants = ['', 'error', 'dark'];
protected readonly documentedComponent = inject(ABSTRACT_PROPS_ACCESSOR);

Expand Down
Loading