未开启内容审核的情况下,加载project tree content 无需请求 content_blocked_state 接口
Problem
目前有一个feature测试失败了 https://jihulab.com/gitlab-cn/gitlab/-/jobs/2994651 ,这个测试失败的原因是在 JH 版本中, project 详情页加载目录树的逻辑是会先去请求 content_blocked_state 接口,然后再去加载目录树,而这个测试中,执行了 Gitlab::Testing::RobotsBlockerMiddleware.block_requests!
,这会使 content_blocked_state 接口返回 503,会阻塞后续的页面渲染,导致测试中无法获取到 readme,测试失败。
# ./spec/features/projects/show/user_sees_readme_spec.rb
context 'obeying robots.txt' do
before do
Gitlab::Testing::RobotsBlockerMiddleware.block_requests!
end
after do
Gitlab::Testing::RobotsBlockerMiddleware.allow_requests!
end
# For example, see this regression we had in
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/39520
it 'does not block the requests necessary to load the project README', :js do
visit project_path(project)
wait_for_requests
page.within('.readme-holder') do
expect(page).to have_content 'testme'
end
end
end
proposal
页面加载前,后端通过gon向前端传递信息是否开启 content_valicaiton , 前端根据这个值来决定是否在加载 project 详情页的时候去请求 content_blocked_state 接口