Skip to content

Commit

Permalink
[#58160] project list: check for stages and gates feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
EinLama committed Dec 13, 2024
1 parent ce4688e commit 28afb3e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 48 deletions.
2 changes: 1 addition & 1 deletion app/models/queries/projects/selects/life_cycle_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def life_cycle_step_definition
end

def available?
life_cycle_step_definition.present?
OpenProject::FeatureDecisions.stages_and_gates_active? && life_cycle_step_definition.present?
end

def visual_icon
Expand Down
109 changes: 62 additions & 47 deletions spec/features/projects/projects_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,63 +339,78 @@ def load_and_open_filters(user)
shared_let(:inactive_life_cycle_gate) { create(:project_gate, active: false) }
shared_let(:inactive_life_cycle_stage) { create(:project_stage, active: false) }

specify "life cycle columns do not show up by default" do
login_as(admin)
projects_page.visit!
context "with the feature flag disabled", with_flag: { stages_and_gates: false } do
specify "life cycle columns cannot be configured to show up" do
login_as(admin)
projects_page.visit!

expect(page).to have_no_text(life_cycle_gate.definition.name.upcase)
expect(page).to have_no_text(life_cycle_stage.definition.name.upcase)
expect(page).to have_no_text(inactive_life_cycle_gate.definition.name.upcase)
expect(page).to have_no_text(inactive_life_cycle_stage.definition.name.upcase)
end
# Trying to set the column via configure view
projects_page.set_columns(life_cycle_gate.definition.name)

specify "life cycle columns show up when configured to do so" do
login_as(admin)
projects_page.visit!
# It didn't work
expect(page).to have_no_text(life_cycle_gate.definition.name.upcase)
end
end

projects_page.expect_columns("Name")
projects_page.set_columns(life_cycle_gate.definition.name)
context "with the feature flag enabled", with_flag: { stages_and_gates: true } do
specify "life cycle columns do not show up by default" do
login_as(admin)
projects_page.visit!

expect(page).to have_text(life_cycle_gate.definition.name.upcase)
end
expect(page).to have_no_text(life_cycle_gate.definition.name.upcase)
expect(page).to have_no_text(life_cycle_stage.definition.name.upcase)
expect(page).to have_no_text(inactive_life_cycle_gate.definition.name.upcase)
expect(page).to have_no_text(inactive_life_cycle_stage.definition.name.upcase)
end

specify "inactive life cycle columns have no cell content" do
login_as(admin)
projects_page.visit!
specify "life cycle columns show up when configured to do so" do
login_as(admin)
projects_page.visit!

projects_page.expect_columns("Name")
projects_page.expect_columns("Name")
projects_page.set_columns(life_cycle_gate.definition.name)

col_names = [life_cycle_gate, life_cycle_stage,
inactive_life_cycle_gate,
inactive_life_cycle_stage].map { |l| l.definition.name }

projects_page.set_columns(*col_names)
# Inactive columns are still displayed in the header:
projects_page.expect_columns("Name", *col_names)

gate_project = life_cycle_gate.project
projects_page.within_row(gate_project) do
expect(page).to have_css(".name", text: gate_project.name)
expect(page).to have_css(".lcsd_#{life_cycle_gate.definition.id}", text: "12/13/2024")
# life cycle assigned to other project, no text here
expect(page).to have_css(".lcsd_#{life_cycle_stage.definition.id}", text: "")
# inactive life cycles, no text here
expect(page).to have_css(".lcsd_#{inactive_life_cycle_stage.definition.id}", text: "")
expect(page).to have_css(".lcsd_#{inactive_life_cycle_gate.definition.id}", text: "")
expect(page).to have_text(life_cycle_gate.definition.name.upcase)
end

stage_project = life_cycle_stage.project
projects_page.within_row(stage_project) do
expect(page).to have_css(".name", text: stage_project.name)
expect(page).to have_css(".lcsd_#{life_cycle_stage.definition.id}", text: "12/01/2024 - 12/13/2024")
# life cycle assigned to other project, no text here
expect(page).to have_css(".lcsd_#{life_cycle_gate.definition.id}", text: "")
end
specify "inactive life cycle columns have no cell content" do
login_as(admin)
projects_page.visit!

projects_page.expect_columns("Name")

col_names = [life_cycle_gate, life_cycle_stage,
inactive_life_cycle_gate,
inactive_life_cycle_stage].map { |l| l.definition.name }

projects_page.set_columns(*col_names)
# Inactive columns are still displayed in the header:
projects_page.expect_columns("Name", *col_names)

gate_project = life_cycle_gate.project
projects_page.within_row(gate_project) do
expect(page).to have_css(".name", text: gate_project.name)
expect(page).to have_css(".lcsd_#{life_cycle_gate.definition.id}", text: "12/13/2024")
# life cycle assigned to other project, no text here
expect(page).to have_css(".lcsd_#{life_cycle_stage.definition.id}", text: "")
# inactive life cycles, no text here
expect(page).to have_css(".lcsd_#{inactive_life_cycle_stage.definition.id}", text: "")
expect(page).to have_css(".lcsd_#{inactive_life_cycle_gate.definition.id}", text: "")
end

# Inactive life cycle steps never show their date values
other_proj = inactive_life_cycle_stage.project
projects_page.within_row(other_proj) do
expect(page).to have_css(".lcsd_#{inactive_life_cycle_stage.definition.id}", text: "")
stage_project = life_cycle_stage.project
projects_page.within_row(stage_project) do
expect(page).to have_css(".name", text: stage_project.name)
expect(page).to have_css(".lcsd_#{life_cycle_stage.definition.id}", text: "12/01/2024 - 12/13/2024")
# life cycle assigned to other project, no text here
expect(page).to have_css(".lcsd_#{life_cycle_gate.definition.id}", text: "")
end

# Inactive life cycle steps never show their date values
other_proj = inactive_life_cycle_stage.project
projects_page.within_row(other_proj) do
expect(page).to have_css(".lcsd_#{inactive_life_cycle_stage.definition.id}", text: "")
end
end
end
end
Expand Down

0 comments on commit 28afb3e

Please sign in to comment.