Skip to content

Commit

Permalink
fix: allow overriding enabled/retestOnFailure via global config (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam authored Feb 21, 2024
1 parent d1259e9 commit 27182c6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions __tests__/core/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ describe('runner', () => {
});

it('runner - build monitors with global config', async () => {
// Faking monitor.use across file level
runner.updateMonitor({
schedule: 5,
locations: ['us_east'],
Expand All @@ -772,16 +773,22 @@ describe('runner', () => {
schedule: 3,
locations: ['united_kingdom'],
privateLocations: ['spain'],
retestOnFailure: true,
});
j2.updateMonitor({ throttling: { latency: 1000 } });
j2.updateMonitor({ throttling: { latency: 1000 }, enabled: true });
runner.addJourney(j1);
runner.addJourney(j2);

const monitors = runner.buildMonitors(options);
const monitors = runner.buildMonitors({
...options,
enabled: false,
retestOnFailure: false,
});
expect(monitors.length).toBe(2);
expect(monitors[0].config).toEqual({
id: 'test-j1',
name: 'j1',
enabled: false,
type: 'browser',
tags: ['foo*'],
locations: ['united_kingdom'],
Expand All @@ -791,11 +798,13 @@ describe('runner', () => {
playwrightOptions: { ignoreHTTPSErrors: true },
throttling: { download: 100, latency: 20, upload: 50 },
alert: { tls: { enabled: true } },
retestOnFailure: true,
});
expect(monitors[1].config).toMatchObject({
locations: ['us_east'],
privateLocations: ['germany'],
schedule: 5,
enabled: true,
tags: ['g1', 'g2'],
throttling: { latency: 1000 },
alert: { tls: { enabled: true } },
Expand Down
1 change: 1 addition & 0 deletions src/common_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export type PushOptions = Partial<ProjectSettings> &
yes?: boolean;
alert?: AlertConfig;
retestOnFailure?: MonitorConfig['retestOnFailure'];
enabled?: boolean;
};

export type ProjectSettings = {
Expand Down
2 changes: 2 additions & 0 deletions src/core/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ export default class Runner {
screenshot: options.screenshots,
tags: options.tags,
alert: options.alert,
retestOnFailure: options.retestOnFailure,
enabled: options.enabled,
});

const monitors: Monitor[] = [];
Expand Down
1 change: 1 addition & 0 deletions src/push/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export function buildMonitorFromYaml(
const alertConfig = parseAlertConfig(config, options.alert);

const mon = new Monitor({
enabled: config.enabled ?? options.enabled,
locations: options.locations,
tags: options.tags,
...normalizeConfig(config),
Expand Down

0 comments on commit 27182c6

Please sign in to comment.