Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

1.3 KB
Raw Blame
# frozen_string_literal: true

require "spec_helper"

RSpec.describe "Duration field in the work package table", :js do
  shared_let(:current_user) { create(:admin) }
  shared_let(:work_package) do
    next_monday = Time.zone.today.beginning_of_week.next_occurring(:monday)
    create(:work_package,
           subject: "moved",
           author: current_user,
           start_date: next_monday,
           due_date: next_monday.next_occurring(:thursday))
  end

  let!(:wp_table) { Pages::WorkPackagesTable.new(work_package.project) }
  let!(:query) do
    query              = build(:query, user: current_user, project: work_package.project)
    query.column_names = %w(subject start_date due_date duration)
    query.filters.clear
    query.show_hierarchies = false

    query.save!
    query
  end

  let(:duration) { wp_table.edit_field work_package, :duration }
  let(:date_field) { wp_table.edit_field work_package, :startDate }

  before do
    login_as(current_user)

    wp_table.visit_query query
    wp_table.expect_work_package_listed work_package
  end

  it "shows the duration as days and opens the datepicker on click" do
    duration.expect_state_text "4 days"
    duration.activate!
    wait_for_network_idle

    date_field.expect_duration_highlighted
    expect(page).to have_field("work_package[duration]", with: "4", wait: 10)
  end
end