Skip to content
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 src/Controls.Extensions/Controls.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Title>Playwright.ReactUI.Controls.Extensions</Title>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<Version>3.1.0</Version>
<Version>3.1.1</Version>
<Authors>Evgeniy Ivanov</Authors>
<Product>Playwright.ReactUI.Controls.Extensions</Product>
<PackageReadmeFile>README-Controls.Extensions.md</PackageReadmeFile>
Expand Down
2 changes: 1 addition & 1 deletion src/Controls.Extensions/FxInputExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 5 additions & 2 deletions src/Controls/Assertions/FxInputAssertionsV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Title>Playwright.ReactUI.Controls</Title>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<Version>3.1.0</Version>
<Version>3.1.1</Version>
<Authors>Evgeniy Ivanov</Authors>
<Product>Playwright.ReactUI.Controls</Product>
<PackageReadmeFile>README-Controls.md</PackageReadmeFile>
Expand Down
8 changes: 2 additions & 6 deletions src/Controls/Dropdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,12 @@ private async Task<ILocator> GetMenuItemsLocatorAsync()
}

private async Task<ILocator> 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);
}
}
8 changes: 2 additions & 6 deletions src/Controls/DropdownMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,13 @@ private async Task<ILocator> GetMenuItemsLocatorAsync()
}

private async Task<ILocator> 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)
Expand Down
8 changes: 4 additions & 4 deletions src/Controls/Kebab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ public async Task<bool> IsDisabledAsync(LocatorGetAttributeOptions? options = de
public async Task<bool> 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)
Expand Down
8 changes: 4 additions & 4 deletions src/Controls/Paging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Page>(
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<Page> Pages { get; }
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Controls/DateInputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Controls/FxInputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 8 additions & 8 deletions src/Tests/Controls/KebabTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions src/Tests/Controls/PagingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TimeoutException>(() => paging.GoToPageAsync(6));
}

Expand Down Expand Up @@ -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);

Expand Down
91 changes: 46 additions & 45 deletions src/web/stories/fxinput.stories.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Gapped>
<FxInput
{...props}
data-tid={FxInputTestIds.FxInputId}
data-attribute-without-value={''}
auto={auto}
value={value}
onValueChange={handleValueChange}
onRestore={handleRestore}
/>
</Gapped>
);
};

const meta: Meta<typeof FxInput> = {
title: "FxInput",
component: FxInput,
title: 'FxInput',
component: FxInputTemplate,
};
export default meta;

type Story = StoryObj<typeof meta>;

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 (
<Gapped>
<FxInput
{...args}
data-tid={FxInputTestIds.FxInputId}
data-attribute-without-value={""}
auto={auto}
value={value}
onValueChange={handleValueChange}
onRestore={handleRestore}
/>
</Gapped>
);
},
};
export const Default: Story = {};

export const Disabled: Story = {
...Default,
Expand All @@ -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);
Expand All @@ -79,7 +80,7 @@ export const Filled: Story = {

function handleRestore() {
setAuto(true);
setValue("auto");
setValue('auto');
}

return (
Expand All @@ -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 (
Expand All @@ -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);
Expand All @@ -135,7 +136,7 @@ export const Hidden: Story = {

function handleRestore() {
setAuto(true);
setValue("auto");
setValue('auto');
}

useEffect(() => {
Expand Down Expand Up @@ -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);
Expand All @@ -174,7 +175,7 @@ export const WithTooltip: Story = {

function handleRestore() {
setAuto(true);
setValue("auto");
setValue('auto');
}
return (
<Gapped>
Expand Down
Loading