Reenable windows test for DataInspector (#1102)
Summary: Requires https://github.com/facebook/flipper/issues/1101. Pull Request resolved: https://github.com/facebook/flipper/pull/1102 Test Plan: CI Reviewed By: nikoant Differential Revision: D21379837 Pulled By: passy fbshipit-source-id: 64afbf20eb246487fbccac2f0108996507a353ed
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9658d1468d
commit
5c60b2b94a
@@ -59,84 +59,74 @@ const json = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('DataInspector', () => {
|
test('changing collapsed property works', async () => {
|
||||||
if (process.platform === 'win32') {
|
const res = render(<ManagedDataInspector data={json} collapsed expandRoot />);
|
||||||
test('Skipping on Windows due to mocking not working', () => {});
|
expect(await res.findByText(/is/)).toBeTruthy(); // from expandRoot
|
||||||
return;
|
expect((await res.queryAllByText(/cool/)).length).toBe(0);
|
||||||
}
|
|
||||||
|
|
||||||
test('changing collapsed property works', async () => {
|
res.rerender(
|
||||||
const res = render(
|
<ManagedDataInspector data={json} collapsed={false} expandRoot />,
|
||||||
<ManagedDataInspector data={json} collapsed expandRoot />,
|
);
|
||||||
);
|
await waitFor(() => res.findByText(/cool/));
|
||||||
expect(await res.findByText(/is/)).toBeTruthy(); // from expandRoot
|
|
||||||
expect((await res.queryAllByText(/cool/)).length).toBe(0);
|
|
||||||
|
|
||||||
res.rerender(
|
res.rerender(
|
||||||
<ManagedDataInspector data={json} collapsed={false} expandRoot />,
|
<ManagedDataInspector data={json} collapsed={true} expandRoot />,
|
||||||
);
|
);
|
||||||
await waitFor(() => res.findByText(/cool/));
|
expect((await res.queryAllByText(/cool/)).length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
res.rerender(
|
test('can manually collapse properties', async () => {
|
||||||
<ManagedDataInspector data={json} collapsed={true} expandRoot />,
|
const res = render(<ManagedDataInspector data={json} collapsed expandRoot />);
|
||||||
);
|
|
||||||
expect((await res.queryAllByText(/cool/)).length).toBe(0);
|
await res.findByText(/is/); // previewed as key, like: "data: {is, and}"
|
||||||
|
expect((await res.queryAllByText(/awesomely/)).length).toBe(0);
|
||||||
|
|
||||||
|
// expand twice
|
||||||
|
fireEvent.click(await res.findByText(/data/));
|
||||||
|
await res.findByText(/awesomely/);
|
||||||
|
expect((await res.queryAllByText(/cool/)).length).toBe(0);
|
||||||
|
|
||||||
|
fireEvent.click(await res.findByText(/is/));
|
||||||
|
await res.findByText(/cool/);
|
||||||
|
expect((await res.queryAllByText(/json/)).length).toBe(0); // this node is not shown
|
||||||
|
|
||||||
|
// collapsing everything again
|
||||||
|
fireEvent.click(await res.findByText(/data/));
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(res.queryByText(/awesomely/)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can manually collapse properties', async () => {
|
// expand everything again, expanded paths will have been remembered
|
||||||
const res = render(
|
fireEvent.click(await res.findByText(/data/));
|
||||||
<ManagedDataInspector data={json} collapsed expandRoot />,
|
await res.findByText(/is/);
|
||||||
|
await res.findByText(/awesomely/);
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(res.queryByText(/json/)).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('can filter for data', async () => {
|
||||||
|
const res = render(
|
||||||
|
<ManagedDataInspector data={json} collapsed={false} expandRoot />,
|
||||||
|
);
|
||||||
|
await res.findByText(/awesomely/); // everything is shown
|
||||||
|
|
||||||
|
// act here is used to make sure the highlight changes have propagated
|
||||||
|
await act(async () => {
|
||||||
|
res.rerender(
|
||||||
|
<ManagedDataInspector
|
||||||
|
data={json}
|
||||||
|
collapsed={false}
|
||||||
|
expandRoot
|
||||||
|
filter="sOn"
|
||||||
|
/>,
|
||||||
);
|
);
|
||||||
|
await sleep(200);
|
||||||
await res.findByText(/is/); // previewed as key, like: "data: {is, and}"
|
|
||||||
expect((await res.queryAllByText(/awesomely/)).length).toBe(0);
|
|
||||||
|
|
||||||
// expand twice
|
|
||||||
fireEvent.click(await res.findByText(/data/));
|
|
||||||
await res.findByText(/awesomely/);
|
|
||||||
expect((await res.queryAllByText(/cool/)).length).toBe(0);
|
|
||||||
|
|
||||||
fireEvent.click(await res.findByText(/is/));
|
|
||||||
await res.findByText(/cool/);
|
|
||||||
expect((await res.queryAllByText(/json/)).length).toBe(0); // this node is not shown
|
|
||||||
|
|
||||||
// collapsing everything again
|
|
||||||
fireEvent.click(await res.findByText(/data/));
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(res.queryByText(/awesomely/)).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
// expand everything again, expanded paths will have been remembered
|
|
||||||
fireEvent.click(await res.findByText(/data/));
|
|
||||||
await res.findByText(/is/);
|
|
||||||
await res.findByText(/awesomely/);
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(res.queryByText(/json/)).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can filter for data', async () => {
|
const element = await res.findByText(/son/); // N.B. search for 'son', as the text was split up
|
||||||
const res = render(
|
// snapshot to make sure the hilighiting did it's job
|
||||||
<ManagedDataInspector data={json} collapsed={false} expandRoot />,
|
expect(element.parentElement).toMatchInlineSnapshot(`
|
||||||
);
|
|
||||||
await res.findByText(/awesomely/); // everything is shown
|
|
||||||
|
|
||||||
// act here is used to make sure the highlight changes have propagated
|
|
||||||
await act(async () => {
|
|
||||||
res.rerender(
|
|
||||||
<ManagedDataInspector
|
|
||||||
data={json}
|
|
||||||
collapsed={false}
|
|
||||||
expandRoot
|
|
||||||
filter="sOn"
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
await sleep(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
const element = await res.findByText(/son/); // N.B. search for 'son', as the text was split up
|
|
||||||
// snapshot to make sure the hilighiting did it's job
|
|
||||||
expect(element.parentElement).toMatchInlineSnapshot(`
|
|
||||||
<span>
|
<span>
|
||||||
"j
|
"j
|
||||||
<span
|
<span
|
||||||
@@ -147,44 +137,43 @@ describe('DataInspector', () => {
|
|||||||
"
|
"
|
||||||
</span>
|
</span>
|
||||||
`);
|
`);
|
||||||
// hides the other part of the tree
|
// hides the other part of the tree
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(res.queryByText(/cool/)).toBeNull();
|
expect(res.queryByText(/cool/)).toBeNull();
|
||||||
});
|
|
||||||
|
|
||||||
// find by key
|
|
||||||
await act(async () => {
|
|
||||||
res.rerender(
|
|
||||||
<ManagedDataInspector
|
|
||||||
data={json}
|
|
||||||
collapsed={false}
|
|
||||||
expandRoot
|
|
||||||
filter="somel"
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
await sleep(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
await res.findByText(/cool/);
|
|
||||||
// hides the other part of the tree
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(res.queryByText(/json/)).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
await act(async () => {
|
|
||||||
res.rerender(
|
|
||||||
<ManagedDataInspector
|
|
||||||
data={json}
|
|
||||||
collapsed={false}
|
|
||||||
expandRoot
|
|
||||||
filter=""
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
await sleep(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
// everything visible again
|
|
||||||
await res.findByText(/awesomely/);
|
|
||||||
await res.findByText(/json/);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// find by key
|
||||||
|
await act(async () => {
|
||||||
|
res.rerender(
|
||||||
|
<ManagedDataInspector
|
||||||
|
data={json}
|
||||||
|
collapsed={false}
|
||||||
|
expandRoot
|
||||||
|
filter="somel"
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
await sleep(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
await res.findByText(/cool/);
|
||||||
|
// hides the other part of the tree
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(res.queryByText(/json/)).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
res.rerender(
|
||||||
|
<ManagedDataInspector
|
||||||
|
data={json}
|
||||||
|
collapsed={false}
|
||||||
|
expandRoot
|
||||||
|
filter=""
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
await sleep(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
// everything visible again
|
||||||
|
await res.findByText(/awesomely/);
|
||||||
|
await res.findByText(/json/);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user