nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: taskforcesh/bullmq
Pull request #922 (2021-12-10 03:00:45)

fix(connection): throw error when no noeviction policy
noeviction maxmemory-policy is the only option allowed

BREAKING CHANGE: noeviction maxmemory-policy is the only option allowed

re #921


Patch:
diff --git a/src/classes/redis-connection.ts b/src/classes/redis-connection.ts
index bbfba8fb79..34e235facc 100644
--- a/src/classes/redis-connection.ts
+++ b/src/classes/redis-connection.ts
@@ -192,14 +192,27 @@ export class RedisConnection extends EventEmitter {
 
   private async getRedisVersion() {
     const doc = await this._client.info();
-    const prefix = 'redis_version:';
+    const redisPrefix = 'redis_version:';
+    const maxMemoryPolicyPrefix = 'maxmemory_policy:';
     const lines = doc.split('\r\n');
+    let redisVersion;
 
     for (let i = 0; i < lines.length; i++) {
-      if (lines[i].indexOf(prefix) === 0) {
-        return lines[i].substr(prefix.length);
+      if (lines[i].indexOf(maxMemoryPolicyPrefix) === 0) {
+        const maxMemoryPolicy = lines[i].substr(maxMemoryPolicyPrefix.length);
+        if (maxMemoryPolicy !== 'noeviction') {
+          throw new Error(
+            `Eviction policy is ${maxMemoryPolicy}. It should be "noeviction"`,
+          );
+        }
+      }
+
+      if (lines[i].indexOf(redisPrefix) === 0) {
+        redisVersion = lines[i].substr(redisPrefix.length);
       }
     }
+
+    return redisVersion;
   }
 
   get redisVersion(): string {


Test patch:
diff --git a/tests/test_connection.ts b/tests/test_connection.ts
index b6589c2049..bdc24b644d 100644
--- a/tests/test_connection.ts
+++ b/tests/test_connection.ts
@@ -42,6 +42,27 @@ describe('connection', () => {
     checkOptions(await queue.client);
   });
 
+  describe('when maxmemory-policy is different than noeviction in Redis', () => {
+    it('throws an error', async () => {
+      const opts = {
+        connection: {
+          host: 'localhost',
+        },
+      };
+
+      const queue = new QueueBase(queueName, opts);
+      const client = await queue.client;
+      await client.config('SET', 'maxmemory-policy', 'volatile-lru');
+
+      const queue2 = new QueueBase(`${queueName}2`, opts);
+
+      await expect(queue2.client).to.be.eventually.rejectedWith(
+        'Eviction policy is volatile-lru. It should be "noeviction"',
+      );
+      await client.config('SET', 'maxmemory-policy', 'noeviction');
+    });
+  });
+
   it('should recover from a connection loss', async () => {
     let processor;
Repository: DevExpress/devextreme-react
Pull request #580 (2021-06-22 15:18:53)

DataGrid: Fix options changing in endUpdate (EditStateManagement demo)


Patch:
diff --git a/packages/devextreme-react/src/core/options-manager.ts b/packages/devextreme-react/src/core/options-manager.ts
index 049fa7b..af7123f 100644
--- a/packages/devextreme-react/src/core/options-manager.ts
+++ b/packages/devextreme-react/src/core/options-manager.ts
@@ -91,8 +91,8 @@ class OptionsManager {
       this.setValue(key, changes.options[key]);
     });
 
-    this.isUpdating = false;
     this.instance.endUpdate();
+    this.isUpdating = false;
 
     this.currentConfig = config;
   }


Test patch:
diff --git a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
index 8f22464..116fd6e 100644
--- a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
+++ b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
@@ -215,6 +215,29 @@ describe('option control', () => {
       expect(handler.mock.calls.length).toBe(1);
     });
 
+    it('should not rollback option if optionChanged is fired in endUpdate on props updating', () => {
+      const { rerender } = render(
+        <ControlledComponent
+          controlledOption="controlled"
+        />,
+      );
+
+      Widget.endUpdate.mockImplementation(
+        () => {
+          fireOptionChange('controlledOption', 'changed');
+        },
+      );
+
+      rerender(<ControlledComponent
+        controlledOption="changed"
+      />);
+
+      jest.runAllTimers(); // it is necessary to test that setGuard is not called
+
+      expect(Widget.option).toHaveBeenCalledTimes(1);
+      expect(Widget.option).toHaveBeenCalledWith('controlledOption', 'changed');
+    });
+
     it('is not updated on other prop updating', () => {
       const controlledOptionChanged = jest.fn();
       const { rerender } = render(
Repository: DevExpress/devextreme-react
Pull request #603 (2021-09-02 11:59:03)

Fix triggering onValueChanged event (T1022557)


Patch:
diff --git a/packages/devextreme-react-generator/src/generator.ts b/packages/devextreme-react-generator/src/generator.ts
index 6e2bcd2..51a62fb 100644
--- a/packages/devextreme-react-generator/src/generator.ts
+++ b/packages/devextreme-react-generator/src/generator.ts
@@ -157,7 +157,7 @@ export function collectIndependentEvents(options: IProp[]): IProp[] {
     if (option.types.filter((type) => type.type === 'Function').length === 1
         && (!option.firedEvents || option.firedEvents.length === 0)
         && option.name.substr(0, 2) === 'on'
-        && !option.name.endsWith('Changed')
+        && !option.name.match(/^(?!.*Value).*Changed/)
     ) {
       acc.push(option);
     }
diff --git a/packages/devextreme-react/src/core/component.ts b/packages/devextreme-react/src/core/component.ts
index 0e342e6..0d1010a 100644
--- a/packages/devextreme-react/src/core/component.ts
+++ b/packages/devextreme-react/src/core/component.ts
@@ -18,7 +18,7 @@ class Component<P> extends ComponentBase<P> {
     this._createExtensions();
   }
 
-  protected renderChildren(): Record<string, unknown>[]|null| undefined {
+  protected renderChildren(): Record<string, unknown>[] | null | undefined {
     return React.Children.map(
       this.props.children,
       (child) => {


Test patch:
diff --git a/packages/devextreme-react-generator/src/generator.test.ts b/packages/devextreme-react-generator/src/generator.test.ts
index 88f2be6..a7d0dac 100644
--- a/packages/devextreme-react-generator/src/generator.test.ts
+++ b/packages/devextreme-react-generator/src/generator.test.ts
@@ -140,9 +140,40 @@ describe('collectIndependentEvents', () => {
         props: [],
         firedEvents: [],
       },
+      {
+        name: 'valueChange',
+        isSubscribable: true,
+        types: [
+          {
+            type: 'Function',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+        ],
+        props: [],
+        firedEvents: [],
+      },
+      {
+        name: 'onSomeValueChanged',
+        isSubscribable: true,
+        types: [
+          {
+            type: 'Function',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+          {
+            type: 'Number',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+        ],
+        props: [],
+        firedEvents: [],
+      },
     ];
     const independentEvents = collectIndependentEvents(options);
-    expect(independentEvents.length).toBe(2);
+    expect(independentEvents.length).toBe(3);
     expect(independentEvents[0]).toEqual(options[1]);
     expect(independentEvents[1]).toEqual(options[6]);
   });
Repository: DevExpress/devextreme-react
Pull request #604 (2021-09-02 13:20:47)

Fix triggering onValueChanged event (T1022557)


Patch:
diff --git a/packages/devextreme-react-generator/src/generator.ts b/packages/devextreme-react-generator/src/generator.ts
index 6e2bcd2..51a62fb 100644
--- a/packages/devextreme-react-generator/src/generator.ts
+++ b/packages/devextreme-react-generator/src/generator.ts
@@ -157,7 +157,7 @@ export function collectIndependentEvents(options: IProp[]): IProp[] {
     if (option.types.filter((type) => type.type === 'Function').length === 1
         && (!option.firedEvents || option.firedEvents.length === 0)
         && option.name.substr(0, 2) === 'on'
-        && !option.name.endsWith('Changed')
+        && !option.name.match(/^(?!.*Value).*Changed/)
     ) {
       acc.push(option);
     }
diff --git a/packages/devextreme-react/src/core/component.ts b/packages/devextreme-react/src/core/component.ts
index 0e342e6..0d1010a 100644
--- a/packages/devextreme-react/src/core/component.ts
+++ b/packages/devextreme-react/src/core/component.ts
@@ -18,7 +18,7 @@ class Component<P> extends ComponentBase<P> {
     this._createExtensions();
   }
 
-  protected renderChildren(): Record<string, unknown>[]|null| undefined {
+  protected renderChildren(): Record<string, unknown>[] | null | undefined {
     return React.Children.map(
       this.props.children,
       (child) => {


Test patch:
diff --git a/packages/devextreme-react-generator/src/generator.test.ts b/packages/devextreme-react-generator/src/generator.test.ts
index 88f2be6..a7d0dac 100644
--- a/packages/devextreme-react-generator/src/generator.test.ts
+++ b/packages/devextreme-react-generator/src/generator.test.ts
@@ -140,9 +140,40 @@ describe('collectIndependentEvents', () => {
         props: [],
         firedEvents: [],
       },
+      {
+        name: 'valueChange',
+        isSubscribable: true,
+        types: [
+          {
+            type: 'Function',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+        ],
+        props: [],
+        firedEvents: [],
+      },
+      {
+        name: 'onSomeValueChanged',
+        isSubscribable: true,
+        types: [
+          {
+            type: 'Function',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+          {
+            type: 'Number',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+        ],
+        props: [],
+        firedEvents: [],
+      },
     ];
     const independentEvents = collectIndependentEvents(options);
-    expect(independentEvents.length).toBe(2);
+    expect(independentEvents.length).toBe(3);
     expect(independentEvents[0]).toEqual(options[1]);
     expect(independentEvents[1]).toEqual(options[6]);
   });
Repository: DevExpress/devextreme-react
Pull request #625 (2021-11-03 10:33:46)

Add possibility to skip option roll back (T1037806)


Patch:
diff --git a/packages/devextreme-react/src/core/options-manager.ts b/packages/devextreme-react/src/core/options-manager.ts
index 154c8e2..35977aa 100644
--- a/packages/devextreme-react/src/core/options-manager.ts
+++ b/packages/devextreme-react/src/core/options-manager.ts
@@ -147,7 +147,7 @@ class OptionsManager {
         && e.value instanceof Object
         && shallowEquals(value as Record<string, unknown>, e.value as Record<string, unknown>);
 
-      if (valuesAreEqual || valuesAreEqualObjects) {
+      if (valuesAreEqual || valuesAreEqualObjects || this.instance.skipOptionsRollBack) {
         return;
       }
 


Test patch:
diff --git a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
index c1b237e..3d76590 100644
--- a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
+++ b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
@@ -285,6 +285,24 @@ describe('option control', () => {
     expect(Widget.option.mock.calls[0]).toEqual(['complexOption', { a: 123, b: 234 }]);
   });
 
+  // T1037806
+  it('no rolls back option. skipOptionsRollBack = true', () => {
+    render(
+      <ControlledComponent complexOption={{ a: 123, b: 234 }} />,
+    );
+
+    try {
+      Widget.skipOptionsRollBack = true;
+
+      fireOptionChange('complexOption', {});
+      jest.runAllTimers();
+
+      expect(Widget.option.mock.calls.length).toBe(0);
+    } finally {
+      Widget.skipOptionsRollBack = false;
+    }
+  });
+
   it('rolls back complex option controlled field', () => {
     render(
       <ControlledComponent complexOption={{ a: 123 }} />,
diff --git a/packages/devextreme-react/src/core/__tests__/test-component.ts b/packages/devextreme-react/src/core/__tests__/test-component.ts
index a14242e..cb7f27c 100644
--- a/packages/devextreme-react/src/core/__tests__/test-component.ts
+++ b/packages/devextreme-react/src/core/__tests__/test-component.ts
@@ -19,6 +19,7 @@ const Widget = {
     eventHandlers[event] = eventHandlers[event].filter((e) => e !== handler);
   },
   dispose: jest.fn(),
+  skipOptionsRollBack: false,
 };
 
 const WidgetClass = jest.fn(() => Widget);
Repository: DevExpress/devextreme-react
Pull request #630 (2021-11-11 14:10:14)

Add possibility to skip option roll back (T1037806)


Patch:
diff --git a/packages/devextreme-react/src/core/options-manager.ts b/packages/devextreme-react/src/core/options-manager.ts
index 154c8e2..35977aa 100644
--- a/packages/devextreme-react/src/core/options-manager.ts
+++ b/packages/devextreme-react/src/core/options-manager.ts
@@ -147,7 +147,7 @@ class OptionsManager {
         && e.value instanceof Object
         && shallowEquals(value as Record<string, unknown>, e.value as Record<string, unknown>);
 
-      if (valuesAreEqual || valuesAreEqualObjects) {
+      if (valuesAreEqual || valuesAreEqualObjects || this.instance.skipOptionsRollBack) {
         return;
       }
 


Test patch:
diff --git a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
index 5fe15a8..7f68f97 100644
--- a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
+++ b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
@@ -262,6 +262,24 @@ describe('option control', () => {
     expect(Widget.option.mock.calls[0]).toEqual(['complexOption', { a: 123, b: 234 }]);
   });
 
+  // T1037806
+  it('no rolls back option. skipOptionsRollBack = true', () => {
+    render(
+      <ControlledComponent complexOption={{ a: 123, b: 234 }} />,
+    );
+
+    try {
+      Widget.skipOptionsRollBack = true;
+
+      fireOptionChange('complexOption', {});
+      jest.runAllTimers();
+
+      expect(Widget.option.mock.calls.length).toBe(0);
+    } finally {
+      Widget.skipOptionsRollBack = false;
+    }
+  });
+
   it('rolls back complex option controlled field', () => {
     render(
       <ControlledComponent complexOption={{ a: 123 }} />,
diff --git a/packages/devextreme-react/src/core/__tests__/test-component.ts b/packages/devextreme-react/src/core/__tests__/test-component.ts
index a14242e..cb7f27c 100644
--- a/packages/devextreme-react/src/core/__tests__/test-component.ts
+++ b/packages/devextreme-react/src/core/__tests__/test-component.ts
@@ -19,6 +19,7 @@ const Widget = {
     eventHandlers[event] = eventHandlers[event].filter((e) => e !== handler);
   },
   dispose: jest.fn(),
+  skipOptionsRollBack: false,
 };
 
 const WidgetClass = jest.fn(() => Widget);
Repository: DevExpress/devextreme-react
Pull request #640 (2022-01-13 15:11:52)

Fix generic components generation
##  1. Add defaults for generic components' classes
Make it possible to use components' classes as types without specifying type params

### Before
```ts
const ref = useRef<DataGrid<any, any>>(...); // OK
const ref = useRef<DataGrid>(...); // compilation error
```

### After

```ts
const ref = useRef<DataGrid<any, any>>(...); // OK
const ref = useRef<DataGrid>(...); // OK
```

## 2.Fix the instance property type

## Before
Generic params are lost  and `any` defaults are used instead ( `dxDataGrid` is the same as `dxDataGrid<any, any>` )

```ts
    get instance(): dxDataGrid;
```

## After 

```ts
    get instance(): dxDataGrid<TRowData, TKey>;
```


Patch:
diff --git a/packages/devextreme-react-generator/src/component-generator.ts b/packages/devextreme-react-generator/src/component-generator.ts
index a80b749..b586650 100644
--- a/packages/devextreme-react-generator/src/component-generator.ts
+++ b/packages/devextreme-react-generator/src/component-generator.ts
@@ -351,9 +351,9 @@ const renderComponent: (model: {
   useRequestAnimationFrameFlag?: boolean;
   typeParams: string[] | undefined;
 }) => string = createTempate(
-  `class <#= it.className #>${TYPE_PARAMS} extends BaseComponent<<#= it.optionsName #>${TYPE_PARAMS}> {
+  `class <#= it.className #>${TYPE_PARAMS_WITH_DEFAULTS} extends BaseComponent<<#= it.optionsName #>${TYPE_PARAMS}> {
 
-  public get instance(): <#= it.widgetName #> {
+  public get instance(): <#= it.widgetName #>${TYPE_PARAMS} {
     return this._instance;
   }
 


Test patch:
diff --git a/packages/devextreme-react-generator/src/component-generator.test.ts b/packages/devextreme-react-generator/src/component-generator.test.ts
index 21a0d03..5e0f9a8 100644
--- a/packages/devextreme-react-generator/src/component-generator.test.ts
+++ b/packages/devextreme-react-generator/src/component-generator.test.ts
@@ -89,9 +89,9 @@ interface ICLASS_NAMEOptions<T1 = any, T2 = any> extends Properties<T1, T2>, IHt
   dataSource?: Properties<T1, T2>["dataSource"];
 }
 
-class CLASS_NAME<T1, T2> extends BaseComponent<ICLASS_NAMEOptions<T1, T2>> {
+class CLASS_NAME<T1 = any, T2 = any> extends BaseComponent<ICLASS_NAMEOptions<T1, T2>> {
 
-  public get instance(): dxCLASS_NAME {
+  public get instance(): dxCLASS_NAME<T1, T2> {
     return this._instance;
   }
Repository: DevExpress/devextreme-react
Pull request #641 (2022-01-14 10:55:14)

Fix generic components generation
Cherry-pick of #640 


Patch:
diff --git a/packages/devextreme-react-generator/src/component-generator.ts b/packages/devextreme-react-generator/src/component-generator.ts
index a80b749..b586650 100644
--- a/packages/devextreme-react-generator/src/component-generator.ts
+++ b/packages/devextreme-react-generator/src/component-generator.ts
@@ -351,9 +351,9 @@ const renderComponent: (model: {
   useRequestAnimationFrameFlag?: boolean;
   typeParams: string[] | undefined;
 }) => string = createTempate(
-  `class <#= it.className #>${TYPE_PARAMS} extends BaseComponent<<#= it.optionsName #>${TYPE_PARAMS}> {
+  `class <#= it.className #>${TYPE_PARAMS_WITH_DEFAULTS} extends BaseComponent<<#= it.optionsName #>${TYPE_PARAMS}> {
 
-  public get instance(): <#= it.widgetName #> {
+  public get instance(): <#= it.widgetName #>${TYPE_PARAMS} {
     return this._instance;
   }
 


Test patch:
diff --git a/packages/devextreme-react-generator/src/component-generator.test.ts b/packages/devextreme-react-generator/src/component-generator.test.ts
index 21a0d03..5e0f9a8 100644
--- a/packages/devextreme-react-generator/src/component-generator.test.ts
+++ b/packages/devextreme-react-generator/src/component-generator.test.ts
@@ -89,9 +89,9 @@ interface ICLASS_NAMEOptions<T1 = any, T2 = any> extends Properties<T1, T2>, IHt
   dataSource?: Properties<T1, T2>["dataSource"];
 }
 
-class CLASS_NAME<T1, T2> extends BaseComponent<ICLASS_NAMEOptions<T1, T2>> {
+class CLASS_NAME<T1 = any, T2 = any> extends BaseComponent<ICLASS_NAMEOptions<T1, T2>> {
 
-  public get instance(): dxCLASS_NAME {
+  public get instance(): dxCLASS_NAME<T1, T2> {
     return this._instance;
   }
Repository: DevExpress/devextreme-react
Pull request #748 (2022-07-28 12:30:17)

Template-renderer: fix template scheduled rendering (T1102789)


Patch:
diff --git a/packages/devextreme-react/src/core/templates-renderer.tsx b/packages/devextreme-react/src/core/templates-renderer.tsx
index 728a01c..00a3c62 100644
--- a/packages/devextreme-react/src/core/templates-renderer.tsx
+++ b/packages/devextreme-react/src/core/templates-renderer.tsx
@@ -6,7 +6,6 @@ import { TemplatesStore } from './templates-store';
 
 class TemplatesRenderer extends React.PureComponent<{ templatesStore: TemplatesStore }> {
   private updateScheduled = false;
-
   private mounted = false;
 
   componentDidMount(): void {
@@ -17,6 +16,10 @@ class TemplatesRenderer extends React.PureComponent<{ templatesStore: TemplatesS
     this.mounted = false;
   }
 
+  forceUpdateCallback = () => {
+    this.updateScheduled = false;
+  }
+
   public scheduleUpdate(useDeferUpdate: boolean): void {
     if (this.updateScheduled) {
       return;
@@ -27,9 +30,8 @@ class TemplatesRenderer extends React.PureComponent<{ templatesStore: TemplatesS
     const updateFunc = useDeferUpdate ? deferUpdate : requestAnimationFrame;
     updateFunc(() => {
       if (this.mounted) {
-        this.forceUpdate();
+        this.forceUpdate(this.forceUpdateCallback);
       }
-
       this.updateScheduled = false;
     });
   }


Test patch:
diff --git a/packages/devextreme-react/src/core/__tests__/templates-renderer.test.tsx b/packages/devextreme-react/src/core/__tests__/templates-renderer.test.tsx
index 2fbf21d..4da2f02 100644
--- a/packages/devextreme-react/src/core/__tests__/templates-renderer.test.tsx
+++ b/packages/devextreme-react/src/core/__tests__/templates-renderer.test.tsx
@@ -89,3 +89,30 @@ jest.mock('devextreme/core/utils/common', () => ({
     });
   });
 });
+
+fdescribe('option update', () => {
+  it('should call forceUpdateCallback and reset "updateScheduled" after forceUpdateCallback', async () => {
+    const ref = React.createRef<TemplatesRenderer>();
+    const templatesStore = new TemplatesStore(() => { });
+
+    deferUpdate.mockImplementation((func, _) => {
+      func();
+    });
+
+    render(<TemplatesRenderer templatesStore={templatesStore} ref={ref} />);
+
+    const current = ref.current!;
+    const actualForceUpdateCallback = current.forceUpdateCallback;
+    const spyForceUpdateCallback = jest.spyOn(current, 'forceUpdateCallback').mockImplementation(() => {
+      expect((current as any).updateScheduled).toEqual(true);
+
+      actualForceUpdateCallback();
+
+      expect((current as any).updateScheduled).toEqual(false);
+    });
+
+    current.scheduleUpdate(true);
+
+    expect(spyForceUpdateCallback).toHaveBeenCalledTimes(1);
+  });
+});