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

My Time Tracking pages

Klaus Zandersade749b373b1
diff --git a/modules/costs/app/components/my/time_tracking/list_component.html.erb b/modules/costs/app/components/my/time_tracking/list_component.html.erb
index 06dfae607b9..96f15cc39c3 100644
--- a/modules/costs/app/components/my/time_tracking/list_component.html.erb
+++ b/modules/costs/app/components/my/time_tracking/list_component.html.erb
@@ -7,7 +7,7 @@
<%= flex_layout(classes: ["my-time-tracking-list-view"]) do |flex| %>
<% range.each do |date| %>
<% flex.with_row do %>
- <%= render(Primer::OpenProject::CollapsibleSection.new(collapsed: collapsed?(date))) do |section| %>
+ <%= render(Primer::OpenProject::CollapsibleSection.new(test_selector: "section-#{date.iso8601}", collapsed: collapsed?(date))) do |section| %>
<% section.with_title { date_title(date) } %>
<% section.with_caption { date_caption(date) } %>
<% section.with_additional_information do %>
diff --git a/modules/costs/spec/features/my_time_tracking_spec.rb b/modules/costs/spec/features/my_time_tracking_spec.rb
index c8b19270680..716be0a22dd 100644
--- a/modules/costs/spec/features/my_time_tracking_spec.rb
+++ b/modules/costs/spec/features/my_time_tracking_spec.rb
@@ -58,13 +58,44 @@ RSpec.describe "my time tracking", :js do
end
let!(:time_entry6) { create(:time_entry, user:, work_package: work_package2, spent_on: "2025-04-14", hours: 2.0) }
+ let(:allow_exact_time_tracking) { true }
+ let(:force_exact_time_tracking) { false }
+
+ let(:calendar_page) { Pages::MyTimeTracking::CalendarPage.new }
+ let(:list_page) { Pages::MyTimeTracking::ListPage.new }
+
before do
+ allow(TimeEntry).to receive_messages(
+ can_track_start_and_end_time?: allow_exact_time_tracking,
+ must_track_start_and_end_time?: force_exact_time_tracking
+ )
+
login_as user
end
- it "does something" do
- allow(TimeEntry).to receive(:can_track_start_and_end_time?).and_return(true)
- visit my_time_tracking_path(date: "2025-04-09", view_mode: "list")
- # save_and_open_screenshot
+ around do |example|
+ travel_to "2025-04-09T12:00:00Z" do # rubocop:disable RSpecRails/TravelAround
+ example.run
+ end
+ end
+
+ context "when requesting list view" do
+ before do
+ visit my_time_tracking_path(date: "2025-04-09", view_mode: "list", mode: "workweek")
+ end
+
+ it "shows all dates of the current work week" do
+ list_page.expect_displays_day_section("2025-04-07", collapsed: true)
+ list_page.expect_displays_day_section("2025-04-08", collapsed: true)
+ list_page.expect_displays_day_section("2025-04-09", collapsed: false)
+ list_page.expect_displays_day_section("2025-04-10", collapsed: false)
+ list_page.expect_displays_day_section("2025-04-11", collapsed: false)
+ end
+ end
+
+ context "when requesting calendar view" do # rubocop:disable RSpec/EmptyExampleGroup
+ before do
+ visit my_time_tracking_path(date: "2025-04-09", view_mode: "calendar", mode: "workweek")
+ end
end
end
diff --git a/modules/costs/spec/support/pages/my_time_tracking/calendar_page.rb b/modules/costs/spec/support/pages/my_time_tracking/calendar_page.rb
new file mode 100644
index 00000000000..c6f056c7bed
--- /dev/null
+++ b/modules/costs/spec/support/pages/my_time_tracking/calendar_page.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "support/pages/page"
+
+module Pages
+ module MyTimeTracking
+ class CalendarPage < Page
+ end
+ end
+end
diff --git a/modules/costs/spec/support/pages/my_time_tracking/list_page.rb b/modules/costs/spec/support/pages/my_time_tracking/list_page.rb
new file mode 100644
index 00000000000..fcae03edadc
--- /dev/null
+++ b/modules/costs/spec/support/pages/my_time_tracking/list_page.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "support/pages/page"
+
+module Pages
+ module MyTimeTracking
+ class ListPage < Page
+ def expect_displays_day_section(date, collapsed: false)
+ selector = if collapsed
+ "collapsible-section[data-test-selector='section-#{date.to_date.iso8601}'][data-collapsed=true]"
+ else
+ "collapsible-section[data-test-selector='section-#{date.to_date.iso8601}']"
+ end
+
+ expect(page).to have_css(selector)
+ end
+ end
+ end
+end