Skip to content

Commit

Permalink
fix(core): fix custom hint
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin committed Nov 18, 2024
1 parent 3b978be commit ba1d549
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
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 @@ -132,4 +132,13 @@ test.describe('TuiHint', () => {

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

0 comments on commit ba1d549

Please sign in to comment.