Skip to content

Commit

Permalink
More data on click
Browse files Browse the repository at this point in the history
  • Loading branch information
bobalazek committed Dec 29, 2023
1 parent 8fd96f7 commit 2e27634
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 103 deletions.
96 changes: 12 additions & 84 deletions apps/web-e2e/src/e2e/features/tasks/tasks-tasks.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,7 @@ describe('tasks-tasks.cy.ts', () => {

cy.getBySel('tasks--tasks-form').find('input').type('My new task{enter}');

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.getBySel('tasks--task-edit-dialog').should('exist');
});
Expand All @@ -115,15 +107,7 @@ describe('tasks-tasks.cy.ts', () => {

cy.getBySel('tasks--tasks-form').find('input').type('My new task{enter}');

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.get('#task-name').clear();

Expand All @@ -144,29 +128,13 @@ describe('tasks-tasks.cy.ts', () => {

cy.getBySel('tasks--tasks-form').find('input').type('My new task{enter}');

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.get('#task-description').type('Task description.');

cy.get('button').contains('Save').click();

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.get('#task-description').contains('Task description.');
});
Expand All @@ -176,15 +144,7 @@ describe('tasks-tasks.cy.ts', () => {

cy.getBySel('tasks--tasks-form').find('input').type('My new task{enter}');

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.getBySel('list-selector--trigger-button').click();

Expand All @@ -198,75 +158,43 @@ describe('tasks-tasks.cy.ts', () => {

cy.getBySel('tasks--tasks-form').find('input').type('My new task{enter}');

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.get('button').contains('Save').click();

cy.contains('You have successfully saved the task').should('exist');
});

it('should close More dialog when clicking on Cancel', () => {
it('should close task dialog when clicking on Cancel', () => {
openTasksPopover();

cy.getBySel('tasks--tasks-form').find('input').type('My new task{enter}');

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.get('button').contains('Cancel').click();

cy.getBySel('tasks--task-edit-dialog').should('not.exist');
});

it('should close More dialog when clicking on the x (close) button in the right top corner in expanded edit options', () => {
it('should close task dialog when clicking on the x (close) button in the right top corner in expanded edit options', () => {
openTasksPopover();

cy.getBySel('tasks--tasks-form').find('input').type('My new task{enter}');

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.get('[data-test="dialog--close"]').click();

cy.getBySel('tasks--task-edit-dialog').should('not.exist');
});

it('should close More dialog when clicking outside the dialog', () => {
it('should close task dialog when clicking outside the dialog', () => {
openTasksPopover();

cy.getBySel('tasks--tasks-form').find('input').type('My new task{enter}');

cy.getBySel('tasks--task')
.first()
.find('[data-test="tasks--task--actions-dropdown-menu--trigger-button"]')
.click();

cy.getBySel('tasks--task--actions-dropdown-menu')
.find('div[role="menuitem"]')
.contains('More')
.click();
cy.getBySel('tasks--task').first().click();

cy.clickOutside();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ const TaskItemDueDate = ({ task }: { task: TaskType }) => {
};

const TaskItem = memo(({ task }: { task: TaskType }) => {
const { editTask, completeTask, uncompleteTask } = useTasksStore();
const { setSelectedTaskDialogOpen, editTask, completeTask, uncompleteTask } = useTasksStore();
const [showConfetti, setShowConfetti] = useState(false);
const textElementRef = useRef<HTMLDivElement | null>(null);

const onClick = async () => {
setSelectedTaskDialogOpen(true, task);
};

const onDoubleClick = useCallback(
(event?: React.MouseEvent<HTMLDivElement, MouseEvent>, cursorAtEnd?: boolean) => {
event?.stopPropagation();
Expand Down Expand Up @@ -123,6 +127,7 @@ const TaskItem = memo(({ task }: { task: TaskType }) => {
return (
<div
className="rounded-lg p-1 outline-none hover:bg-gray-50 dark:hover:bg-gray-800"
onClick={onClick}
data-test="tasks--task"
>
<div className="relative w-full">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
HistoryIcon,
InfoIcon,
ListIcon,
MoreVerticalIcon,
PencilIcon,
TrashIcon,
} from 'lucide-react';
import { HistoryIcon, ListIcon, MoreVerticalIcon, PencilIcon, TrashIcon } from 'lucide-react';
import { memo, useState } from 'react';

import { Task } from '@moaitime/shared-common';
Expand All @@ -26,7 +19,7 @@ import ListsSelectedListDropdownMenuContent from '../lists/ListsSelectedListDrop

const TaskItemActions = memo(
({ task, onEditAndFocus }: { task: Task; onEditAndFocus: () => void }) => {
const { deleteTask, undeleteTask, moveTask, setSelectedTaskDialogOpen } = useTasksStore();
const { deleteTask, undeleteTask, moveTask } = useTasksStore();
const { toast } = useToast();
const [dropdownMenuOpen, setDropdownMenuOpen] = useState(false);

Expand Down Expand Up @@ -119,15 +112,6 @@ const TaskItemActions = memo(
}}
/>
</DropdownMenuSub>
<DropdownMenuItem
className="cursor-pointer"
onClick={() => {
setSelectedTaskDialogOpen(true, task);
}}
>
<InfoIcon className="mr-2 h-4 w-4" />
<span>More</span>
</DropdownMenuItem>
{!task.deletedAt && (
<DropdownMenuItem
variant="destructive"
Expand Down

0 comments on commit 2e27634

Please sign in to comment.