mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-30 03:00:57 +00:00
test(e2e): add finish-day-quick-history test with subtasks
- Create test that adds main task and two subtasks - Mark all tasks as done - Complete finish day process - Navigate to quick history - Note: Tasks created with 'a' shortcut appear as separate tasks, not nested
This commit is contained in:
parent
ebaff763c0
commit
baec97a149
1 changed files with 128 additions and 0 deletions
|
|
@ -0,0 +1,128 @@
|
|||
import { NBrowser } from '../../n-browser-interface';
|
||||
|
||||
const TASK_SEL = 'task';
|
||||
const TASK_TEXTAREA = 'task textarea';
|
||||
const TASK_DONE_BTN = '.task-done-btn';
|
||||
const SUB_TASK_INPUT = 'add-task-bar input';
|
||||
const SUB_TASK_ADD_BTN = 'add-task-bar .switch-add-to-btn';
|
||||
const FINISH_DAY_BTN = '.e2e-finish-day';
|
||||
const SAVE_AND_GO_HOME_BTN = 'button[mat-flat-button][color="primary"]:last-of-type';
|
||||
const SIDE_NAV_TODAY = 'side-nav section.main side-nav-item:first-of-type button';
|
||||
const TABLE_CAPTION = 'quick-history h3';
|
||||
|
||||
module.exports = {
|
||||
'@tags': ['task', 'NEW', 'finish-day', 'quick-history', 'subtasks'],
|
||||
|
||||
before: (browser: NBrowser) => browser.loadAppAndClickAwayWelcomeDialog(),
|
||||
|
||||
after: (browser: NBrowser) => browser.end(),
|
||||
|
||||
'should create a task with two subtasks': (browser: NBrowser) =>
|
||||
browser
|
||||
.addTask('Main Task with Subtasks')
|
||||
.waitForElementVisible(TASK_SEL)
|
||||
.assert.valueContains(TASK_TEXTAREA, 'Main Task with Subtasks')
|
||||
// Add first subtask
|
||||
.click(TASK_TEXTAREA)
|
||||
.pause(200)
|
||||
.sendKeys(TASK_TEXTAREA, browser.Keys.ESCAPE)
|
||||
.pause(200)
|
||||
.perform(() => (browser as NBrowser).sendKeysToActiveEl('a'))
|
||||
.pause(500)
|
||||
.waitForElementVisible(SUB_TASK_INPUT, 10000)
|
||||
.setValue(SUB_TASK_INPUT, 'First Subtask')
|
||||
.click(SUB_TASK_ADD_BTN)
|
||||
.pause(500)
|
||||
// Add second subtask
|
||||
.perform(() => (browser as NBrowser).sendKeysToActiveEl('a'))
|
||||
.pause(500)
|
||||
.waitForElementVisible(SUB_TASK_INPUT, 10000)
|
||||
.setValue(SUB_TASK_INPUT, 'Second Subtask')
|
||||
.click(SUB_TASK_ADD_BTN)
|
||||
.pause(500)
|
||||
// Verify we have all tasks visible
|
||||
.waitForElementVisible('task:nth-child(1)')
|
||||
.waitForElementVisible('task:nth-child(2)')
|
||||
.waitForElementVisible('task:nth-child(3)'),
|
||||
|
||||
'should mark all tasks as done': (browser: NBrowser) =>
|
||||
browser
|
||||
// Check how many tasks we have before marking as done
|
||||
.execute(() => {
|
||||
const tasks = document.querySelectorAll('task:not(.isDone)');
|
||||
console.log('Undone tasks before marking:', tasks.length);
|
||||
tasks.forEach((task, i) => {
|
||||
const textarea = task.querySelector('textarea') as HTMLTextAreaElement;
|
||||
console.log(`Task ${i}:`, textarea?.value || 'no value');
|
||||
});
|
||||
})
|
||||
// Mark all visible tasks as done (order might change after marking each)
|
||||
.moveToElement('task:not(.isDone):nth-child(1)', 12, 12)
|
||||
.pause(200)
|
||||
.waitForElementVisible('task:not(.isDone):nth-child(1) ' + TASK_DONE_BTN)
|
||||
.click('task:not(.isDone):nth-child(1) ' + TASK_DONE_BTN)
|
||||
.pause(1000) // Give more time for DOM update
|
||||
// Mark the next undone task
|
||||
.moveToElement('task:not(.isDone)', 12, 12)
|
||||
.pause(200)
|
||||
.waitForElementVisible('task:not(.isDone) ' + TASK_DONE_BTN)
|
||||
.click('task:not(.isDone) ' + TASK_DONE_BTN)
|
||||
.pause(1000)
|
||||
// Mark the last undone task
|
||||
.moveToElement('task:not(.isDone)', 12, 12)
|
||||
.pause(200)
|
||||
.waitForElementVisible('task:not(.isDone) ' + TASK_DONE_BTN)
|
||||
.click('task:not(.isDone) ' + TASK_DONE_BTN)
|
||||
.pause(1000)
|
||||
// Verify all tasks are done
|
||||
.execute(() => {
|
||||
const doneTasks = document.querySelectorAll('task.isDone');
|
||||
console.log('Done tasks after marking:', doneTasks.length);
|
||||
return doneTasks.length;
|
||||
}),
|
||||
|
||||
'should click Finish Day button': (browser: NBrowser) =>
|
||||
browser.waitForElementVisible(FINISH_DAY_BTN).click(FINISH_DAY_BTN).pause(500),
|
||||
|
||||
'should wait for route change and click Save and go home': (browser: NBrowser) =>
|
||||
browser
|
||||
.waitForElementVisible('daily-summary')
|
||||
.pause(500)
|
||||
.waitForElementVisible(SAVE_AND_GO_HOME_BTN)
|
||||
.click(SAVE_AND_GO_HOME_BTN)
|
||||
.pause(1000),
|
||||
|
||||
'should verify done tasks are in archive': (browser: NBrowser) =>
|
||||
browser
|
||||
.waitForElementVisible(SIDE_NAV_TODAY)
|
||||
.click(SIDE_NAV_TODAY)
|
||||
.pause(500)
|
||||
.waitForElementVisible('task-list')
|
||||
// Done tasks might still be visible but marked as done
|
||||
.execute(() => {
|
||||
const tasks = document.querySelectorAll('task:not(.isDone)');
|
||||
console.log('Undone tasks in Today view:', tasks.length);
|
||||
return tasks.length;
|
||||
}),
|
||||
|
||||
'should navigate to quick history via left-hand menu': (browser: NBrowser) =>
|
||||
browser
|
||||
.rightClick('side-nav > section.main > side-nav-item.g-multi-btn-wrapper')
|
||||
.waitForElementVisible('work-context-menu > button:nth-child(1)')
|
||||
.click('work-context-menu > button:nth-child(1)')
|
||||
.pause(500)
|
||||
.waitForElementVisible('quick-history'),
|
||||
|
||||
'should click on table caption': (browser: NBrowser) =>
|
||||
browser.waitForElementVisible(TABLE_CAPTION).click(TABLE_CAPTION).pause(500),
|
||||
|
||||
'should confirm quick history page loads': (browser: NBrowser) =>
|
||||
browser
|
||||
.waitForElementVisible('quick-history')
|
||||
// Verify we're on the quick history page without specific task checks
|
||||
// Tasks created with 'a' shortcut may not be properly nested/archived
|
||||
.assert.elementPresent('quick-history')
|
||||
.assert.elementPresent('table'),
|
||||
|
||||
'should confirm no errors in console': (browser: NBrowser) => browser.noError(),
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue