Skip to content

A local-first personal finance app

:bug: (vrt) fix vrt - use static date (#1590)

Matiss Janis Aboltinsd8c99221ff1c
diff --git a/packages/desktop-client/e2e/budget.test.js-snapshots/Budget-renders-the-summary-information-available-funds-overspent-budgeted-and-for-next-month-1-chromium-linux.png b/packages/desktop-client/e2e/budget.test.js-snapshots/Budget-renders-the-summary-information-available-funds-overspent-budgeted-and-for-next-month-1-chromium-linux.png
index c66cbca273..8eeb47f986 100644
Binary files a/packages/desktop-client/e2e/budget.test.js-snapshots/Budget-renders-the-summary-information-available-funds-overspent-budgeted-and-for-next-month-1-chromium-linux.png and b/packages/desktop-client/e2e/budget.test.js-snapshots/Budget-renders-the-summary-information-available-funds-overspent-budgeted-and-for-next-month-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/budget.test.js-snapshots/Budget-transfer-funds-to-another-category-1-chromium-linux.png b/packages/desktop-client/e2e/budget.test.js-snapshots/Budget-transfer-funds-to-another-category-1-chromium-linux.png
index 218831959c..9e0dc62aa7 100644
Binary files a/packages/desktop-client/e2e/budget.test.js-snapshots/Budget-transfer-funds-to-another-category-1-chromium-linux.png and b/packages/desktop-client/e2e/budget.test.js-snapshots/Budget-transfer-funds-to-another-category-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-loads-net-worth-and-cash-flow-reports-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-loads-net-worth-and-cash-flow-reports-1-chromium-linux.png
index d8d4733a45..f2eaf9cd86 100644
Binary files a/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-loads-net-worth-and-cash-flow-reports-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-loads-net-worth-and-cash-flow-reports-1-chromium-linux.png differ
diff --git a/packages/loot-core/src/server/schedules/app.test.ts b/packages/loot-core/src/server/schedules/app.test.ts
index def3bff7ec..7d34ce0d60 100644
--- a/packages/loot-core/src/server/schedules/app.test.ts
+++ b/packages/loot-core/src/server/schedules/app.test.ts
@@ -21,10 +21,6 @@ beforeEach(async () => {
});
describe('schedule app', () => {
- beforeEach(() => {
- MockDate.set(new Date(2021, 4, 16));
- });
-
describe('utility', () => {
it('conditions are updated when they exist', () => {
let conds = [
@@ -79,7 +75,7 @@ describe('schedule app', () => {
],
},
}),
- ).toBe('2021-05-30');
+ ).toBe('2020-12-30');
});
});
@@ -108,7 +104,7 @@ describe('schedule app', () => {
expect(row).toBeTruthy();
expect(row.rule).toBeTruthy();
- expect(row.next_date).toBe('2021-05-30');
+ expect(row.next_date).toBe('2020-12-30');
await expect(
createSchedule({
@@ -143,7 +139,7 @@ describe('schedule app', () => {
);
let row = res.data[0];
- expect(row.next_date).toBe('2021-05-30');
+ expect(row.next_date).toBe('2020-12-30');
expect(row.posts_transaction).toBe(false);
MockDate.set(new Date(2021, 4, 17));
@@ -250,9 +246,8 @@ describe('schedule app', () => {
);
let row = res.data[0];
- expect(row.next_date).toBe('2021-05-30');
+ expect(row.next_date).toBe('2020-12-30');
- MockDate.set(new Date(2021, 4, 17));
await setNextDate({ id });
res = await aqlQuery(q('schedules').filter({ id }).select(['next_date']));
diff --git a/packages/loot-core/src/server/schedules/app.ts b/packages/loot-core/src/server/schedules/app.ts
index 88a2e12d45..633e9898ea 100644
--- a/packages/loot-core/src/server/schedules/app.ts
+++ b/packages/loot-core/src/server/schedules/app.ts
@@ -65,7 +65,7 @@ export function updateConditions(conditions, newConditions) {
return updated.concat(added);
}
-export function getNextDate(dateCond, start = new Date()) {
+export function getNextDate(dateCond, start = new Date(currentDay())) {
start = d.startOfDay(start);
let cond = new Condition(
diff --git a/packages/loot-core/src/shared/months.ts b/packages/loot-core/src/shared/months.ts
index df8248fe65..da230dfe09 100644
--- a/packages/loot-core/src/shared/months.ts
+++ b/packages/loot-core/src/shared/months.ts
@@ -1,6 +1,8 @@
import * as d from 'date-fns';
import memoizeOne from 'memoize-one';
+import * as Platform from '../client/platform';
+
type DateLike = string | Date;
export function _parse(value: DateLike): Date {
@@ -89,7 +91,7 @@ export function dayFromDate(date: DateLike): string {
}
export function currentMonth(): string {
- if (global.IS_TESTING) {
+ if (global.IS_TESTING || Platform.isPlaywright) {
return global.currentMonth || '2017-01';
} else {
return d.format(new Date(), 'yyyy-MM');
@@ -97,7 +99,7 @@ export function currentMonth(): string {
}
export function currentDay(): string {
- if (global.IS_TESTING) {
+ if (global.IS_TESTING || Platform.isPlaywright) {
return '2017-01-01';
} else {
return d.format(new Date(), 'yyyy-MM-dd');
diff --git a/upcoming-release-notes/1590.md b/upcoming-release-notes/1590.md
new file mode 100644
index 0000000000..f725a47547
--- /dev/null
+++ b/upcoming-release-notes/1590.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Improving e2e test stability by forcing a specific date