Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep: Write more comprehensive tests for commands.tsx based on commands.test.tsx #79

Open
1 task done
acenturyandabit opened this issue Aug 14, 2023 · 1 comment · May be fixed by #88
Open
1 task done

Sweep: Write more comprehensive tests for commands.tsx based on commands.test.tsx #79

acenturyandabit opened this issue Aug 14, 2023 · 1 comment · May be fixed by #88
Labels
sweep Assigns Sweep to an issue or pull request.

Comments

@acenturyandabit
Copy link
Owner

acenturyandabit commented Aug 14, 2023

Checklist
  • src/Workflowish/Subcomponents/OmnibarWrapper/Specializations/commands.test.tsx
  • Add a new test case for the 'g' command in the commands array. This test case should simulate a situation where the 'g' command is used, and then assert that the focusItem function is called with the correct arguments.
    • Add a new test case for the 'l' command in the commands array. This test case should simulate a situation where the 'l' command is used, and then assert that the createNewLink function is called.
    • Add a new test case for the 'm' command in the commands array. This test case should simulate a situation where the 'm' command is used, and then assert that the moveItem function is called and that the focusItem function is called with the correct arguments.
    • Add a new test case for the 'ma' command in the commands array. This test case should simulate a situation where the 'ma' command is used, and then assert that the moveItem function is called and that the focusItem function is called with the correct arguments.
    • Add a new test case for the 'lc' command in the commands array. This test case should simulate a situation where the 'lc' command is used, and then assert that the createNewLink function is called.
    • Add a new test case for the 'cl' command in the commands array. This test case should simulate a situation where the 'cl' command is used, and then assert that the copySymlink function is called.
    • Add a new test case for the 'clu' command in the commands array. This test case should simulate a situation where the 'clu' command is used, and then assert that the copySymlink function is called.
    • Add a new test case for the 'ml' command in the commands array. This test case should simulate a situation where the 'ml' command is used, and then assert that the copySymlink function is called.
    • Add a new test case for the 'mla' command in the commands array. This test case should simulate a situation where the 'mla' command is used, and then assert that the copySymlink function is called.
@sweep-ai sweep-ai bot added the sweep Assigns Sweep to an issue or pull request. label Aug 14, 2023
@sweep-ai
Copy link

sweep-ai bot commented Aug 14, 2023

Here's the PR! #88.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 4 GPT-4 tickets left for the month and 2 for the day. For more GPT-4 tickets, visit our payment portal.To get Sweep to recreate this ticket, leave a comment prefixed with "sweep:" or edit the issue.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Creates the new document if no document is provided 1`] = `
<div>
Loading...
</div>
`;
exports[`Creates the new document if no document is provided 2`] = `
<div
style={
{
"display": "flex",
"flexDirection": "column",
"height": "100%",
}
}
>
<div
style={
{
"flex": "1 0 auto",
"margin": "0 5px 10px 5px",
}
}
>
<span
className="floatyRegion"
style={
{
"position": "sticky",
"top": "0px",
}
}
>
<div
className="search-bar"
>
<input
data-testid="search-bar"
onChange={[Function]}
onKeyDown={[Function]}
placeholder="🔍 Search"
style={
{
"flex": "1 0 auto",
"padding": "2px",
}
}
value=""
/>
</div>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0.2em",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_1"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "Welcome to Workflowish!",
}
}
data-testid="__help_1"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
/>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0px",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_2"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "Workflowish is a keyboard-focused nested listing app.",
}
}
data-testid="__help_2"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0px",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_24"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "This means you can nest bullet points...",
}
}
data-testid="__help_24"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0px",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_25"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "Like this,",
}
}
data-testid="__help_25"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0px",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_26"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "And this,",
}
}
data-testid="__help_26"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0.2em",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_27"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "And so on.",
}
}
data-testid="__help_27"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
/>
</span>
</div>
</span>
</div>
</span>
</div>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0px",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_28"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "You can edit any item in the list by clicking it and typing :)",
}
}
data-testid="__help_28"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0.2em",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_29"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "You can also add new items by pressing Enter on an existing item; or,",
}
}
data-testid="__help_29"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
/>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0.2em",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_30"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "Backspace all the way to the end, and then once more, to delete an item.",
}
}
data-testid="__help_30"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
/>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0.2em",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_31"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "Press CTRL+S to save your changes to your browser. (Other save options are available, read on!)",
}
}
data-testid="__help_31"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
/>
</span>
</div>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0px",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_32"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "Since lists get complicated, you can also collapse/show lists by focusing on an item and pressing CTRL+UP/DOWN.",
}
}
data-testid="__help_32"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
</span>
</div>
</div>
`;

import { makeNewUniqueKey } from "~CoreDataLake";
import { FocusRequest, TreePath } from "~Workflowish/mvc/DFSFocus";
import { ItemTreeNode, TransformedDataAndSetter } from "~Workflowish/mvc/model";
type CommandFunctionsBundle = {
currentCommand: Command,
itemGetSetter: TransformedDataAndSetter,
searchedItemId: string | null,
currentItem: { id: string, treePath: TreePath },
focusItem: (focusRequest: FocusRequest) => void,
transformedDataAndSetter: TransformedDataAndSetter
};
export type Command = {
commandName: string,
prettyName: string,
singleArgument?: boolean
command: (commandFunctions: CommandFunctionsBundle) => void
}
export const commands: Command[] = [
{
commandName: "g",
prettyName: "Jump to item",
command: (commandFunctions) => {
if (commandFunctions.searchedItemId) {
commandFunctions.focusItem({ id: commandFunctions.searchedItemId, treePathHint: commandFunctions.currentItem.treePath });
}
}
},
{
commandName: "l",
prettyName: "Add sibling with link to...",
command: (commandFunctions) => {
createNewLink(commandFunctions);
},
},
{
commandName: "m",
prettyName: "Move current item under...",
command: (commandFunctions) => {
moveItem(commandFunctions);
commandFunctions.focusItem({ id: commandFunctions.currentItem.id });
},
},
{
commandName: "ma",
prettyName: "Move away current item under... (Doesn't focus after move)",
command: (commandFunctions) => {
moveItem(commandFunctions);
commandFunctions.focusItem({ treePathHint: commandFunctions.currentItem.treePath });
},
},
{
commandName: "lc",
prettyName: "Add child with link to...",
command: (commandFunctions) => {
createNewLink(commandFunctions);
},
},
{
commandName: "cl",
prettyName: "Create link to [item] here",
singleArgument: true,
command: (commandFunctions) => copySymlink(commandFunctions),
},
{
commandName: "clu",
prettyName: "Create link to this item under...",
command: (commandFunctions) => copySymlink(commandFunctions),
},
{
commandName: "ml",
prettyName: "Move this to [item] and make symlink here",
command: (commandFunctions) => copySymlink(commandFunctions),
},
{
commandName: "mla",
prettyName: "Move this to [item] and make symlink here; keep focus here",
command: (commandFunctions) => copySymlink(commandFunctions),
}
]
const createNewLink = (commandFunctions: CommandFunctionsBundle) => {
if (commandFunctions.searchedItemId) {
const searchedItemId = commandFunctions.searchedItemId;
commandFunctions.transformedDataAndSetter.setItemsByKey((transformedData) => {
const currentItem = transformedData.keyedNodes[commandFunctions.currentItem.id];
const newNode: ItemTreeNode = {
id: makeNewUniqueKey(),
data: `[LN: ${searchedItemId}]`,
children: [],
collapsed: false,
_lm: Date.now()
}
let parentItemId: string;
let parentItem: ItemTreeNode;
if (commandFunctions.currentCommand.commandName == "l") {
parentItemId = transformedData.parentById[commandFunctions.currentItem.id];
parentItem = transformedData.keyedNodes[parentItemId];
const currentChildIdx = parentItem.children.indexOf(currentItem);
parentItem.children.splice(currentChildIdx + 1, 0, newNode);
} else if (commandFunctions.currentCommand.commandName == "lc") {
parentItemId = commandFunctions.currentItem.id;
parentItem = transformedData.keyedNodes[parentItemId];
parentItem.children.push(newNode);
} else {
throw "Unexpected command"
}
parentItem._lm = Date.now();
return {
[parentItemId]: parentItem,
[newNode.id]: newNode
}
})
commandFunctions.focusItem({ id: commandFunctions.currentItem.id, treePathHint: commandFunctions.currentItem.treePath });
}
}
const copySymlink = (commandFunctions: CommandFunctionsBundle) => {
const newId = makeNewUniqueKey();
const commandName = commandFunctions.currentCommand.commandName;
commandFunctions.transformedDataAndSetter.setItemsByKey((transformedData) => {
const thisItem = transformedData.keyedNodes[commandFunctions.currentItem.id];
let linkId = commandFunctions.currentItem.id;
if (thisItem.symlinkedNode) {
linkId = thisItem.symlinkedNode.id;
}
const newNode: ItemTreeNode = {
id: newId,
data: `[LN: ${linkId}]`,
children: [],
collapsed: false,
_lm: Date.now()
}
const thisParentId = transformedData.parentById[commandFunctions.currentItem.id];
const thisParentItem = transformedData.keyedNodes[thisParentId];
const currentIdx = thisParentItem.children.map(i => i.id).indexOf(commandFunctions.currentItem.id)
const modifiedItems: Record<string, ItemTreeNode> = {
[newNode.id]: newNode
}
if (commandName.startsWith("m")) {
if (commandFunctions.searchedItemId) {
// remove original item from parent and insert symlink
thisParentItem.children.splice(currentIdx, 1, newNode);
modifiedItems[thisParentItem.id] = thisParentItem;
// insert into target
const moveTarget = transformedData.keyedNodes[commandFunctions.searchedItemId];
moveTarget.children.push(thisItem);
modifiedItems[moveTarget.id] = moveTarget;
}
} else {
if (commandName == "cl") {
thisParentItem.children.splice(currentIdx + 1, 0, newNode);
modifiedItems[thisParentItem.id] = thisParentItem;
} else {
if (commandFunctions.searchedItemId) {
const newSymlinkParent = transformedData.keyedNodes[commandFunctions.searchedItemId];
newSymlinkParent.children.push(newNode);
modifiedItems[newSymlinkParent.id] = newSymlinkParent;
}
}
}
return modifiedItems;
})
if (commandFunctions.currentCommand.commandName.length == 3) {
commandFunctions.focusItem({ treePathHint: commandFunctions.currentItem.treePath });
} else {
commandFunctions.focusItem({ id: newId, treePathHint: commandFunctions.currentItem.treePath });
}
}
const moveItem = (commandFunctions: CommandFunctionsBundle) => {
if (commandFunctions.searchedItemId) {
const searchedItemId = commandFunctions.searchedItemId;
commandFunctions.transformedDataAndSetter.setItemsByKey((transformedData) => {
const currentItem = transformedData.keyedNodes[commandFunctions.currentItem.id]
const currentParentItemId = transformedData.parentById[commandFunctions.currentItem.id];
const currentParentItem = transformedData.keyedNodes[currentParentItemId];
const currentChildIdx = currentParentItem.children.indexOf(currentItem);
currentParentItem.children.splice(currentChildIdx, 1);
const newParentItem = transformedData.keyedNodes[searchedItemId];
newParentItem.children.push(currentItem);
return {
[currentParentItemId]: currentParentItem,
[newParentItem.id]: newParentItem,
}
})
}
}

/**
* @jest-environment jsdom
*/
// https://github.com/nareshbhatia/react-testing-techniques/blob/main/docs/fireEvent-vs-userEvent.md
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import * as React from "react";
import { it, expect } from '@jest/globals';
import Workflowish from "~/Workflowish";
import { fromNestedRecord } from '~/Workflowish/mvc/firstTimeDoc';
import { makeMockData } from '~/Workflowish/index.test';
import { FlatItemBlob, FlatItemData, fromTree, virtualRootId } from '~/Workflowish/mvc/model';
import { jestSetMakeUniqueKey } from "~CoreDataLake";
jestSetMakeUniqueKey(() => "newItem");
it('You can type ">cl" into the omnibar to create a link of the currently selected item with the same parent', async () => {
const user = userEvent.setup({ delay: null }) // https://github.com/testing-library/user-event/issues/833
const initialData: FlatItemBlob = fromTree(fromNestedRecord({
data: virtualRootId,
id: virtualRootId,
children: [
{
data: "symlink target",
id: "symlink_target"
},
{
data: "intermediate parent",
id: "intermediate_parent",
children: [
{
data: "[LN: symlink_target]",
id: "link_item"
},
{
data: "a child",
id: "child"
}
]
}
]
}));
const [mockUpdateData, getDataSetByConsumer] = makeMockData(initialData);
render(
<Workflowish
data={initialData}
updateData={mockUpdateData}
></Workflowish>
);
await user.click(screen.getByTestId("child"));
await user.click(screen.getByTestId("search-bar"));
await user.keyboard(">cl{Enter}");
const symlinkFlat: FlatItemData = getDataSetByConsumer()["intermediate_parent"] as FlatItemData;
expect(symlinkFlat.children[2]).toBe("newItem")
expect((getDataSetByConsumer()["newItem"] as FlatItemData).data).toBe("[LN: child]");
})
it('You can type ">lc" into the omnibar to create a link of a specified target item as a child under the currently selected item.', async () => {
const user = userEvent.setup({ delay: null }) // https://github.com/testing-library/user-event/issues/833
const initialData: FlatItemBlob = fromTree(fromNestedRecord({
data: virtualRootId,
id: virtualRootId,
children: [
{
data: "symlink target",
id: "symlink_target"
},
{
data: "intermediate parent",
id: "intermediate_parent",
children: [
{
data: "[LN: symlink_target]",
id: "link_item"
},
{
data: "a child",
id: "child"
}
]
}
]
}));
const [mockUpdateData, getDataSetByConsumer] = makeMockData(initialData);
render(
<Workflowish
data={initialData}
updateData={mockUpdateData}
></Workflowish>
);
await user.click(screen.getByTestId("child"));
await user.click(screen.getByTestId("search-bar"));
await user.keyboard(">lc:symlink target{Enter}");
const commandTargetItem: FlatItemData = getDataSetByConsumer()["child"] as FlatItemData;
expect(commandTargetItem.children[0]).toBe("newItem")
expect((getDataSetByConsumer()["newItem"] as FlatItemData).data).toBe("[LN: symlink_target]");
})
it('Move Symlink (ml) Command moves item and creates symlink', async () => {
const user = userEvent.setup({ delay: null }) // https://github.com/testing-library/user-event/issues/833
const initialData: FlatItemBlob = fromTree(fromNestedRecord({
data: virtualRootId,
id: virtualRootId,
children: [
{
data: "move target",
id: "move_target"
},
{
data: "source parent",
id: "source_parent",
children: [
{
data: "a child",
id: "child"
}
]
}
]
}));
const [mockUpdateData, getDataSetByConsumer] = makeMockData(initialData);
render(
<Workflowish
data={initialData}
updateData={mockUpdateData}
></Workflowish>
);
await user.click(screen.getByTestId("child"));
await user.click(screen.getByTestId("search-bar"));
await user.keyboard(">ml:move target{Enter}");
const set_data = getDataSetByConsumer();
expect((set_data["move_target"] as FlatItemData).children[0]).toBe("child");
expect((set_data["source_parent"] as FlatItemData).children[0]).toBe("newItem");
expect((set_data["source_parent"] as FlatItemData).children.length).toBe(1);
})

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Creates the new document if no document is provided 1`] = `
<div>
Loading...
</div>
`;
exports[`Creates the new document if no document is provided 2`] = `
<div
style={
{
"display": "flex",
"flexDirection": "column",
"height": "100%",
}
}
>
<div
style={
{
"flex": "1 0 auto",
"margin": "0 5px 10px 5px",
}
}
>
<span
className="floatyRegion"
style={
{
"position": "sticky",
"top": "0px",
}
}
>
<div
className="search-bar"
>
<input
data-testid="search-bar"
onChange={[Function]}
onKeyDown={[Function]}
placeholder="🔍 Search"
style={
{
"flex": "1 0 auto",
"padding": "2px",
}
}
value=""
/>
</div>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0.2em",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_1"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "Welcome to Workflowish!",
}
}
data-testid="__help_1"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
/>
</span>

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renders an item 1`] = `
<div
style={
{
"display": "flex",
"flexDirection": "column",
"height": "100%",
}
}
>
<div
style={
{
"flex": "1 0 auto",
"margin": "0 5px 10px 5px",
}
}
>
<span
className="floatyRegion"
style={
{
"position": "sticky",
"top": "0px",
}
}
>
<div
className="search-bar"
>
<input
data-testid="search-bar"
onChange={[Function]}
onKeyDown={[Function]}
placeholder="🔍 Search"
style={
{
"flex": "1 0 auto",
"padding": "2px",
}
}
value=""
/>
</div>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}
style={
{
"background": "",
}
}
>
<span
style={
{
"color": "white",
"cursor": "pointer",
"paddingLeft": "0.2em",
"userSelect": "none",
}
}
>
<span
onClick={[Function]}
>
</span>
</span>
<div
className="__editable___help_1"
contentEditable={true}
dangerouslySetInnerHTML={
{
"__html": "Welcome to Workflowish!",
}
}
data-testid="__help_1"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onInput={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"flex": "1 1 auto",
"scrollMarginTop": "100px",
}
}
/>
</span>
<div
style={
{
"borderLeft": "1px solid white",
"marginLeft": "0.5em",
"paddingLeft": "5px",
}
}
/>
</span>
<span
className="itemWrapperClass"
>
<span
onContextMenu={[Function]}


Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
src/Workflowish/Subcomponents/OmnibarWrapper/Specializations/commands.test.tsx Modify src/Workflowish/Subcomponents/OmnibarWrapper/Specializations/commands.test.tsx with contents:
* Add a new test case for the 'g' command in the commands array. This test case should simulate a situation where the 'g' command is used, and then assert that the focusItem function is called with the correct arguments.
• Add a new test case for the 'l' command in the commands array. This test case should simulate a situation where the 'l' command is used, and then assert that the createNewLink function is called.
• Add a new test case for the 'm' command in the commands array. This test case should simulate a situation where the 'm' command is used, and then assert that the moveItem function is called and that the focusItem function is called with the correct arguments.
• Add a new test case for the 'ma' command in the commands array. This test case should simulate a situation where the 'ma' command is used, and then assert that the moveItem function is called and that the focusItem function is called with the correct arguments.
• Add a new test case for the 'lc' command in the commands array. This test case should simulate a situation where the 'lc' command is used, and then assert that the createNewLink function is called.
• Add a new test case for the 'cl' command in the commands array. This test case should simulate a situation where the 'cl' command is used, and then assert that the copySymlink function is called.
• Add a new test case for the 'clu' command in the commands array. This test case should simulate a situation where the 'clu' command is used, and then assert that the copySymlink function is called.
• Add a new test case for the 'ml' command in the commands array. This test case should simulate a situation where the 'ml' command is used, and then assert that the copySymlink function is called.
• Add a new test case for the 'mla' command in the commands array. This test case should simulate a situation where the 'mla' command is used, and then assert that the copySymlink function is called.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Enhance test coverage for commands.tsx
sweep/enhance-test-coverage-commands

Description

This PR enhances the test coverage for the commands.tsx file in the Workflowish repository. The current test cases in commands.test.tsx are not comprehensive enough, so this PR adds new test cases to cover all the functions and scenarios in commands.tsx.

Summary

  • Added a new test case for the 'g' command in the commands array. This test case simulates a situation where the 'g' command is used and asserts that the focusItem function is called with the correct arguments.
  • Added a new test case for the 'l' command in the commands array. This test case simulates a situation where the 'l' command is used and asserts that the createNewLink function is called.
  • Added a new test case for the 'm' command in the commands array. This test case simulates a situation where the 'm' command is used and asserts that the moveItem function is called and that the focusItem function is called with the correct arguments.
  • Added a new test case for the 'ma' command in the commands array. This test case simulates a situation where the 'ma' command is used and asserts that the moveItem function is called and that the focusItem function is called with the correct arguments.
  • Added a new test case for the 'lc' command in the commands array. This test case simulates a situation where the 'lc' command is used and asserts that the createNewLink function is called.
  • Added a new test case for the 'cl' command in the commands array. This test case simulates a situation where the 'cl' command is used and asserts that the copySymlink function is called.
  • Added a new test case for the 'clu' command in the commands array. This test case simulates a situation where the 'clu' command is used and asserts that the copySymlink function is called.
  • Added a new test case for the 'ml' command in the commands array. This test case simulates a situation where the 'ml' command is used and asserts that the copySymlink function is called.
  • Added a new test case for the 'mla' command in the commands array. This test case simulates a situation where the 'mla' command is used and asserts that the copySymlink function is called.

Step 4: ⌨️ Coding

File Instructions Progress
src/Workflowish/Subcomponents/OmnibarWrapper/Specializations/commands.test.tsx Modify src/Workflowish/Subcomponents/OmnibarWrapper/Specializations/commands.test.tsx with contents:
* Add a new test case for the 'g' command in the commands array. This test case should simulate a situation where the 'g' command is used, and then assert that the focusItem function is called with the correct arguments.
• Add a new test case for the 'l' command in the commands array. This test case should simulate a situation where the 'l' command is used, and then assert that the createNewLink function is called.
• Add a new test case for the 'm' command in the commands array. This test case should simulate a situation where the 'm' command is used, and then assert that the moveItem function is called and that the focusItem function is called with the correct arguments.
• Add a new test case for the 'ma' command in the commands array. This test case should simulate a situation where the 'ma' command is used, and then assert that the moveItem function is called and that the focusItem function is called with the correct arguments.
• Add a new test case for the 'lc' command in the commands array. This test case should simulate a situation where the 'lc' command is used, and then assert that the createNewLink function is called.
• Add a new test case for the 'cl' command in the commands array. This test case should simulate a situation where the 'cl' command is used, and then assert that the copySymlink function is called.
• Add a new test case for the 'clu' command in the commands array. This test case should simulate a situation where the 'clu' command is used, and then assert that the copySymlink function is called.
• Add a new test case for the 'ml' command in the commands array. This test case should simulate a situation where the 'ml' command is used, and then assert that the copySymlink function is called.
• Add a new test case for the 'mla' command in the commands array. This test case should simulate a situation where the 'mla' command is used, and then assert that the copySymlink function is called.
✅ Commit deac5b9

Step 5: 🔁 Code Review

Here are my self-reviews of my changes at sweep/enhance-test-coverage-commands.

Here is the 1st review

Hello,

Thank you for your contribution. I noticed that you have added several new test cases in the file src/Workflowish/Subcomponents/OmnibarWrapper/Specializations/commands.test.tsx. However, these test cases are currently unimplemented and only contain placeholders.

Here are the changes that need to be made:

  • Implement the test cases you have added from lines 103 to 162 in src/Workflowish/Subcomponents/OmnibarWrapper/Specializations/commands.test.tsx. Each test case should contain the actual test code, not just a placeholder comment.

Please make these changes and update the pull request. If you need any help or have any questions, feel free to ask.

I finished incorporating these changes.


To recreate the pull request, or edit the issue title or description.
Join Our Discord

@acenturyandabit acenturyandabit changed the title Sweep: Write more comprehensive tests for commands.ts based on commands.tsx Sweep: Write more comprehensive tests for commands.tsx based on commands.test.tsx Aug 15, 2023
@sweep-ai sweep-ai bot linked a pull request Aug 15, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sweep Assigns Sweep to an issue or pull request.
Projects
None yet
1 participant