diff --git a/common/changes/@uifabric/example-app-base/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json b/common/changes/@uifabric/example-app-base/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json new file mode 100644 index 0000000000000..7ef56cf8e12fd --- /dev/null +++ b/common/changes/@uifabric/example-app-base/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/example-app-base", + "type": "none" + } + ], + "packageName": "@uifabric/example-app-base", + "email": "law@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/experiments/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json b/common/changes/@uifabric/experiments/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json new file mode 100644 index 0000000000000..5260536241508 --- /dev/null +++ b/common/changes/@uifabric/experiments/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/experiments", + "type": "none" + } + ], + "packageName": "@uifabric/experiments", + "email": "law@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/fabric-website/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json b/common/changes/@uifabric/fabric-website/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json new file mode 100644 index 0000000000000..71c75f3436166 --- /dev/null +++ b/common/changes/@uifabric/fabric-website/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/fabric-website", + "type": "none" + } + ], + "packageName": "@uifabric/fabric-website", + "email": "law@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/file-type-icons/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json b/common/changes/@uifabric/file-type-icons/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json new file mode 100644 index 0000000000000..88e044fe064bf --- /dev/null +++ b/common/changes/@uifabric/file-type-icons/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/file-type-icons", + "type": "none" + } + ], + "packageName": "@uifabric/file-type-icons", + "email": "law@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/icons/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json b/common/changes/@uifabric/icons/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json new file mode 100644 index 0000000000000..ee773e312980a --- /dev/null +++ b/common/changes/@uifabric/icons/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/icons", + "type": "none" + } + ], + "packageName": "@uifabric/icons", + "email": "law@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/styling/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json b/common/changes/@uifabric/styling/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json new file mode 100644 index 0000000000000..e9c457b38d420 --- /dev/null +++ b/common/changes/@uifabric/styling/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/styling", + "type": "none" + } + ], + "packageName": "@uifabric/styling", + "email": "law@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/variants/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json b/common/changes/@uifabric/variants/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json new file mode 100644 index 0000000000000..0b9da8cd27d93 --- /dev/null +++ b/common/changes/@uifabric/variants/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/variants", + "type": "none" + } + ], + "packageName": "@uifabric/variants", + "email": "law@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/office-ui-fabric-react/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json b/common/changes/office-ui-fabric-react/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json new file mode 100644 index 0000000000000..a4eeac94391bc --- /dev/null +++ b/common/changes/office-ui-fabric-react/magellan-fixDetailsListFocusTest_2018-02-24-00-36.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "[DetailsList] Fixed test by mocking visiblity", + "type": "patch" + } + ], + "packageName": "office-ui-fabric-react", + "email": "law@microsoft.com" +} \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsList.test.tsx b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsList.test.tsx index a02f86a9dc39c..0c4c88ed52644 100644 --- a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsList.test.tsx +++ b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsList.test.tsx @@ -62,8 +62,8 @@ describe('DetailsList', () => { expect(component).toBeDefined(); (component as IDetailsList).focusIndex(2); setTimeout(() => { - expect(document.activeElement.className.split(' ')).toContain('ms-DetailsRow'); expect(document.activeElement.textContent).toEqual('2'); + expect(document.activeElement.className.split(' ')).toContain('ms-DetailsRow'); }, 0); jest.runOnlyPendingTimers(); }); @@ -96,17 +96,26 @@ describe('DetailsList', () => { />); expect(component).toBeDefined(); - (component as IDetailsList).focusIndex(2); + (component as IDetailsList).focusIndex(3); setTimeout(() => { + expect(document.activeElement.textContent).toEqual('3'); expect(document.activeElement.className.split(' ')).toContain('ms-DetailsRow'); - expect(document.activeElement.textContent).toEqual('2'); }, 0); jest.runOnlyPendingTimers(); - (component as IDetailsList).focusIndex(2, true); + // Set element visibility manually as a test workaround + (component as IDetailsList).focusIndex(4); setTimeout(() => { + (document.activeElement.children[1] as any).isVisible = true; + (document.activeElement.children[1].children[0] as any).isVisible = true; + (document.activeElement.children[1].children[0].children[0] as any).isVisible = true; + }, 0); + + jest.runOnlyPendingTimers(); + (component as IDetailsList).focusIndex(4, true); + setTimeout(() => { + expect(document.activeElement.textContent).toEqual('4'); expect(document.activeElement.className.split(' ')).toContain('test-column'); - expect(document.activeElement.textContent).toEqual('2'); }, 0); jest.runOnlyPendingTimers(); });