nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: elastic/synthetics
Pull request #813 (2023-07-31 10:32:57)

feat: add --no-headless cli option
add `--no-headless` cli option

fixes https://github.com/elastic/synthetics/issues/799


Patch:
diff --git a/src/cli.ts b/src/cli.ts
index 59b720f..e76e151 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -78,8 +78,9 @@ program
   )
   .option('--inline', 'Run inline journeys from heartbeat')
   .option('-r, --require <modules...>', 'module(s) to preload')
-  .option('--sandbox', 'enable chromium sandboxing')
+  .option('--sandbox', 'enable chromium sand-boxing')
   .option('--rich-events', 'Mimics a heartbeat run')
+  .option('--no-headless', 'run browser in head-full mode')
   .option(
     '--capability <features...>',
     'Enable capabilities through feature flags'
diff --git a/src/common_types.ts b/src/common_types.ts
index c8c14f8..db4219f 100644
--- a/src/common_types.ts
+++ b/src/common_types.ts
@@ -223,6 +223,7 @@ export type CliArgs = BaseArgs & {
   require?: Array<string>;
   sandbox?: boolean;
   richEvents?: boolean;
+  headless?: boolean;
   capability?: Array<string>;
   ignoreHttpsErrors?: boolean;
 };
diff --git a/src/index.ts b/src/index.ts
index 4222f1f..691b38a 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -43,6 +43,7 @@ export {
   after,
 } from './core';
 export { expect } from './core/expect';
+
 /**
  * Export all the driver related types to be consumed
  * and used by suites
@@ -53,13 +54,9 @@ export type {
   ChromiumBrowserContext,
   CDPSession,
   APIRequestContext,
+  devices,
 } from 'playwright-chromium';
 
-/**
- * Export things related to playwright-core
- */
-export { devices } from 'playwright-core';
-
 /**
  * Export the types necessary to write custom reporters
  */
diff --git a/src/options.ts b/src/options.ts
index 58a3994..bfd3342 100644
--- a/src/options.ts
+++ b/src/options.ts
@@ -106,6 +106,7 @@ export function normalizeOptions(
   );
   options.playwrightOptions = {
     ...playwrightOpts,
+    headless: cliArgs.headless ?? playwrightOpts?.headless,
     chromiumSandbox: cliArgs.sandbox ?? playwrightOpts?.chromiumSandbox,
     ignoreHTTPSErrors:
       cliArgs.ignoreHttpsErrors ?? playwrightOpts?.ignoreHTTPSErrors,


Test patch:
diff --git a/__tests__/options.test.ts b/__tests__/options.test.ts
index 8a251ef..0d998ee 100644
--- a/__tests__/options.test.ts
+++ b/__tests__/options.test.ts
@@ -119,4 +119,18 @@ describe('options', () => {
       },
     });
   });
+
+  it('cli arg headless override playwright headless arg', () => {
+    const cliArgs: CliArgs = {
+      playwrightOptions: {
+        headless: false,
+      },
+      headless: true,
+    };
+    expect(normalizeOptions(cliArgs)).toMatchObject({
+      playwrightOptions: {
+        headless: true,
+      },
+    });
+  });
 });
Repository: elastic/synthetics
Pull request #838 (2023-09-19 12:43:03)

fix: fix headless option from config file

fixes https://github.com/elastic/synthetics/issues/837

fix headless option from config file !!

devcorpio: I'm testing the PR.


## Case 1:  Default config

That means, no configuring anything related to headless:  (no cli flag, and no property in `synthetics.config.file`)

Result: I'm seeing the browser

## Case 2: headless flag set to **false** in synthetics.config.file

Result: I'm seeing the browser

## Case 3: headless flag set to **false** in synthetics.config.file and passing --no-headless arg

Result: I'm seeing the browser

## Case 4: headless flag set to **true** in synthetics.config.file

Result: I'm **not** seeing the browser

## Case 5: headless flag set to **true** in synthetics.config.file and passing --no-headless arg

Result: I'm seeing the browser

## Case 6: nothing set in synthetics.config.file and passing --no-headless arg

Result: I'm seeing the browser

Patch:
diff --git a/src/options.ts b/src/options.ts
index af5e002..83fe0dc 100644
--- a/src/options.ts
+++ b/src/options.ts
@@ -106,7 +106,7 @@ export async function normalizeOptions(
   );
   options.playwrightOptions = {
     ...playwrightOpts,
-    headless: cliArgs.headless ?? playwrightOpts?.headless,
+    headless: getHeadlessFlag(cliArgs.headless, playwrightOpts?.headless),
     chromiumSandbox: cliArgs.sandbox ?? playwrightOpts?.chromiumSandbox,
     ignoreHTTPSErrors:
       cliArgs.ignoreHttpsErrors ?? playwrightOpts?.ignoreHTTPSErrors,
@@ -140,6 +140,18 @@ export async function normalizeOptions(
   return options;
 }
 
+export function getHeadlessFlag(
+  cliHeadless: boolean,
+  configHeadless?: boolean
+) {
+  // if cliHeadless is false, then we don't care about configHeadless
+  if (!cliHeadless) {
+    return false;
+  }
+  // default is headless
+  return configHeadless ?? true;
+}
+
 export function validatePushOptions(opts: PushOptions) {
   if (opts.tags || opts.match) {
     throw error(`Aborted. Invalid CLI flags.


Test patch:
diff --git a/__tests__/options.test.ts b/__tests__/options.test.ts
index e0976d4..2536fdc 100644
--- a/__tests__/options.test.ts
+++ b/__tests__/options.test.ts
@@ -121,6 +121,20 @@ describe('options', () => {
   });
 
   it('cli arg headless override playwright headless arg', async () => {
+    const cliArgs: CliArgs = {
+      playwrightOptions: {
+        headless: true,
+      },
+      headless: false,
+    };
+    expect(await normalizeOptions(cliArgs)).toMatchObject({
+      playwrightOptions: {
+        headless: false,
+      },
+    });
+  });
+
+  it('cli arg headless default value is overridden by config file', async () => {
     const cliArgs: CliArgs = {
       playwrightOptions: {
         headless: false,
@@ -129,7 +143,7 @@ describe('options', () => {
     };
     expect(await normalizeOptions(cliArgs)).toMatchObject({
       playwrightOptions: {
-        headless: true,
+        headless: false,
       },
     });
   });
Repository: elastic/synthetics
Pull request #899 (2024-02-23 02:05:53)

fix: push disabled lightweight monitor correctly
+ fix #898 


Patch:
diff --git a/src/push/monitor.ts b/src/push/monitor.ts
index 356f736..f261b0a 100644
--- a/src/push/monitor.ts
+++ b/src/push/monitor.ts
@@ -204,11 +204,8 @@ export async function createLightweightMonitors(
     }
 
     for (const monNode of monitorSeq.items) {
-      // Skip browser monitors and disabled monitors from pushing
-      if (
-        monNode.get('type') === 'browser' ||
-        monNode.get('enabled') === false
-      ) {
+      // Skip browser monitors from the YML files
+      if (monNode.get('type') === 'browser') {
         continue;
       }
       const config = monNode.toJSON();


Test patch:
diff --git a/__tests__/push/monitor.test.ts b/__tests__/push/monitor.test.ts
index 13ac783..55ba2fa 100644
--- a/__tests__/push/monitor.test.ts
+++ b/__tests__/push/monitor.test.ts
@@ -205,8 +205,10 @@ heartbeat.monitors:
   id: "foo"
   name: "foo"
       `);
-      opts.pattern = '.yaml$';
-      const monitors = await createLightweightMonitors(PROJECT_DIR, opts);
+      const monitors = await createLightweightMonitors(PROJECT_DIR, {
+        ...opts,
+        pattern: '.yaml$',
+      });
       expect(monitors.length).toBe(0);
     });
 
@@ -221,16 +223,17 @@ heartbeat.monitors:
       expect(monitors.length).toBe(0);
     });
 
-    it('skip disabled monitors', async () => {
+    it('push disabled monitors', async () => {
       await writeHBFile(`
 heartbeat.monitors:
 - type: http
+  name: "disabled"
   schedule: "@every 1m"
-  id: "http"
+  id: "disabled"
   enabled: false
       `);
       const monitors = await createLightweightMonitors(PROJECT_DIR, opts);
-      expect(monitors.length).toBe(0);
+      expect(monitors.length).toBe(1);
     });
 
     it('prefer local monitor config', async () => {