Skip to content
Snippets Groups Projects
Unverified Commit d8c99221 authored by Matiss Janis Aboltins's avatar Matiss Janis Aboltins Committed by GitHub
Browse files

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

parent 7c48e533
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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']));
......
......@@ -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(
......
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');
......
---
category: Maintenance
authors: [MatissJanis]
---
Improving e2e test stability by forcing a specific date
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment