Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
63d37c55
提交
63d37c55
编辑于
3 years ago
作者:
Tomislav Nikić
提交者:
Amy Qualls
3 years ago
浏览文件
操作
下载
补丁
差异文件
Handling Selectors when testing Feature Flags
上级
32b98f5e
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
1
隐藏空白变更内容
行内
左右并排
显示
1 个更改的文件
doc/development/testing_guide/end_to_end/feature_flags.md
+51
-0
51 个添加, 0 个删除
doc/development/testing_guide/end_to_end/feature_flags.md
有
51 个添加
和
0 个删除
doc/development/testing_guide/end_to_end/feature_flags.md
+
51
−
0
浏览文件 @
63d37c55
...
@@ -67,6 +67,57 @@ If no scope is provided, the feature flag is set instance-wide:
...
@@ -67,6 +67,57 @@ If no scope is provided, the feature flag is set instance-wide:
Runtime
::
Feature
.
enable
(
:feature_flag_name
)
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
## 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
It's also possible to run an entire scenario with a feature flag enabled, without having to edit
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录