From 4fcec640a4a4f7e308f77cd5e6cadb0a6f9cb03f Mon Sep 17 00:00:00 2001 From: Ruslan Bayandinov <45530296+wazsone@users.noreply.github.com> Date: Thu, 10 Nov 2022 15:14:21 +0700 Subject: [PATCH] Add verifications for some test steps (#2371) * Add verifications for some test steps Signed-off-by: Ruslan Bayandinov * Add verifications for some test steps Signed-off-by: Ruslan Bayandinov * remove random from tests Signed-off-by: Ruslan Bayandinov * return random and fix internal loop index Signed-off-by: Ruslan Bayandinov * remove outer loop Signed-off-by: Ruslan Bayandinov Signed-off-by: Ruslan Bayandinov --- tests/sanity/tests/tracker.spec.ts | 51 ++++++++++++++++-------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/tests/sanity/tests/tracker.spec.ts b/tests/sanity/tests/tracker.spec.ts index 10a0e75f4a..a87da6fed6 100644 --- a/tests/sanity/tests/tracker.spec.ts +++ b/tests/sanity/tests/tracker.spec.ts @@ -208,22 +208,25 @@ test('report-time-from-issue-card', async ({ page }) => { await navigate(page) const assignee = 'Rosamund Chen' const status = 'In Progress' - const values = ['0.25', '0.5', '0.75', '1'] + const values = [0.25, 0.5, 0.75, 1] for (let i = 0; i < 10; i++) { const random = Math.floor(Math.random() * values.length) const time = values[random] const name = getIssueName() await createIssue(page, { name, assignee, status }) - + await page.waitForSelector(`text="${name}"`) + await page.waitForSelector('text="View issue"') await page.click('text="View issue"') await page.click('#ReportedTimeEditor') + 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\\ time"]', time) + await page.fill('[placeholder="Reported\\ time"]', `${time}`) await expect(page.locator('button:has-text("Create")')).toBeEnabled() await page.click('button:has-text("Create")') - await page.keyboard.press('Escape') + await page.click('#card-close') await expect(page.locator('#TimeSpendReportValue')).toContainText(`${time}d`) } @@ -241,28 +244,28 @@ test('report-time-from-main-view', async ({ page }) => { const values = [0.25, 0.5, 0.75, 1] const assignee = 'Rosamund Chen' const status = 'In Progress' - for (let i = 0; i < 5; i++) { - const name = getIssueName() - await createIssue(page, { name, assignee, status }) - await page.waitForSelector(`text="${name}"`) - await page.click('.close-button >> button') + const name = getIssueName() - let count = 0 - for (let i = 0; i < 5; i++) { - const random = Math.floor(Math.random() * values.length) - const time = values[random] - count += time - await page.click('.estimation-container') - await page.waitForSelector('text="Estimation"') + await createIssue(page, { name, assignee, status }) + await page.waitForSelector(`text="${name}"`) + await page.click('.close-button > .button') - await page.click('text="Add time report"') - await expect(page.locator('button:has-text("Create")')).toBeDisabled() - await page.fill('[placeholder="Reported\\ time"]', `${time}`) - await expect(page.locator('button:has-text("Create")')).toBeEnabled() - await page.click('button:has-text("Create")') - await page.keyboard.press('Escape') + let count = 0 + for (let j = 0; j < 5; j++) { + const random = Math.floor(Math.random() * values.length) + const time = values[random] + count += time + await page.locator('.estimation-container').first().click() + await page.waitForSelector('text="Estimation"') - await expect(page.locator('.estimation-container >> span').nth(0)).toContainText(`${Number(count.toFixed(2))}d`) - } + await page.click('button:has-text("Add time report")') + await page.waitForSelector('.antiCard-header >> .antiCard-header__title-wrap >> span:has-text("Add time report")') + await expect(page.locator('button:has-text("Create")')).toBeDisabled() + await page.fill('[placeholder="Reported\\ time"]', `${time}`) + await expect(page.locator('button:has-text("Create")')).toBeEnabled() + await page.click('button:has-text("Create")') + await page.click('#card-close') + + await expect(page.locator('.estimation-container >> span').first()).toContainText(`${Number(count.toFixed(2))}d`) } })