Skip to content

Commit

Permalink
Merge branch 'master' into matiss/eslint-warn
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored Aug 28, 2023
2 parents a960270 + d8c9922 commit a1a61e5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 4 additions & 9 deletions packages/loot-core/src/server/schedules/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -79,7 +75,7 @@ describe('schedule app', () => {
],
},
}),
).toBe('2021-05-30');
).toBe('2020-12-30');
});
});

Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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']));
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/server/schedules/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions packages/loot-core/src/shared/months.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -89,15 +91,15 @@ 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');
}
}

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');
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/1590.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---

Improving e2e test stability by forcing a specific date

0 comments on commit a1a61e5

Please sign in to comment.