-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(addon-mobile):
DropdownMobile
is not compatible with `DropdownH…
…over` (#9736)
- Loading branch information
1 parent
91af99f
commit b57149a
Showing
7 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
projects/demo-playwright/tests/kit/dropdown-hover/dropdown-hover.pw.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import {DemoRoute} from '@demo/routes'; | ||
import { | ||
TuiDocumentationPagePO, | ||
tuiGoto, | ||
TuiMobileDropdownPO, | ||
} from '@demo-playwright/utils'; | ||
import type {Locator} from '@playwright/test'; | ||
import {expect, test} from '@playwright/test'; | ||
|
||
import { | ||
TUI_PLAYWRIGHT_MOBILE_USER_AGENT, | ||
TUI_PLAYWRIGHT_MOBILE_VIEWPORT_HEIGHT, | ||
TUI_PLAYWRIGHT_MOBILE_VIEWPORT_WIDTH, | ||
} from '../../../playwright.options'; | ||
|
||
const {describe, beforeEach} = test; | ||
|
||
test.describe('DropdownHover', () => { | ||
describe('Examples', () => { | ||
beforeEach(async ({page}) => { | ||
await tuiGoto(page, DemoRoute.DropdownHover); | ||
}); | ||
|
||
describe('With DropdownMobile', () => { | ||
let example!: Locator; | ||
let mobileCalendar: TuiMobileDropdownPO; | ||
|
||
test.use({ | ||
viewport: { | ||
width: TUI_PLAYWRIGHT_MOBILE_VIEWPORT_WIDTH, | ||
height: TUI_PLAYWRIGHT_MOBILE_VIEWPORT_HEIGHT, | ||
}, | ||
userAgent: TUI_PLAYWRIGHT_MOBILE_USER_AGENT, | ||
isMobile: true, | ||
}); | ||
|
||
beforeEach(({page}) => { | ||
example = new TuiDocumentationPagePO(page).getExample('#dropdown-mobile'); | ||
mobileCalendar = new TuiMobileDropdownPO( | ||
page.locator('tui-dropdown-mobile'), | ||
); | ||
}); | ||
|
||
test('Opens mobile version of dropdown on the 1st time click', async ({ | ||
page, | ||
}) => { | ||
await example.locator('button').click(); | ||
|
||
await expect(page.locator('tui-dropdown')).not.toBeAttached(); | ||
await expect(page.locator('tui-dropdown-mobile')).toBeVisible(); | ||
await expect(page).toHaveScreenshot( | ||
'mobile-dropdown-1st-time-time-click.png', | ||
); | ||
}); | ||
|
||
test('Closes dropdown on click on overlay', async ({page}) => { | ||
await example.locator('button').click(); | ||
|
||
await expect(page.locator('tui-dropdown-mobile')).toBeVisible(); | ||
|
||
await mobileCalendar.overlay.click(); | ||
|
||
await expect(page.locator('tui-dropdown-mobile')).not.toBeAttached(); | ||
}); | ||
|
||
test('Opens mobile version of dropdown on the 2nd time click', async ({ | ||
page, | ||
}) => { | ||
await example.locator('button').click(); | ||
await mobileCalendar.overlay.click(); | ||
await example.locator('button').click(); | ||
|
||
await expect(page.locator('tui-dropdown-mobile')).toBeVisible(); | ||
|
||
await expect(page).toHaveScreenshot( | ||
'mobile-dropdown-2nd-time-time-click.png', | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
projects/demo-playwright/utils/page-objects/mobile-dropdown.po.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type {Locator} from '@playwright/test'; | ||
|
||
export class TuiMobileDropdownPO { | ||
public overlay = this.host.locator('.t-filler'); | ||
|
||
constructor(private readonly host: Locator) {} | ||
} |
43 changes: 43 additions & 0 deletions
43
projects/demo/src/modules/directives/dropdown-hover/examples/5/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<button | ||
appearance="outline-grayscale" | ||
iconStart="@tui.ellipsis" | ||
tuiDropdownHover | ||
tuiDropdownMobile="Contact Us" | ||
tuiIconButton | ||
type="button" | ||
[tuiDropdown]="dropdown" | ||
> | ||
More | ||
</button> | ||
|
||
<ng-template #dropdown> | ||
<tui-data-list> | ||
<a | ||
href="https://github.com/taiga-family/taiga-ui" | ||
iconStart="assets/images/github.svg" | ||
rel="noreferrer" | ||
target="_blank" | ||
tuiOption | ||
> | ||
GitHub | ||
</a> | ||
<a | ||
href="https://t.me/taiga_ui" | ||
iconStart="assets/icons/telegram.svg" | ||
rel="noreferrer" | ||
target="_blank" | ||
tuiOption | ||
> | ||
Telegram | ||
</a> | ||
<a | ||
href="https://discord.gg/zrB2EdJjEy" | ||
iconStart="assets/icons/discord.svg" | ||
rel="noreferrer" | ||
target="_blank" | ||
tuiOption | ||
> | ||
Discord | ||
</a> | ||
</tui-data-list> | ||
</ng-template> |
15 changes: 15 additions & 0 deletions
15
projects/demo/src/modules/directives/dropdown-hover/examples/5/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiDropdownMobile} from '@taiga-ui/addon-mobile'; | ||
import {TuiButton, TuiDataList, TuiDropdown} from '@taiga-ui/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [TuiButton, TuiDataList, TuiDropdown, TuiDropdownMobile], | ||
templateUrl: './index.html', | ||
styles: ['[tuiOption] {justify-content: flex-start}'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters