TSK-1574: Accurate time reports count (#3509)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2023-07-19 19:46:25 +07:00 committed by GitHub
parent 3fcd9081be
commit 046de0d986
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 3 deletions

View File

@ -799,7 +799,7 @@ export class LiveQuery extends TxProcessor implements Client {
}
if (q.options?.limit !== undefined && q.result.length > q.options.limit) {
if (q.result.pop()?._id !== doc._id) {
if (q.result.pop()?._id !== doc._id || q.options?.total === true) {
await this.callback(q)
}
} else {

View File

@ -226,7 +226,7 @@
_class,
totalQuery ?? query ?? {},
(result) => {
gtotal = result.total
gtotal = result.total === -1 ? 0 : result.total
},
{
lookup,

View File

@ -424,7 +424,7 @@ abstract class MongoAdapterBase implements DbAdapter {
cursor.maxTimeMS(30000)
const res = (await cursor.toArray())[0]
const result = res.results as WithLookup<T>[]
const total = res.totalCount?.shift()?.count ?? -1
const total = options?.total === true ? res.totalCount?.shift()?.count ?? 0 : -1
for (const row of result) {
await this.fillLookupValue(clazz, options?.lookup, row)
this.clearExtraLookups(row)

View File

@ -172,6 +172,39 @@ test('report-time-from-issue-card', async ({ page }) => {
}
})
test('report-multiple-time-from-issue-card', async ({ page }) => {
await navigate(page)
const assignee = 'Chen Rosamund'
const status = 'In Progress'
const time = 0.25
const name = getIssueName()
try {
await page.evaluate(() => localStorage.setItem('#platform.notification.timeout', '5000'))
await createIssue(page, { name, assignee, status })
await page.waitForSelector(`text="${name}"`)
await page.waitForSelector('text="View issue"')
await page.click('text="View issue"')
} finally {
await page.evaluate(() => localStorage.setItem('#platform.notification.timeout', '0'))
}
await page.click('#ReportedTimeEditor')
for (let i = 0; i < 5; i++) {
await expect(page.locator('.antiCard-content >> .footer')).toContainText(`Total: ${i}`)
await page.waitForSelector('text="Time spend reports"')
await page.click('#ReportsPopupAddButton')
await page.waitForSelector('text="Add time report"')
await expect(page.locator('button:has-text("Create")')).toBeDisabled()
await page.fill('[placeholder="Reported\\ days"]', `${time}`)
await expect(page.locator('button:has-text("Create")')).toBeEnabled()
await page.click('button:has-text("Create")')
await expect(page.locator('.antiCard-content >> .footer')).toContainText(`Total: ${i + 1}`)
}
})
test('report-time-from-main-view', async ({ page }) => {
await navigate(page)