Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
63d37c55
Commit
63d37c55
authored
Dec 14, 2021
by
Tomislav Nikić
Committed by
Amy Qualls
Dec 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handling Selectors when testing Feature Flags
parent
32b98f5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
doc/development/testing_guide/end_to_end/feature_flags.md
doc/development/testing_guide/end_to_end/feature_flags.md
+51
-0
No files found.
doc/development/testing_guide/end_to_end/feature_flags.md
View file @
63d37c55
...
...
@@ -67,6 +67,57 @@ If no scope is provided, the feature flag is set instance-wide:
Runtime
::
Feature
.
enable
(
:feature_flag_name
)
```
## Working with selectors
A new feature often replaces a
`vue`
component or a
`haml`
file with a new one.
In most cases, the new file or component is accessible only with a feature flag.
This approach becomes problematic when tests must pass both with, and without,
the feature flag enabled. To ensure tests pass in both scenarios:
1.
Create another selector inside the new component or file.
1.
Give it the same name as the old one.
Selectors are connected to a specific frontend file in the
[
page object
](
page_objects.md
)
,
and checked for availability inside our
`qa:selectors`
test. If the mentioned selector
is missing inside that frontend file, the test fails. To ensure selectors are
available when a feature flag is enabled or disabled, add the new selector to the
[
page object
](
page_objects.md
)
, leaving the old selector in place.
The test uses the correct selector and still detects missing selectors.
If a new feature changes an existing frontend file that already has a selector,
you can add a new selector with the same name. However, only one of the selectors
displays on the page. You should:
1.
Disable the other with the feature flag.
1.
Add a comment in the frontend file to delete the old selector from the frontend
file and from the page object file when the feature flag is removed.
### Example before
```
ruby
# This is the link to the old file
view
'app/views/devise/passwords/edit.html.haml'
do
# The new selector should have the same name
element
:password_field
...
end
```
### Example after
```
ruby
view
'app/views/devise/passwords/edit.html.haml'
do
element
:password_field
...
end
# Now it can verify the selector is available
view
'app/views/devise/passwords/new_edit_behind_ff.html.haml'
do
# The selector has the same name
element
:password_field
end
```
## Running a scenario with a feature flag enabled
It's also possible to run an entire scenario with a feature flag enabled, without having to edit
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment