TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.
TypeScript graphviewkanban-boardnodejsproductivityproject-managementself-hostedtasktask-managementtask-managertodoapp
fix: subtasks duplication
Nikolai Gimanc6b769a47647
diff --git a/web/.gitignore b/web/.gitignoreindex 34cdd11..9c23aa2 100644--- a/web/.gitignore+++ b/web/.gitignore@@ -35,4 +35,5 @@ Info.pliste2e_logse2e_pgdatae2e_updates-playwright-report\ No newline at end of file+playwright-report+test-results\ No newline at end of filediff --git a/web/e2e/auth.spec.ts b/web/e2e/auth.spec.tsindex 6c708d1..bc5d9a0 100644--- a/web/e2e/auth.spec.ts+++ b/web/e2e/auth.spec.ts@@ -1,29 +1,27 @@import { test, expect } from '@playwright/test'import { TEST_USER } from './fixtures/auth'+import { setEnglishLocale } from './test-helpers'test.describe('Login', () => {test.beforeEach(async ({ page }) => {await page.goto('/')+ await setEnglishLocale(page)+ await page.reload()})test('shows login page with welcome message', async ({ page }) => {- await expect(page.getByRole('heading', { level: 1 })).toContainText(/welcome|возвращением/i)+ await expect(page.getByRole('heading', { level: 1 })).toContainText(/welcome/i)})test('user can login with password and reach dashboard', async ({ page }) => {- // Switch to Password tab (default is Magic link)- await page.getByRole('tab', { name: /password|пароль/i }).click()+ await page.getByRole('tab', { name: /password/i }).click()- // Fill credentialsawait page.getByTestId('login-input').fill(TEST_USER.login)await page.getByTestId('password-input').fill(TEST_USER.password)- // Submitawait page.getByTestId('sign-in-button').click()- // Should redirect to user dashboardawait expect(page).toHaveURL(/\/user/)- // Dashboard should be visible (sidebar or main content)- await expect(page.locator('body')).not.toContainText(/invalid|неверный|error|ошибка/i)+ await expect(page.locator('body')).not.toContainText(/invalid|error/i)})})diff --git a/web/e2e/projects.spec.ts b/web/e2e/projects.spec.tsindex cab8d82..7640a71 100644--- a/web/e2e/projects.spec.ts+++ b/web/e2e/projects.spec.ts@@ -1,26 +1,22 @@import { test, expect } from '@playwright/test'-import { login } from './test-helpers'--async function addProject(page: import('@playwright/test').Page, name: string) {- const input = page.getByTestId('project-add-input').first()- await input.waitFor({ state: 'visible', timeout: 15000 })- await input.fill(name)- await input.press('Enter')- await expect(page.getByText(name).first()).toBeVisible({ timeout: 10000 })-}--async function openProjectMenu(page: import('@playwright/test').Page, projectName: string) {- const row = page.getByTestId(`project-row-${projectName}`)- await row.first().waitFor({ state: 'visible', timeout: 10000 })- await row.first().getByTestId('project-menu-trigger').click()-}+import {+ setupAndLogin,+ addProject,+ openProjectMenu,+ cleanupProjects,+} from './test-helpers'test.describe('Projects', () => {- test.setTimeout(15_000)+ test.setTimeout(30_000)test.beforeEach(async ({ page }) => {- await page.goto('/')- await login(page)+ await setupAndLogin(page)+ })++ test.afterAll(async ({ browser }) => {+ const page = await browser.newPage()+ await cleanupProjects(page)+ await page.close()})test('user can add project', async ({ page }) => {@@ -36,16 +32,17 @@ test.describe('Projects', () => {await page.getByTestId('context-menu-edit').click()await page.getByTestId('project-edit-name').fill(newName)await page.getByTestId('project-edit-save').click()-+await expect(page.getByText(newName).first()).toBeVisible({ timeout: 5000 })})test('user can delete project', async ({ page }) => {const projectName = `Delete Me ${Date.now()}`await addProject(page, projectName)+ await page.waitForTimeout(1000)await openProjectMenu(page, projectName)- await page.getByTestId('context-menu-delete').click()- await page.getByRole('button', { name: /^yes|^да$/i }).click()+ await page.getByTestId('context-menu-delete').click({ force: true })+ await page.getByTestId('confirm-delete-button').click()await expect(page.getByText(projectName)).toHaveCount(0)})@@ -63,7 +60,9 @@ test.describe('Projects', () => {await addProject(page, projectName)await openProjectMenu(page, projectName)await page.getByTestId('context-menu-move-to-archive').click()+ await page.waitForTimeout(1000)await page.getByTestId('archive-list-collapsible').click()+ await page.getByTestId(`project-row-${projectName}`).first().waitFor({ state: 'visible', timeout: 5000 })await openProjectMenu(page, projectName)await page.getByTestId('context-menu-restore-from-archive').click({ force: true })await expect(page.getByText(projectName).first()).toBeVisible({ timeout: 5000 })diff --git a/web/e2e/subtasks-duplication.spec.ts b/web/e2e/subtasks-duplication.spec.tsnew file mode 100644index 0000000..f448ce0--- /dev/null+++ b/web/e2e/subtasks-duplication.spec.ts@@ -0,0 +1,88 @@+import { test, expect } from '@playwright/test'+import {+ setupAndLogin,+ createProjectAndNavigate,+ cleanupProjects,+ addTaskFromList,+ openTaskDetail,+ addSubtask,+ getSubtaskCount,+ navigateToKanban,+ navigateToGraph,+} from './test-helpers'++test.describe('Subtask duplication', () => {+ test.setTimeout(60_000)++ let projectName: string++ test.beforeEach(async ({ page }) => {+ await setupAndLogin(page)+ })++ test.afterAll(async ({ browser }) => {+ const page = await browser.newPage()+ await cleanupProjects(page)+ await page.close()+ })++ test('adding subtask from task list does not duplicate', async ({ page }) => {+ const project = await createProjectAndNavigate(page)+ projectName = project.name++ const taskName = `List Task ${Date.now()}`+ await addTaskFromList(page, taskName)+ await openTaskDetail(page, taskName)++ const count = await addSubtask(page)+ expect(count).toBe(1)+ })++ test('adding subtask from kanban does not duplicate', async ({ page }) => {+ const project = await createProjectAndNavigate(page)+ projectName = project.name++ const taskName = `Kanban Task ${Date.now()}`+ await addTaskFromList(page, taskName)++ await navigateToKanban(page, projectName)++ await expect(page.getByText(taskName).first()).toBeVisible({ timeout: 10000 })+ await openTaskDetail(page, taskName)++ const count = await addSubtask(page)+ expect(count).toBe(1)+ })++ test('adding subtask from graph does not duplicate', async ({ page }) => {+ const project = await createProjectAndNavigate(page)+ projectName = project.name++ const taskName = `Graph Task ${Date.now()}`+ await addTaskFromList(page, taskName)++ await navigateToGraph(page, projectName)++ await expect(page.getByText(taskName).first()).toBeVisible({ timeout: 10000 })+ await openTaskDetail(page, taskName)++ const count = await addSubtask(page)+ expect(count).toBe(1)+ })++ test('adding multiple subtasks does not duplicate any of them', async ({ page }) => {+ const project = await createProjectAndNavigate(page)+ projectName = project.name++ const taskName = `Multi Subtask ${Date.now()}`+ await addTaskFromList(page, taskName)+ await openTaskDetail(page, taskName)++ for (let i = 0; i < 3; i++) {+ await addSubtask(page)+ }++ const count = await getSubtaskCount(page)+ expect(count).toBe(3)+ })+})diff --git a/web/e2e/test-helpers.ts b/web/e2e/test-helpers.tsindex 5899f29..65533e3 100644--- a/web/e2e/test-helpers.ts+++ b/web/e2e/test-helpers.ts@@ -1,8 +1,160 @@+import { expect, type Page } from '@playwright/test'import { TEST_USER } from './fixtures/auth'+const API_URL = 'http://localhost:1401'++// ── Cleanup ──++const createdProjectIds: number[] = []++export function trackProjectId(id: number | null) {+ if (id) createdProjectIds.push(id)+}++/**+ * Deletes all tracked projects via API. Call in afterAll.+ * Authenticates via API login to get a JWT token (page.request alone has no Bearer header).+ */+export async function cleanupProjects(page: Page) {+ if (createdProjectIds.length === 0) return++ const loginResponse = await page.request.post(`${API_URL}/module/auth/login`, {+ form: { login: TEST_USER.login, password: TEST_USER.password },+ })+ const loginData = await loginResponse.json()+ const token = loginData.access+ if (!token) {+ console.error('Cleanup: failed to get auth token, skipping project deletion')+ return+ }++ for (const id of createdProjectIds) {+ try {+ await page.request.delete(`${API_URL}/module/goals`, {+ data: { goalId: id },+ headers: { Authorization: `Bearer ${token}` },+ timeout: 5000,+ })+ } catch {+ console.error(`Failed to delete project ${id} via API`)+ }+ }+ createdProjectIds.length = 0+}++// ── Locale ──++/**+ * Sets the app locale to English via localStorage before page load.+ * Must be called after page.goto() so localStorage is available for the domain,+ * then reload to apply.+ */+export async function setEnglishLocale(page: Page) {+ await page.evaluate(() => {+ localStorage.setItem('store_task_view.task_view.locale', 'en')+ })+}++// ── Auth ──+export async function login(page: Page) {- await page.getByRole('tab', { name: /password|пароль/i }).click()+ await page.getByRole('tab', { name: /password/i }).click()await page.getByTestId('login-input').fill(TEST_USER.login)await page.getByTestId('password-input').fill(TEST_USER.password)await page.getByTestId('sign-in-button').click()-}\ No newline at end of file+}++/**+ * Navigates to `/`, sets English locale, reloads, and logs in.+ */+export async function setupAndLogin(page: Page) {+ await page.goto('/')+ await setEnglishLocale(page)+ await page.reload()+ await login(page)+}++// ── Projects ──++export async function addProject(page: Page, name: string): Promise<number | null> {+ const urlBefore = page.url()+ const input = page.getByTestId('project-add-input').first()+ await input.waitFor({ state: 'visible', timeout: 15000 })+ await input.fill(name)+ await input.press('Enter')+ await expect(page.getByText(name).first()).toBeVisible({ timeout: 10000 })+ await page.waitForFunction(+ (prev) => location.href !== prev && /\/user\/\d+\//.test(location.href),+ urlBefore,+ { timeout: 10000 },+ )+ const id = extractProjectId(page.url())+ trackProjectId(id)+ return id+}++/**+ * Creates a project, waits for auto-navigation, and tracks the ID for cleanup.+ */+export async function createProjectAndNavigate(page: Page, prefix = 'Test') {+ const projectName = `${prefix} ${Date.now()}`+ const id = await addProject(page, projectName)+ await expect(page.getByTestId('task-search-add-input')).toBeVisible({ timeout: 10000 })+ return { name: projectName, id }+}++export function extractProjectId(url: string): number | null {+ const match = url.match(/\/user\/(\d+)\//)+ return match ? Number(match[1]) : null+}++export async function openProjectMenu(page: Page, projectName: string) {+ const row = page.getByTestId(`project-row-${projectName}`)+ await row.first().waitFor({ state: 'visible', timeout: 10000 })+ await row.first().getByTestId('project-menu-trigger').click({ force: true })+}++// ── Navigation ──++export async function navigateToKanban(page: Page, projectName: string) {+ await openProjectMenu(page, projectName)+ await page.getByRole('link', { name: /kanban/i }).click()+ await page.waitForURL(/\/kanban/, { timeout: 10000 })+}++export async function navigateToGraph(page: Page, projectName: string) {+ await openProjectMenu(page, projectName)+ await page.getByRole('link', { name: /graph/i }).click()+ await page.waitForURL(/\/graph/, { timeout: 10000 })+}++// ── Tasks ──++export async function addTaskFromList(page: Page, taskName: string) {+ const input = page.getByTestId('task-search-add-input')+ await input.waitFor({ state: 'visible', timeout: 10000 })+ await input.fill(taskName)+ await input.press('Enter')+ await expect(page.getByText(taskName).first()).toBeVisible({ timeout: 10000 })+}++export async function openTaskDetail(page: Page, taskName: string) {+ await page.getByText(taskName).first().click()+ await expect(page.getByTestId('add-subtask-button')).toBeVisible({ timeout: 10000 })+}++// ── Subtasks ──++/**+ * Clicks "Add subtask" and returns the total count of subtask items.+ */+export async function addSubtask(page: Page) {+ await page.getByTestId('add-subtask-button').click()+ await expect(page.getByTestId('subtasks-list')).toBeVisible({ timeout: 10000 })+ await page.waitForTimeout(500)+ return page.locator('[data-testid^="subtask-item-"]').count()+}++export function getSubtaskCount(page: Page) {+ return page.locator('[data-testid^="subtask-item-"]').count()+}diff --git a/web/src/components/features/kanban/parts/KanbanAddTask.vue b/web/src/components/features/kanban/parts/KanbanAddTask.vueindex 99df78e..35dfc84 100644--- a/web/src/components/features/kanban/parts/KanbanAddTask.vue+++ b/web/src/components/features/kanban/parts/KanbanAddTask.vue@@ -3,6 +3,7 @@v-model="taskName":loading="loading":placeholder="t('kanban.addTask')"+ data-testid="kanban-add-task-input":trailing-icon="inputIcon"icon="i-lucide-plus"size="xl"diff --git a/web/src/components/features/projects/parts/ProjectDeleteDialog.vue b/web/src/components/features/projects/parts/ProjectDeleteDialog.vueindex 788ed89..1a7610f 100644--- a/web/src/components/features/projects/parts/ProjectDeleteDialog.vue+++ b/web/src/components/features/projects/parts/ProjectDeleteDialog.vue@@ -25,6 +25,7 @@color="error"class="min-w-12":ui="{base: 'justify-center'}"+ data-testid="confirm-delete-button"@click="confirm"/></div>diff --git a/web/src/components/features/tasks/parts/TaskItem.vue b/web/src/components/features/tasks/parts/TaskItem.vueindex 456ca69..065c1d5 100644--- a/web/src/components/features/tasks/parts/TaskItem.vue+++ b/web/src/components/features/tasks/parts/TaskItem.vue@@ -1,6 +1,7 @@<template><divclass="flex flex-col gap-3 p-3 rounded-lg border border-default hover:bg-elevated transition-colors cursor-pointer"+ :data-testid="`task-item-${task.id}`"@click="handleOpenTask"><div class="flex items-center gap-3">diff --git a/web/src/components/features/tasks/parts/TaskSearchAdd.vue b/web/src/components/features/tasks/parts/TaskSearchAdd.vueindex caeebd0..548beae 100644--- a/web/src/components/features/tasks/parts/TaskSearchAdd.vue+++ b/web/src/components/features/tasks/parts/TaskSearchAdd.vue@@ -7,6 +7,7 @@:loading="loading"variant="soft"class="w-full"+ data-testid="task-search-add-input":ui="{base: 'bg-tv-ui-bg-elevated',}"diff --git a/web/src/components/features/tasks/parts/TaskSubtaskItem.vue b/web/src/components/features/tasks/parts/TaskSubtaskItem.vueindex 6db9211..44e290d 100644--- a/web/src/components/features/tasks/parts/TaskSubtaskItem.vue+++ b/web/src/components/features/tasks/parts/TaskSubtaskItem.vue@@ -1,5 +1,8 @@<template>- <div class="flex items-center gap-2 group ">+ <div+ class="flex items-center gap-2 group"+ :data-testid="`subtask-item-${subtask.id}`"+ ><UTextarearef="inputRef"v-model="localDescription"diff --git a/web/src/components/features/tasks/parts/TaskSubtasks.vue b/web/src/components/features/tasks/parts/TaskSubtasks.vueindex cf50426..2ca6db2 100644--- a/web/src/components/features/tasks/parts/TaskSubtasks.vue+++ b/web/src/components/features/tasks/parts/TaskSubtasks.vue@@ -6,6 +6,7 @@<divv-if="subtasks.length > 0 && canViewTaskSubtasks"class="space-y-2 mb-2"+ data-testid="subtasks-list"><TaskSubtaskItemv-for="subtask in subtasks"@@ -25,6 +26,7 @@color="neutral"variant="ghost"class="w-full justify-start rounded-lg shadow-sm dark:bg-tv-ui-bg-elevated"+ data-testid="add-subtask-button":loading="isAdding"@click="addSubtask">diff --git a/web/src/composables/useLogout.ts b/web/src/composables/useLogout.tsindex 2ee3cfa..08bee81 100644--- a/web/src/composables/useLogout.ts+++ b/web/src/composables/useLogout.ts@@ -3,7 +3,7 @@ import { $ls } from '@/plugins/axios'export async function useLogout() {const result = await $api.post<{ logout: boolean }>('/module/auth/logout').catch((err) => {- console.log(err, $api)+ console.error(err, $api)})if (result) {diff --git a/web/src/stores/tasks.store.ts b/web/src/stores/tasks.store.tsindex 1d7a585..99d7fb4 100644--- a/web/src/stores/tasks.store.ts+++ b/web/src/stores/tasks.store.ts@@ -113,12 +113,11 @@ export const useTasksStore = defineStore('tasks', {throw new Error('Main task not found for adding subtask')}- if (mainTask) {- mainTask.subtasks.push(task)- }+ mainTask.subtasks.push(task)- if (this.selectedTask?.id === task.parentId) {- this.selectedTask.subtasks.push(task)+ // Sync selectedTask if it's a separate object for the same parent+ if (this.selectedTask && this.selectedTask !== mainTask && this.selectedTask.id === task.parentId) {+ this.selectedTask.subtasks = mainTask.subtasks}} else {this.tasks.unshift(task)