Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change tests to use web.ui.FormLayout where applicable #256

Open
IwanVosloo opened this issue Dec 5, 2019 · 0 comments
Open

Change tests to use web.ui.FormLayout where applicable #256

IwanVosloo opened this issue Dec 5, 2019 · 0 comments

Comments

@IwanVosloo
Copy link
Member

In tests, we like to use methods that refer to what you see on the screen instead of having to refer to HTML-level things, such as IDs etc.

So, if you want to refer to an Input, you'd like to refer to it as XPath.input_labelled('Some label'), for example. However, for that to work you need not only the Input in your HTML, but also a Label element, with its for= attribute correctly set.

This means that in basic tests (tests that are not testing bootstrap-styled widgets) we'll have to add a label and an input for the above to work.

In current test code, we might still refer to things by actually giving an XPath string. We may also add the Input and Label etc.

In 5.0 we added web.ui.FormLayout which you can use to do the above tasks quicker. So, instead of doing:

an_input = TextInput(view, field)
form.add_child(Label(view, for_input=an_input))
form.add_child(an_input)

You can do:

form.use_layout(FormLayout())
form.layout.add_input(TextInput(view, field))

That will also add a validation error message if necessary.

This task is to go hunt down places where we use inputs in test code and make them consistently use this new layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant