diff --git a/src/Controls.Extensions/Controls.Extensions.csproj b/src/Controls.Extensions/Controls.Extensions.csproj index 651b736..205b688 100644 --- a/src/Controls.Extensions/Controls.Extensions.csproj +++ b/src/Controls.Extensions/Controls.Extensions.csproj @@ -23,7 +23,7 @@ Playwright.ReactUI.Controls.Extensions 1.0.0.0 1.0.0 - 3.1.0 + 3.1.1 Evgeniy Ivanov Playwright.ReactUI.Controls.Extensions README-Controls.Extensions.md diff --git a/src/Controls.Extensions/FxInputExtensions.cs b/src/Controls.Extensions/FxInputExtensions.cs index 8724d7c..df75a18 100644 --- a/src/Controls.Extensions/FxInputExtensions.cs +++ b/src/Controls.Extensions/FxInputExtensions.cs @@ -59,7 +59,7 @@ public static async Task AppendTextAsync( public static async Task WaitToBeAutoAsync( this FxInput fxInput, - LocatorAssertionsToBeVisibleOptions? options = default + LocatorAssertionsToBeHiddenOptions? options = default ) => await fxInput.ExpectV2().ToBeAutoAsync(options).ConfigureAwait(false); public static async Task WaitNotToBeAutoAsync( diff --git a/src/Controls/Assertions/FxInputAssertionsV2.cs b/src/Controls/Assertions/FxInputAssertionsV2.cs index c3b2105..118ee8d 100644 --- a/src/Controls/Assertions/FxInputAssertionsV2.cs +++ b/src/Controls/Assertions/FxInputAssertionsV2.cs @@ -38,8 +38,11 @@ public async Task ToBeFocusedAsync(LocatorAssertionsToBeFocusedOptions? options public async Task NotToBeFocusedAsync(LocatorAssertionsToBeFocusedOptions? options = default) => await fxInput.InputLocator.Expect().Not.ToBeFocusedAsync(options).ConfigureAwait(false); - public async Task ToBeAutoAsync(LocatorAssertionsToBeVisibleOptions? options = default) - => await fxInput.AutoButtonLocator.Expect().Not.ToBeVisibleAsync(options).ConfigureAwait(false); + public async Task ToBeAutoAsync(LocatorAssertionsToBeHiddenOptions? options = default) + { + await fxInput.WaitForAsync().ConfigureAwait(false); + await fxInput.AutoButtonLocator.Expect().ToBeHiddenAsync(options).ConfigureAwait(false); + } public async Task NotToBeAutoAsync(LocatorAssertionsToBeVisibleOptions? options = default) => await fxInput.AutoButtonLocator.Expect().ToBeVisibleAsync(options).ConfigureAwait(false); diff --git a/src/Controls/Controls.csproj b/src/Controls/Controls.csproj index b3887c7..572ed4c 100644 --- a/src/Controls/Controls.csproj +++ b/src/Controls/Controls.csproj @@ -24,7 +24,7 @@ Playwright.ReactUI.Controls 1.0.0.0 1.0.0 - 3.1.0 + 3.1.1 Evgeniy Ivanov Playwright.ReactUI.Controls README-Controls.md diff --git a/src/Controls/Dropdown.cs b/src/Controls/Dropdown.cs index f234544..143faf9 100644 --- a/src/Controls/Dropdown.cs +++ b/src/Controls/Dropdown.cs @@ -127,16 +127,12 @@ private async Task GetMenuItemsLocatorAsync() } private async Task GetPortalContainerAsync() - { - await OpenDropdownIfNeededAsync().ConfigureAwait(false); - return await portal.GetContainerAsync().ConfigureAwait(false); - } - - private async Task OpenDropdownIfNeededAsync() { if (!await IsMenuOpenedAsync().ConfigureAwait(false)) { await ButtonLocator.ClickAsync().ConfigureAwait(false); } + + return await portal.GetContainerAsync().ConfigureAwait(false); } } \ No newline at end of file diff --git a/src/Controls/DropdownMenu.cs b/src/Controls/DropdownMenu.cs index f6976b8..8620bc8 100644 --- a/src/Controls/DropdownMenu.cs +++ b/src/Controls/DropdownMenu.cs @@ -137,17 +137,13 @@ private async Task GetMenuItemsLocatorAsync() } private async Task GetPortalContainerAsync() - { - await OpenDropdownIfNeededAsync().ConfigureAwait(false); - return await portal.GetContainerAsync().ConfigureAwait(false); - } - - private async Task OpenDropdownIfNeededAsync() { if (!await IsMenuOpenedAsync().ConfigureAwait(false)) { await ButtonLocator.ClickAsync().ConfigureAwait(false); } + + return await portal.GetContainerAsync().ConfigureAwait(false); } private async Task SelectFirstByTextAsync(ILocator item, bool isMenuClosedAfterSelect = true) diff --git a/src/Controls/Kebab.cs b/src/Controls/Kebab.cs index 307cc2f..ec4fb5d 100644 --- a/src/Controls/Kebab.cs +++ b/src/Controls/Kebab.cs @@ -27,16 +27,16 @@ public async Task IsDisabledAsync(LocatorGetAttributeOptions? options = de public async Task IsMenuOpenedAsync() => await portal.IsVisibleAsync().ConfigureAwait(false); - public async Task SelectByTextAsync(string text, LocatorClickOptions? options = default) + public async Task SelectFirstByTextAsync(string text, LocatorClickOptions? options = default) { var item = await GetMenuItemsLocatorAsync(text).ConfigureAwait(false); - await item.ClickAsync(options).ConfigureAwait(false); + await item.First.ClickAsync(options).ConfigureAwait(false); } - public async Task SelectByTextAsync(Regex regex, LocatorClickOptions? options = default) + public async Task SelectFirstByTextAsync(Regex regex, LocatorClickOptions? options = default) { var item = await GetMenuItemsLocatorAsync(regex).ConfigureAwait(false); - await item.ClickAsync(options).ConfigureAwait(false); + await item.First.ClickAsync(options).ConfigureAwait(false); } public async Task SelectByIndexAsync(int index, LocatorClickOptions? options = default) diff --git a/src/Controls/Paging.cs b/src/Controls/Paging.cs index 08a6d14..4c6d686 100644 --- a/src/Controls/Paging.cs +++ b/src/Controls/Paging.cs @@ -11,14 +11,14 @@ public class Paging : ControlBase { private readonly Label nextPage; - public Paging(ILocator context) - : base(context) + public Paging(ILocator rootLocator) + : base(rootLocator) { Pages = new ControlList( - context, + rootLocator, locator => locator.Locator("[data-tid='Paging__pageLinkWrapper']"), x => new Page(x)); - nextPage = new Label(context.Locator("[data-tid='Paging__forwardLink']")); + nextPage = new Label(rootLocator.Locator("[data-tid='Paging__forwardLink']")); } public ControlList Pages { get; } diff --git a/src/Tests/Controls/DateInputTests.cs b/src/Tests/Controls/DateInputTests.cs index b9a6f0a..916c70e 100644 --- a/src/Tests/Controls/DateInputTests.cs +++ b/src/Tests/Controls/DateInputTests.cs @@ -116,6 +116,7 @@ public async Task GetValue_Return_Empty_When_DateInput_Value_Is_Empty() public async Task Fill_New_Value() { var dateInput = await GetDateInputAsync("default").ConfigureAwait(false); + await dateInput.NativeInputLocator.Expect().ToBeEmptyAsync().ConfigureAwait(false); await dateInput.FillAsync("02.01.2024").ConfigureAwait(false); diff --git a/src/Tests/Controls/FxInputTests.cs b/src/Tests/Controls/FxInputTests.cs index 68e7b3c..69a2d49 100644 --- a/src/Tests/Controls/FxInputTests.cs +++ b/src/Tests/Controls/FxInputTests.cs @@ -64,7 +64,7 @@ public async Task IsAuto_Return_True_WHen_FxInput_In_AutoMode() } [Test] - public async Task IsAuto_Return_False_When_FxInput_In_AutoMode() + public async Task IsAuto_Return_False_When_FxInput_In_Default_Mode() { var fxInput = await GetFxInputAsync("default").ConfigureAwait(false); diff --git a/src/Tests/Controls/KebabTests.cs b/src/Tests/Controls/KebabTests.cs index 0e095da..f9ff7ce 100644 --- a/src/Tests/Controls/KebabTests.cs +++ b/src/Tests/Controls/KebabTests.cs @@ -76,29 +76,29 @@ public async Task IsMenuOpened_Return_True_When_Menu_Is_Opened() } [Test] - public async Task SelectByText() + public async Task SelectFirstByText() { var kebab = await GetKebabAsync("default").ConfigureAwait(false); var toast = new Toast(Page.GetByTestId("ToastView__root")); await toast.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Hidden }) .ConfigureAwait(false); - await kebab.SelectByTextAsync("TODO 2").ConfigureAwait(false); + await kebab.SelectFirstByTextAsync("TODO 2").ConfigureAwait(false); await toast.RootLocator.Expect().ToHaveTextAsync("Clicked TODO 2").ConfigureAwait(false); } [Test] - public async Task SelectByText_With_Regex() + public async Task SelectFirstByText_With_Regex() { var kebab = await GetKebabAsync("default").ConfigureAwait(false); var toast = new Toast(Page.GetByTestId("ToastView__root")); await toast.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Hidden }) .ConfigureAwait(false); - await kebab.SelectByTextAsync(new Regex("^TODO 2.*")).ConfigureAwait(false); + await kebab.SelectFirstByTextAsync(new Regex("^TODO.*")).ConfigureAwait(false); - await toast.RootLocator.Expect().ToHaveTextAsync("Clicked TODO 2").ConfigureAwait(false); + await toast.RootLocator.Expect().ToHaveTextAsync("Clicked TODO 1").ConfigureAwait(false); } [Test] @@ -141,13 +141,13 @@ public async Task Click() [Test] public async Task Hover() { - var dropdown = await GetKebabAsync("with-tooltip").ConfigureAwait(false); - await dropdown.WaitForAsync().ConfigureAwait(false); + var kebab = await GetKebabAsync("with-tooltip").ConfigureAwait(false); + await kebab.WaitForAsync().ConfigureAwait(false); var tooltipLocator = Page.GetByText("TooltipText"); await tooltipLocator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Hidden }) .ConfigureAwait(false); - await dropdown.HoverAsync().ConfigureAwait(false); + await kebab.HoverAsync().ConfigureAwait(false); await tooltipLocator.Expect().ToBeVisibleAsync().ConfigureAwait(false); } diff --git a/src/Tests/Controls/PagingTests.cs b/src/Tests/Controls/PagingTests.cs index 5416828..c489088 100644 --- a/src/Tests/Controls/PagingTests.cs +++ b/src/Tests/Controls/PagingTests.cs @@ -81,9 +81,7 @@ public async Task GoToPage() [Test] public async Task GoToPage_Throws_When_Page_Is_Not_Visible() { - await Page.GotoAsync(StorybookUrl.Get("paging--default")).ConfigureAwait(false); - var paging = new Paging(Page.GetByTestId("PagingId")); - + var paging = await GetPagingAsync("default").ConfigureAwait(false); Assert.ThrowsAsync(() => paging.GoToPageAsync(6)); } @@ -161,7 +159,7 @@ public async Task GoToNextPage() } [Test] - public async Task GoToNextPage_Throws_When_Current_Is_Last() + public async Task GoToNextPage_Throws_When_Current_Page_Is_Last() { var paging = await GetPagingAsync("on-last-page").ConfigureAwait(false); diff --git a/src/web/stories/fxinput.stories.tsx b/src/web/stories/fxinput.stories.tsx index 6a686c6..203d990 100644 --- a/src/web/stories/fxinput.stories.tsx +++ b/src/web/stories/fxinput.stories.tsx @@ -1,50 +1,51 @@ -import React, { useEffect, useState } from "react"; -import { FxInput, Gapped, Tooltip } from "@skbkontur/react-ui"; -import type { Meta } from "@storybook/react"; -import { type StoryObj } from "@storybook/react"; +import React, { useEffect, useState } from 'react'; +import type { FxInputProps } from '@skbkontur/react-ui'; +import { FxInput, Gapped, Tooltip } from '@skbkontur/react-ui'; +import type { Meta } from '@storybook/react'; +import { type StoryObj } from '@storybook/react'; export enum FxInputTestIds { - FxInputId = "FxInputId", + FxInputId = 'FxInputId', } +export const FxInputTemplate = (props: FxInputProps) => { + const [auto, setAuto] = useState(false); + const [value, setValue] = useState(''); + + function handleValueChange(value: string) { + setAuto(false); + setValue(value); + } + + function handleRestore() { + setAuto(true); + setValue('auto'); + } + + return ( + + + + ); +}; + const meta: Meta = { - title: "FxInput", - component: FxInput, + title: 'FxInput', + component: FxInputTemplate, }; export default meta; type Story = StoryObj; -export const Default: Story = { - render(args) { - const [auto, setAuto] = useState(false); - const [value, setValue] = useState(""); - - function handleValueChange(value: string) { - setAuto(false); - setValue(value); - } - - function handleRestore() { - setAuto(true); - setValue("auto"); - } - - return ( - - - - ); - }, -}; +export const Default: Story = {}; export const Disabled: Story = { ...Default, @@ -70,7 +71,7 @@ export const Warning: Story = { export const Filled: Story = { render: () => { const [auto, setAuto] = useState(false); - const [value, setValue] = useState("TODO"); + const [value, setValue] = useState('TODO'); function handleValueChange(value: string) { setAuto(false); @@ -79,7 +80,7 @@ export const Filled: Story = { function handleRestore() { setAuto(true); - setValue("auto"); + setValue('auto'); } return ( @@ -98,14 +99,14 @@ export const Filled: Story = { export const Auto: Story = { render: () => { - const [value, setValue] = useState("TODO"); + const [value, setValue] = useState('TODO'); function handleValueChange(value: string) { setValue(value); } function handleRestore() { - setValue("auto"); + setValue('auto'); } return ( @@ -126,7 +127,7 @@ export const Hidden: Story = { render: () => { const [isVisible, setIsVisible] = useState(true); const [auto, setAuto] = useState(false); - const [value, setValue] = useState(""); + const [value, setValue] = useState(''); function handleValueChange(value: string) { setAuto(false); @@ -135,7 +136,7 @@ export const Hidden: Story = { function handleRestore() { setAuto(true); - setValue("auto"); + setValue('auto'); } useEffect(() => { @@ -165,7 +166,7 @@ export const Hidden: Story = { export const WithTooltip: Story = { render: () => { const [auto, setAuto] = useState(false); - const [value, setValue] = useState(""); + const [value, setValue] = useState(''); function handleValueChange(value: string) { setAuto(false); @@ -174,7 +175,7 @@ export const WithTooltip: Story = { function handleRestore() { setAuto(true); - setValue("auto"); + setValue('auto'); } return (