Skip to content

Commit

Permalink
KOGITO-1788: Desktop sort recently opened files
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovmr committed May 11, 2020
1 parent 971afb4 commit eb7b629
Show file tree
Hide file tree
Showing 2 changed files with 428 additions and 16 deletions.
33 changes: 29 additions & 4 deletions packages/desktop/src/__tests__/webview/home/FilesPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("FilesPage", () => {
expect(component.asFragment()).toMatchSnapshot();
});

test("three recent files listed ordered alphabetically", () => {
test("three recent files in different directories listed ordered alphabetically", () => {
const openFile = jest.fn();
const openFileByPath = jest.fn();

Expand All @@ -75,11 +75,36 @@ describe("FilesPage", () => {
})
);

// alphabetical order
fireEvent.click(component.getByTestId("orderAlphabeticallyButton"));
expect(component.asFragment()).toMatchSnapshot();
});

test("three recent files listed ordered alphabetically reverse", () => {
test("three recent files in the same directory listed ordered alphabetically", () => {
const openFile = jest.fn();
const openFileByPath = jest.fn();

const component = render(
usingTestingGlobalContext(<FilesPage openFile={openFile} openFileByPath={openFileByPath} />).wrapper
);

act(() =>
electron.ipcRenderer.send("returnLastOpenedFiles", {
lastOpenedFiles: [
{ filePath: "/a/a.dmn", preview: "" },
{ filePath: "/a/b.dmn", preview: "" },
{ filePath: "/a/b.bpmn", preview: "" },
{ filePath: "/a/c.bpmn", preview: "" }
]
})
);

// alphabetical order
fireEvent.click(component.getByTestId("orderAlphabeticallyButton"));
expect(component.asFragment()).toMatchSnapshot();
});

test("three recent files listed ordered by access time", () => {
const openFile = jest.fn();
const openFileByPath = jest.fn();

Expand All @@ -97,9 +122,9 @@ describe("FilesPage", () => {
})
);

// standard order
// alphabetical order
fireEvent.click(component.getByTestId("orderAlphabeticallyButton"));
// reversed order
// access time order
fireEvent.click(component.getByTestId("orderAlphabeticallyButton"));
expect(component.asFragment()).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit eb7b629

Please sign in to comment.