Fix components UI tests (#3157)

Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@icloud.com>
This commit is contained in:
Sergei Ogorelkov 2023-05-10 17:00:16 +04:00 committed by GitHub
parent 238f2da750
commit 9a36559fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 21 deletions

View File

@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test'
import { generateId, PlatformSetting, PlatformURI } from './utils'
import { fillSearch, generateId, PlatformSetting, PlatformURI } from './utils'
test.use({
storageState: PlatformSetting
@ -55,16 +55,13 @@ test.describe('contact tests', () => {
await expect(page.locator('text=M. Marina')).toBeVisible()
expect(await page.locator('.antiTable-body__row').count()).toBeGreaterThan(5)
const searchBox = page.locator('[placeholder="Search"]')
await searchBox.fill('Marina')
await searchBox.press('Enter')
await fillSearch(page, 'Marina')
await expect(page.locator('.antiTable-body__row')).toHaveCount(1, {
timeout: 15000
})
await searchBox.fill('')
await searchBox.press('Enter')
await fillSearch(page, '')
await expect(page.locator('text=Chen Rosamund')).toBeVisible()
expect(await page.locator('.antiTable-body__row').count()).toBeGreaterThan(5)

View File

@ -13,7 +13,7 @@ import {
setViewOrder,
ViewletSelectors
} from './tracker.utils'
import { generateId, PlatformSetting } from './utils'
import { fillSearch, generateId, PlatformSetting } from './utils'
test.use({
storageState: PlatformSetting
})
@ -173,9 +173,7 @@ test.describe('tracker layout tests', () => {
await setViewGroup(page, 'No grouping')
await setViewOrder(page, order)
const searchBox = page.locator('[placeholder="Search"]')
await searchBox.fill(id)
await searchBox.press('Enter')
await fillSearch(page, id)
await expect(locator).toContainText(orderedIssueNames, {
timeout: 15000

View File

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test'
import { navigate } from './tracker.utils'
import { generateId, PlatformSetting, PlatformURI } from './utils'
import { generateId, PlatformSetting, PlatformURI, fillSearch } from './utils'
test.use({
storageState: PlatformSetting
@ -26,6 +26,8 @@ test.describe('component tests', () => {
await page.click('button:has-text("Create component")')
await fillSearch(page, prjId)
await page.click(`text=${prjId}`)
await page.click('button:has-text("New issue")')
await page.fill('[placeholder="Issue\\ title"]', 'issue')
@ -50,6 +52,9 @@ test.describe('component tests', () => {
await page.click('button:has-text("In progress")')
await page.click('button:has-text("Create component")')
await page.waitForSelector('form.antiCard', { state: 'detached' })
await fillSearch(page, prjId)
await page.click(`text=${prjId}`)
await page.click('button:has-text("In progress")')
await page.click('button:has-text("Completed")')

View File

@ -11,7 +11,7 @@ import {
navigate,
openIssue
} from './tracker.utils'
import { PlatformSetting, generateId } from './utils'
import { PlatformSetting, fillSearch, generateId } from './utils'
test.use({
storageState: PlatformSetting
})
@ -32,9 +32,7 @@ test('create-issue-and-sub-issue', async ({ page }) => {
await createIssue(page, props)
await page.click('text="Issues"')
await page.locator('[placeholder="Search"]').click()
await page.locator('[placeholder="Search"]').fill(props.name)
await page.locator('[placeholder="Search"]').press('Enter')
await fillSearch(page, props.name)
await openIssue(page, props.name)
await checkIssue(page, props)
@ -167,9 +165,7 @@ test('report-time-from-main-view', async ({ page }) => {
// await page.click('.close-button > .button')
// We need to fait for indexer to complete indexing.
await page.locator('[placeholder="Search"]').click()
await page.locator('[placeholder="Search"]').fill(name)
await page.locator('[placeholder="Search"]').press('Enter')
await fillSearch(page, name)
await page.waitForSelector(`text="${name}"`, { timeout: 15000 })
@ -307,9 +303,7 @@ test('sub-issue-draft', async ({ page }) => {
await createIssue(page, props)
await page.click('text="Issues"')
await page.locator('[placeholder="Search"]').click()
await page.locator('[placeholder="Search"]').fill(props.name)
await page.locator('[placeholder="Search"]').press('Enter')
await fillSearch(page, props.name)
await openIssue(page, props.name)
await checkIssue(page, props)

View File

@ -1,3 +1,5 @@
import { Locator, Page } from '@playwright/test'
export const PlatformURI = process.env.PLATFORM_URI as string
export const PlatformTransactor = process.env.PLATFORM_TRANSACTOR as string
export const PlatformUser = process.env.PLATFORM_USER as string
@ -38,3 +40,21 @@ export function generateId (len = 100): string {
const r = v.slice(s, v.length) + count()
return r
}
/**
* Finds a search field on the page, fills it with
* the provided string, and returns a locator
*
* @export
* @param {Page} page
* @param {string} search
* @returns {Promise<Locator>}
*/
export async function fillSearch (page: Page, search: string): Promise<Locator> {
const searchBox = page.locator('input[placeholder="Search"]')
await searchBox.fill(search)
await searchBox.press('Enter')
return searchBox
}