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

fix(core): fix custom hint #9776

Merged
merged 1 commit into from
Nov 20, 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
9 changes: 7 additions & 2 deletions projects/core/directives/hint/hint-unstyled.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {WritableSignal} from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
Expand All @@ -8,6 +9,7 @@ import {
import type {TuiContext} from '@taiga-ui/cdk/types';
import {tuiParentAnimation} from '@taiga-ui/core/animations';
import type {TuiPortalItem} from '@taiga-ui/core/types';
import type {PolymorpheusContent} from '@taiga-ui/polymorpheus';
import {
injectContext,
PolymorpheusComponent,
Expand All @@ -19,13 +21,16 @@ import {TuiHintDirective} from './hint.directive';
@Component({
standalone: true,
imports: [PolymorpheusOutlet],
template: '<ng-container *polymorpheusOutlet="context.$implicit.content" />',
template: '<ng-container *polymorpheusOutlet="context.$implicit.content()" />',
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [tuiParentAnimation],
host: {'[@tuiParentAnimation]': ''},
})
export class TuiHintUnstyledComponent {
protected readonly context = injectContext<TuiContext<TuiPortalItem>>();
protected readonly context =
injectContext<
TuiContext<TuiPortalItem & {content: WritableSignal<PolymorpheusContent>}>
>();
}

@Directive({
Expand Down
9 changes: 9 additions & 0 deletions projects/demo-playwright/tests/core/hint/hint.pw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
directions.forEach((direction, directionIndex) => {
[256, 1280].forEach((width) => {
test(`tuiHintDirection is ${direction}, viewport width is ${width}px`, async ({
page,

Check warning on line 36 in projects/demo-playwright/tests/core/hint/hint.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected use of the `.skip()` annotation
}) => {
await page.setViewportSize({width, height: 300});
await tuiGoto(
Expand Down Expand Up @@ -132,4 +132,13 @@

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

test('TuiHint customizing works', async ({page}) => {
await tuiGoto(page, DemoRoute.Hint);
const example = new TuiDocumentationPagePO(page).getExample('#customizing');

await example.locator('tui-avatar').hover();

await expect(example).toHaveScreenshot('07-hint.png');
});

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

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 2 of 9

[chromium] › tests/core/hint/hint.pw.spec.ts:137:9 › TuiHint › TuiHint customizing works

1) [chromium] › tests/core/hint/hint.pw.spec.ts:137:9 › TuiHint › TuiHint customizing works ────── Error: Screenshot comparison failed: 54592 pixels (ratio 0.20 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.pw.spec.ts-snapshots/07-hint-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint.pw-TuiHint-TuiHint-customizing-works-chromium/07-hint-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint.pw-TuiHint-TuiHint-customizing-works-chromium/07-hint-diff.png Call log: - expect.toHaveScreenshot(07-hint.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#customizing [automation-id="tui-doc-example"]') - locator resolved to <div _ngcontent-ng-c644840128="" automation-id="tui-doc-example" class="t-demo ng-star-inserted">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - 54592 pixels (ratio 0.20 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#customizing [automation-id="tui-doc-example"]') - locator resolved to <div _ngcontent-ng-c644840128="" automation-id="tui-doc-example" class="t-demo ng-star-inserted">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - captured a stable screenshot - 54592 pixels (ratio 0.20 of all image pixels) are different. 141 | await example.locator('tui-avatar').hover(); 142 | > 143 | await expect(example).toHaveScreenshot('07-hint.png'); | ^ 144 | }); 145 | }); 146 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.pw.spec.ts:143:31

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

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 2 of 9

[chromium] › tests/core/hint/hint.pw.spec.ts:137:9 › TuiHint › TuiHint customizing works

1) [chromium] › tests/core/hint/hint.pw.spec.ts:137:9 › TuiHint › TuiHint customizing works ────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 54592 pixels (ratio 0.20 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.pw.spec.ts-snapshots/07-hint-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint.pw-TuiHint-TuiHint-customizing-works-chromium-retry1/07-hint-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint.pw-TuiHint-TuiHint-customizing-works-chromium-retry1/07-hint-diff.png Call log: - expect.toHaveScreenshot(07-hint.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#customizing [automation-id="tui-doc-example"]') - locator resolved to <div _ngcontent-ng-c644840128="" automation-id="tui-doc-example" class="t-demo ng-star-inserted">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - 54592 pixels (ratio 0.20 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#customizing [automation-id="tui-doc-example"]') - locator resolved to <div _ngcontent-ng-c644840128="" automation-id="tui-doc-example" class="t-demo ng-star-inserted">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - captured a stable screenshot - 54592 pixels (ratio 0.20 of all image pixels) are different. 141 | await example.locator('tui-avatar').hover(); 142 | > 143 | await expect(example).toHaveScreenshot('07-hint.png'); | ^ 144 | }); 145 | }); 146 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.pw.spec.ts:143:31

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

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 2 of 9

[chromium] › tests/core/hint/hint.pw.spec.ts:137:9 › TuiHint › TuiHint customizing works

1) [chromium] › tests/core/hint/hint.pw.spec.ts:137:9 › TuiHint › TuiHint customizing works ────── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 54592 pixels (ratio 0.20 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/core/hint/hint.pw.spec.ts-snapshots/07-hint-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint.pw-TuiHint-TuiHint-customizing-works-chromium-retry2/07-hint-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-core-hint-hint.pw-TuiHint-TuiHint-customizing-works-chromium-retry2/07-hint-diff.png Call log: - expect.toHaveScreenshot(07-hint.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#customizing [automation-id="tui-doc-example"]') - locator resolved to <div _ngcontent-ng-c644840128="" automation-id="tui-doc-example" class="t-demo ng-star-inserted">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - 54592 pixels (ratio 0.20 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#customizing [automation-id="tui-doc-example"]') - locator resolved to <div _ngcontent-ng-c644840128="" automation-id="tui-doc-example" class="t-demo ng-star-inserted">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - captured a stable screenshot - 54592 pixels (ratio 0.20 of all image pixels) are different. 141 | await example.locator('tui-avatar').hover(); 142 | > 143 | await expect(example).toHaveScreenshot('07-hint.png'); | ^ 144 | }); 145 | }); 146 | at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/core/hint/hint.pw.spec.ts:143:31
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<tui-avatar
size="l"
tuiHint
tuiHintDirection="right"
[style.background]="'❤' | tuiAutoColor"
>
Expand Down
Loading