Move generic work item tests out of issue_detail_spec
What does this MR do?
This MR moves four tests out of issue_detail_spec.rb and into work_item_detail_spec.rb. It is part of work item #1427.
project_issue_path now shows the work item detail page. The same Vue components render for every work item type. Four tests in issue_detail_spec.rb check behaviour that applies to all work items, but they only run against the issue path. This MR moves them to the work item spec, so they cover the work item page directly.
These tests move:
renders gl-emoji tagshows checklist item actions ellipsis button when hovering over the task list item, but not within a tableencodes the description to prevent xss issuesshows the issue, for a work item that a deleted user edited
Two tests stay in issue_detail_spec.rb. Both are specific to incidents: the permission check for a non-member author, and the route change when the type changes from incident to issue.
This is not an MSW migration. These tests check server rendering and must stay in Capybara.
Decisions
The work item puts the first three tests in the 'work items description' shared example. This MR puts them in work_item_detail_spec.rb instead. The shared example has three callers, so it would run each test three times and add Capybara runtime. The goal of the epic is to cut Capybara runtime, so one run of each test is better.
Each moved test gets its own context that overrides let(:work_item) with the description it needs. The outer before hook then visits the right page. There is no second sign_in and no second visit.
The deleted-user test creates its own work item. It changes the title through the UI, so it must not change the shared let_it_be work item.
RSpec/BeforeAllRoleAssignment does not allow project.add_developer in a before hook here. The membership moves to the factory call, create(:user, developer_of: project).
How to test
bundle exec rspec spec/features/work_items/detail/work_item_detail_spec.rb spec/features/work_items/issues/issue_detail_spec.rbThe four moved tests pass. One test that stays in issue_detail_spec.rb fails
locally: "routes the user to the issue details page when the issue_type is set
to issue". It fails with Condition not met: JS requests complete. The same test
fails the same way on master without this change, so it is not caused by this
MR. That test uses wait_for_requests, which the testing guide does not allow
any more.
References
- Work item: https://gitlab.com/gitlab-org/plan-stage/plan-engineering/-/work_items/1427
- Epic: https://gitlab.com/groups/gitlab-org/plan-stage/-/work_items/475