Commit 7bcd30d6 authored by Felipe Artur's avatar Felipe Artur Committed by Michael Kozono

Add route for test cases show page

parent 0a7ce52e
......@@ -29,6 +29,7 @@ export default {
},
mounted() {
window.addEventListener('resize', this.handleWindowResize);
this.updatePageContainerClass();
},
beforeDestroy() {
window.removeEventListener('resize', this.handleWindowResize);
......
import initSidebarBundle from 'ee/sidebar/sidebar_bundle';
import trackShowInviteMemberLink from 'ee/projects/track_invite_members';
import initTestCaseShow from 'ee/test_case_show/test_case_show_bundle';
import { parseIssuableData } from '~/issue_show/utils/parse_data';
import initRelatedIssues from '~/related_issues';
import initShow from '~/pages/projects/issues/show';
import UserCallout from '~/user_callout';
import { IssuableType } from '~/issuable_show/constants';
const { issueType } = parseIssuableData();
initShow();
if (issueType === IssuableType.TestCase) {
initTestCaseShow({
mountPointSelector: '#js-issuable-app',
});
}
if (gon.features && !gon.features.vueIssuableSidebar) {
initSidebarBundle();
}
......
import initTestCaseShow from 'ee/test_case_show/test_case_show_bundle';
initTestCaseShow({
mountPointSelector: '#js-issuable-app',
});
......@@ -26,9 +26,29 @@ class Projects::Quality::TestCasesController < Projects::ApplicationController
end
end
def show
@test_case = test_cases_finder
.execute
.iid_in(params[:id])
.without_order
.first
serializer = IssueSerializer.new(current_user: current_user, project: project)
@issuable_sidebar = serializer.represent(@test_case, serializer: 'sidebar')
respond_to do |format|
format.html
end
end
private
def verify_test_cases_flag!
render_404 unless Feature.enabled?(:quality_test_cases, project)
end
def test_cases_finder
IssuesFinder.new(current_user, project_id: project.id, issue_types: :test_case)
end
end
......@@ -9,5 +9,11 @@ module EE
issuable_sla&.due_at
end
def web_url
return super unless issue.issue_type == 'test_case'
project_quality_test_case_url(issue.project, issue)
end
end
end
- if @issue.issue_type == 'test_case'
= render_if_exists 'projects/quality/test_cases/show'
- else
= render_ce 'projects/issues/show'
- @content_class = "limit-container-width" unless fluid_layout
- add_to_breadcrumbs _('Test Cases'), project_quality_test_cases_path(@project)
- breadcrumb_title @issue.to_reference
- breadcrumb_title @test_case.to_reference
- page_title "#{@issue.title} (#{@issue.to_reference})", _('Test Cases')
- page_description @issue.description
- page_title "#{@test_case.title} (#{@test_case.to_reference})", _('Test Cases')
- page_description @test_case.description
#js-issuable-app{ data: { initial: issuable_initial_data(@issue).to_json,
#js-issuable-app{ data: { initial: issuable_initial_data(@test_case).to_json,
can_edit_test_case: can?(current_user, :admin_issue, @project).to_s,
can_move_test_case: @issuable_sidebar.dig(:current_user, :can_move).to_s,
description_preview_path: preview_markdown_path(@project),
......@@ -15,4 +15,4 @@
labels_fetch_path: project_labels_path(@project, format: :json),
test_case_new_path: new_project_quality_test_case_path(@project),
sidebar_options: issuable_sidebar_options(@issuable_sidebar).to_json.html_safe,
test_case_id: @issue.iid } }
test_case_id: @test_case.iid } }
---
title: Add route for test cases show page
merge_request: 47441
author:
type: added
......@@ -16,7 +16,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
namespace :quality do
resources :test_cases, only: [:index, :new]
resources :test_cases, only: [:index, :new, :show]
end
resources :autocomplete_sources, only: [] do
......
......@@ -91,5 +91,28 @@ RSpec.describe Projects::Quality::TestCasesController do
it_behaves_like 'test case action', :new
end
describe '#show' do
let_it_be(:test_case) { create(:quality_test_case, project: project) }
subject { get :show, params: { namespace_id: project.namespace, project_id: project, id: test_case } }
it_behaves_like 'test case action', :show
context 'when feature is enabled and user has access' do
before do
stub_licensed_features(quality_management: true)
project.add_developer(user)
sign_in(user)
end
it 'assigns test case related variables' do
subject
expect(assigns(:test_case)).to eq(test_case)
expect(assigns(:issuable_sidebar)).to be_present
end
end
end
end
end
......@@ -18,7 +18,7 @@ RSpec.describe 'Test Cases', :js do
context 'test case page' do
before do
visit project_issue_path(project, test_case)
visit project_quality_test_case_path(project, test_case)
wait_for_all_requests
end
......
......@@ -25,4 +25,20 @@ RSpec.describe IssuePresenter do
it { is_expected.to eq(nil) }
end
end
describe '#web_url' do
subject { described_class.new(issue).present.web_url }
context 'when issue has default type' do
let_it_be(:issue) { create(:issue) }
it { is_expected.to eq("http://localhost/#{issue.project.namespace.path}/#{issue.project.name}/-/issues/#{issue.iid}") }
end
context 'when issue has test_case type' do
let_it_be(:issue) { create(:quality_test_case) }
it { is_expected.to eq("http://localhost/#{issue.project.namespace.path}/#{issue.project.name}/-/quality/test_cases/#{issue.iid}") }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment