Skip to content

Commit 02f8b06

Browse files
Fix/timezone fix (#366)
* Fix timezone issue once and for all * improved timezone testing * Update ci.yml set locale so that dates are formatted correctly when running tests * Update ci.yml trying another way * Update ci.yml trying for timelog tests * Try global env --------- Co-authored-by: Matt Bell <matt@2pisoftware.com>
1 parent c5d9b38 commit 02f8b06

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
DB_PASSWORD: cmfive_test
1717
DB_DATABASE: cmfive_test
1818
PLAYWRIGHT_MODULES: "admin channel form tag report task timelog"
19+
LANG: en_AU.UTF-8
1920

2021
jobs:
2122
# Lint

system/modules/timelog/tests/acceptance/playwright/timelog.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ test("You can create a Timelog using Timer" , async ({page, isMobile}) => {
2121
const taskID = await TaskHelper.createTask(page, isMobile, task, taskgroup, "Software Development");
2222

2323
const timelog = CmfiveHelper.randomID("timelog_");
24-
await TimelogHelper.createTimelogFromTimer(page, isMobile, timelog, task, taskID);
25-
24+
const start_time = new DateTime('now').minus({hours: 1}).toFormat("HH:mm");
25+
await TimelogHelper.createTimelogFromTimer(page, isMobile, timelog, task, taskID, start_time);
2626
await TimelogHelper.deleteTimelog(page, isMobile, timelog, task, taskID);
2727
await TaskHelper.deleteTask(page, isMobile, task, taskID);
2828
await TaskHelper.deleteTaskGroup(page, isMobile, taskgroup, taskgroupID);
@@ -49,7 +49,7 @@ test("You can create a Timelog using Add Timelog" , async ({page, isMobile}) =>
4949
timelog,
5050
task,
5151
taskID,
52-
DateTime.fromFormat("1/1/2021", "d/M/yyyy"),
52+
DateTime.fromFormat("1/2/2021", "d/M/yyyy"),
5353
"10:00",
5454
"11:00",
5555
);

system/modules/timelog/tests/acceptance/playwright/timelog.utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export class TimelogHelper {
2828
await page.getByRole("link", {name: "Time Log"}).click();
2929
await page.reload();
3030
await expect(page.getByText(timelog)).toBeVisible();
31+
//check timelog date and time values
32+
await expect(page.getByText(new DateTime('now').toFormat("dd-LL-yyyy") + ' ' + start_time)).toBeVisible();
3133
}
3234

3335
static async createTimelog(page: Page, isMobile: boolean, timelog: string, taskName: string, taskID: string, date: DateTime, start_time: string, end_time: string, check_duplicate: boolean = false)
@@ -71,6 +73,9 @@ export class TimelogHelper {
7173
await expect(page.getByText(timelog)).toBeHidden();
7274
else
7375
await expect(page.getByText(timelog)).toBeVisible();
76+
//check timelog date and time values
77+
await expect(page.getByText(date.toFormat("dd-LL-yyyy") + ' ' + start_time)).toBeVisible();
78+
await expect(page.getByText(date.toFormat("dd-LL-yyyy") + ' ' + end_time)).toBeVisible();
7479
}
7580

7681
static async editTimelog(page: Page, isMobile: boolean, timelog: string, taskName: string, taskID: string, date: DateTime, start_time: string, end_time: string)

system/web.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,7 @@ public function start($init_database = true)
546546
$this->ctx('error', "An error occoured, if this message persists please contact your administrator.");
547547
});
548548
}
549-
if ($init_database) {
550-
$this->initDB();
551-
}
549+
552550

553551
// Set the timezone from Config
554552
$timezone = Config::get('system.timezone');
@@ -557,6 +555,10 @@ public function start($init_database = true)
557555
}
558556
date_default_timezone_set($timezone);
559557

558+
if ($init_database) {
559+
$this->initDB();
560+
}
561+
560562
//check config for 'gc_maxlifetime' for the session
561563
$gc_maxlifetime = Config::get('system.gc_maxlifetime');
562564
//Checks include is greater than 1 hour (3600 sec) is less than 1 month (2628000 sec)

0 commit comments

Comments
 (0)