Fix hotbar migration of workspaces (#3178)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-06-25 09:55:25 -04:00
1 parent b9dfd20a93
commit 51655884c7
39 files changed
+333 -446

No files matched your search

@@ -26,6 +26,14 @@ import React from "react";
import { ThemeStore } from "../../../theme.store";
import { UserStore } from "../../../../common/user-store";
import { Notifications } from "../../notifications";
import mockFs from "mock-fs";
jest.mock("electron", () => ({
app: {
getPath: () => "tmp",
setLoginItemSettings: jest.fn(),
},
}));
const mockHotbars: {[id: string]: any} = {
"1": {
@@ -48,6 +56,9 @@ jest.mock("../../../../common/hotbar-store", () => ({
describe("<HotbarRemoveCommand />", () => {
beforeEach(() => {
mockFs({
"tmp": {}
});
UserStore.createInstance();
ThemeStore.createInstance();
});
@@ -55,11 +66,12 @@ describe("<HotbarRemoveCommand />", () => {
afterEach(() => {
UserStore.resetInstance();
ThemeStore.resetInstance();
mockFs.restore();
});
it("renders w/o errors", () => {
const { container } = render(<HotbarRemoveCommand/>);
expect(container).toBeInstanceOf(HTMLElement);
});
@@ -73,4 +85,3 @@ describe("<HotbarRemoveCommand />", () => {
spy.mockRestore();
});
});
@@ -33,22 +33,14 @@ const uniqueHotbarName: InputValidator = {
@observer
export class HotbarAddCommand extends React.Component {
onSubmit(name: string) {
onSubmit = (name: string) => {
if (!name.trim()) {
return;
}
const hotbarStore = HotbarStore.getInstance();
const hotbar = hotbarStore.add({
name
});
hotbarStore.activeHotbarId = hotbar.id;
HotbarStore.getInstance().add({ name }, { setActive: true });
CommandOverlay.close();
}
};
render() {
return (
@@ -58,10 +50,11 @@ export class HotbarAddCommand extends React.Component {
autoFocus={true}
theme="round-black"
data-test-id="command-palette-hotbar-add-name"
validators={[uniqueHotbarName]}
onSubmit={(v) => this.onSubmit(v)}
validators={uniqueHotbarName}
onSubmit={this.onSubmit}
dirty={true}
showValidationLine={true} />
showValidationLine={true}
/>
<small className="hint">
Please provide a new hotbar name (Press &quot;Enter&quot; to confirm or &quot;Escape&quot; to cancel)
</small>