MudBlazor/MudBlazor

Allow setting a static ErrorId on MudFormComponent for testing

已关闭

#6,274 创建于 2023年2月3日

 (0 条评论) (0 个反应) (0 位负责人)C# (1,631 个派生)batch import
enhancementgood first issue

仓库指标

星标
 (10,394 个星标)
PR 合并指标
 (平均合并 6天 6小时) (30 天内合并 108 个 PR)

描述

Feature request type

Enhance component

Component name

MudFormComponent

Is your feature request related to a problem?

We have a testing team that simulates clicks on the page to check the user path, while searching for the elements themselves by their Id. The same goes for searching for error messages and other items. Like:

...
    private IWebElement SnackbarElement => WebDriver.FindElement(By.CssSelector(TestSettings.Settings.SnackbarSelector));
...
    public bool CheckErrorMessageExists(string message)
    {
        return SnackbarElement.Text.Contains(message);
    }

Now an ErrorId is generated after each error, which forces the testing team to first write a check for the presence of an attribute on the input field, and then search for an element with this ID. With my changes, we ourselves set this ID and in the test it will be possible to immediately search the page.

The change will not affect those who use the attribute interception method.

Describe the solution you'd like

We will save ErrorId, passed by parameter and generete new if it`s not.

if(HasErrors && ErrorId is null)
{
    ErrorId = Guid.NewGuid().ToString();
}

Have you seen this feature anywhere else?

No response

Describe alternatives you've considered

No response

Pull Request

  • I would like to do a Pull Request

Code of Conduct

  • I agree to follow this project's Code of Conduct

贡献者指南