|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +#-- copyright |
| 4 | +# OpenProject is an open source project management software. |
| 5 | +# Copyright (C) the OpenProject GmbH |
| 6 | +# |
| 7 | +# This program is free software; you can redistribute it and/or |
| 8 | +# modify it under the terms of the GNU General Public License version 3. |
| 9 | +# |
| 10 | +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
| 11 | +# Copyright (C) 2006-2013 Jean-Philippe Lang |
| 12 | +# Copyright (C) 2010-2013 the ChiliProject Team |
| 13 | +# |
| 14 | +# This program is free software; you can redistribute it and/or |
| 15 | +# modify it under the terms of the GNU General Public License |
| 16 | +# as published by the Free Software Foundation; either version 2 |
| 17 | +# of the License, or (at your option) any later version. |
| 18 | +# |
| 19 | +# This program is distributed in the hope that it will be useful, |
| 20 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | +# GNU General Public License for more details. |
| 23 | +# |
| 24 | +# You should have received a copy of the GNU General Public License |
| 25 | +# along with this program; if not, write to the Free Software |
| 26 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 27 | +# |
| 28 | +# See COPYRIGHT and LICENSE files for more details. |
| 29 | +#++ |
| 30 | + |
| 31 | +require "spec_helper" |
| 32 | + |
| 33 | +RSpec.describe "Work package type tab page titles", |
| 34 | + type: :rails_request, |
| 35 | + with_flag: { type_variants: true } do |
| 36 | + shared_let(:admin) { create(:admin) } |
| 37 | + shared_let(:type) { create(:type, name: "Bug") } |
| 38 | + shared_let(:variant) { create(:type_variant, type:, variant_name: "Hardware") } |
| 39 | + |
| 40 | + before { login_as admin } |
| 41 | + |
| 42 | + def page_title |
| 43 | + response.parsed_body.at_css("title")&.text |
| 44 | + end |
| 45 | + |
| 46 | + def tab_paths(args) |
| 47 | + { |
| 48 | + details: edit_type_details_path(**args), |
| 49 | + form_configuration: edit_type_form_configuration_path(**args), |
| 50 | + defaults: edit_type_defaults_path(**args), |
| 51 | + projects: edit_type_projects_path(**args), |
| 52 | + project_attributes: edit_type_project_attributes_path(**args), |
| 53 | + workflow: edit_type_workflow_path(**args), |
| 54 | + pdf_export: edit_type_pdf_export_template_index_path(**args) |
| 55 | + } |
| 56 | + end |
| 57 | + |
| 58 | + it "names the variant on every tab", :aggregate_failures do |
| 59 | + tab_paths(variant.path_args).each do |tab, path| |
| 60 | + get path |
| 61 | + |
| 62 | + expect(page_title).to include("Bug: Hardware"), "expected the #{tab} tab title to name the variant" |
| 63 | + end |
| 64 | + end |
| 65 | + |
| 66 | + it "names the type on the tabs of its base variant", :aggregate_failures do |
| 67 | + tab_paths(type.default_variant.path_args).each do |tab, path| |
| 68 | + get path |
| 69 | + |
| 70 | + expect(page_title).to include("Bug"), "expected the #{tab} tab title to name the type" |
| 71 | + expect(page_title).not_to include("Bug: "), "expected the #{tab} tab title to omit a variant name" |
| 72 | + end |
| 73 | + end |
| 74 | +end |
0 commit comments