-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: update @playwright/test to 1.49.x and fix e2e case #2792
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
"sortablejs": "1.15.0" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "~1.42.0" | ||
"@playwright/test": "catalog:" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,19 +4,9 @@ test('表格编辑还原更改', async ({ page }) => { | |
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('grid-edit#edit-revert-data') | ||
await page.getByText('GFD 科技 YX 公司').first().click() | ||
await page | ||
.getByRole('row', { | ||
name: '1 华东区 福州 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。 恢复' | ||
}) | ||
.getByRole('textbox') | ||
.fill('sss') | ||
await page.locator('.tiny-grid-default-input').fill('sss') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add wait conditions and distinguish between input fields. The current implementation might be flaky because:
- await page.locator('.tiny-grid-default-input').fill('sss')
+ await page.locator('.tiny-grid-default-input').first().waitFor()
+ await page.locator('.tiny-grid-default-input').first().fill('sss')
await page.getByText('RFV 有限责任公司').first().click()
- await page.locator('.tiny-grid-default-input').fill('eee')
+ await page.locator('.tiny-grid-default-input').nth(1).waitFor()
+ await page.locator('.tiny-grid-default-input').nth(1).fill('eee') Also applies to: 9-9 |
||
await page.getByText('RFV 有限责任公司').first().click() | ||
await page | ||
.getByRole('row', { | ||
name: '3 华南区 中山市 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。 恢复' | ||
}) | ||
.getByRole('textbox') | ||
.fill('eee') | ||
await page.locator('.tiny-grid-default-input').fill('eee') | ||
await page.locator('#edit-revert-data').getByRole('cell', { name: '名称' }).click() | ||
await page.getByRole('button', { name: '恢复全部' }).click() | ||
await expect(page.getByText('GFD 科技 YX 公司').first()).toBeVisible() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,21 +4,9 @@ test('触发编辑方式', async ({ page }) => { | |
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('grid-edit#edit-trigger-mode-for-editing') | ||
await page.getByText('GFD 科技 YX 公司').first().click() | ||
await expect( | ||
page | ||
.getByRole('row', { | ||
name: '1 华东区 福州 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
}) | ||
.getByRole('textbox') | ||
).toBeVisible() | ||
await expect(page.locator('.tiny-grid-default-input')).toBeVisible() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve test reliability with more specific selectors. Using the same generic selector Consider using more specific selectors: - await expect(page.locator('.tiny-grid-default-input')).toBeVisible()
+ await expect(page.locator('[data-testid="grid-input-company1"]')).toBeVisible()
- await expect(page.locator('.tiny-grid-default-input')).toBeVisible()
+ await expect(page.locator('[data-testid="grid-input-company2"]')).toBeVisible() Also applies to: 11-11 |
||
|
||
await page.getByText('WWWW 科技 YX 公司').nth(1).dblclick() | ||
|
||
await expect( | ||
page | ||
.getByRole('row', { | ||
name: '2 华南区 深圳福田区 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
}) | ||
.getByRole('textbox') | ||
).toBeVisible() | ||
await expect(page.locator('.tiny-grid-default-input')).toBeVisible() | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,11 @@ import { test, expect } from '@playwright/test' | |
|
||
test('提交前校验', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
const demo = page.locator('#validation-before-submit-validation') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Maintain consistency in locator usage and add wait conditions. The test mixes const demo = page.locator('#validation-before-submit-validation')
await page.goto('grid-validation#validation-before-submit-validation')
+ await demo.waitFor()
await demo.getByText('GFD 科技 YX 公司').first().click()
+ await demo.locator('.tiny-grid-default-input').waitFor()
await demo.locator('.tiny-grid-default-input').fill('')
- await page.getByRole('button', { name: '提交数据' }).click()
+ await demo.getByRole('button', { name: '提交数据' }).click() Also applies to: 7-9 |
||
await page.goto('grid-validation#validation-before-submit-validation') | ||
await page.getByText('GFD 科技 YX 公司').first().click() | ||
await page | ||
.getByRole('row', { | ||
name: '1 华东区 福州 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
}) | ||
.getByRole('textbox') | ||
.fill('') | ||
await demo.getByText('GFD 科技 YX 公司').first().click() | ||
await demo.locator('.tiny-grid-default-input').fill('') | ||
|
||
await page.getByRole('button', { name: '提交数据' }).click() | ||
await expect(page.getByText('校验不通过', { exact: true })).toBeVisible() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,10 @@ import { test, expect } from '@playwright/test' | |
|
||
test('自定义组件与插槽编辑器校验', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
const demo = page.locator('#validation-custcomp') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Verify correct row selection before input interaction. The current implementation doesn't verify we're interacting with the correct row. Add assertions to ensure test reliability: const demo = page.locator('#validation-custcomp')
await page.goto('grid-validation#validation-custcomp')
await page.getByText('GFD 科技 YX 公司').first().click()
+ // Ensure correct row is selected
+ await expect(page.locator('tr.row-selected'))
+ .toContainText('GFD 科技 YX 公司')
await demo.locator('.tiny-grid-default-input').fill('') Also applies to: 8-8 |
||
await page.goto('grid-validation#validation-custcomp') | ||
await page.getByText('GFD 科技 YX 公司').first().click() | ||
await page | ||
.getByRole('row', { | ||
name: '1 华东区 福州 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。 1234567890' | ||
}) | ||
.getByRole('textbox') | ||
.fill('') | ||
await demo.locator('.tiny-grid-default-input').fill('') | ||
|
||
await expect(page.getByRole('tooltip', { name: '必填' })).toBeVisible() | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,10 @@ import { test, expect } from '@playwright/test' | |
|
||
test('数据关联校验', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
const demo = page.locator('#validation-row-data-valid') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add initial state verification and input value assertion. The test should verify the initial state and confirm the input value was actually set: const demo = page.locator('#validation-row-data-valid')
await page.goto('grid-validation#validation-row-data-valid')
await page.getByText('70').first().click()
+ // Verify initial state
+ await expect(demo.locator('.tiny-grid-default-input'))
+ .toHaveValue('70')
await demo.locator('.tiny-grid-default-input').fill('700')
+ // Verify input value was set
+ await expect(demo.locator('.tiny-grid-default-input'))
+ .toHaveValue('700') Also applies to: 8-8 |
||
await page.goto('grid-validation#validation-row-data-valid') | ||
await page.getByText('70').first().click() | ||
await page.getByRole('row', { name: '1 100 0' }).getByRole('textbox').fill('700') | ||
await demo.locator('.tiny-grid-default-input').fill('700') | ||
|
||
await expect(page.getByRole('tooltip', { name: '数值不能大于 100' })).toBeVisible() | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,13 @@ import { test, expect } from '@playwright/test' | |
|
||
test('选中时校验', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
|
||
const demo = page.locator('#validation-select-validation') | ||
await page.goto('grid-validation#validation-select-validation') | ||
await page.getByText('GFD 科技 YX 公司').first().click() | ||
await page | ||
.getByRole('row', { | ||
name: '1 华东区 福州 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
}) | ||
.getByRole('textbox') | ||
.clear() | ||
await demo.locator('.tiny-grid-default-input').fill('') | ||
await page.waitForTimeout(200) | ||
await page | ||
.getByRole('row', { | ||
name: '1 华东区 福州 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
}) | ||
.locator('span') | ||
.click() | ||
await demo.locator('.tiny-grid-body__row .tiny-grid-checkbox__icon').first().click() | ||
Comment on lines
10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace hardcoded timeout with proper wait conditions. Using Example: await demo.locator('.tiny-grid-default-input').fill('')
- await page.waitForTimeout(200)
+ await expect(demo.locator('.tiny-grid-default-input')).toHaveValue('')
|
||
await page.getByRole('button', { name: '校验选中数据' }).click() | ||
|
||
await expect(page.getByText('校验不通过', { exact: true })).toBeVisible() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,7 @@ test('触发校验时自动定位到当前校验的单元格', async ({ page }) | |
|
||
const demo = page.locator('#validation-validation-scroll-to-col') | ||
await page.getByText('GFD 科技 YX 公司').first().click() | ||
await page | ||
.getByRole('row', { | ||
name: '1 华东区 福州 公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
}) | ||
.getByRole('textbox') | ||
.fill('') | ||
await demo.locator('.tiny-input__inner').fill('') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace hardcoded timeout with proper wait conditions. Using await page.getByRole('button', { name: '保存' }).click()
- await page.waitForTimeout(200)
+ await expect(page.getByRole('cell', { name: 'WWW 科技 YX 公司' })).toBeVisible() Also applies to: 15-15 |
||
await demo.getByText('名称').click() | ||
const lastColumn = demo.getByText('公司简介') | ||
await lastColumn.scrollIntoViewIfNeeded() | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,6 +22,9 @@ | |||||||||||||
"pub": "pnpm publish --no-git-checks --access=public" | ||||||||||||||
}, | ||||||||||||||
"dependencies": { | ||||||||||||||
"@docsearch/css": "^3.8.0", | ||||||||||||||
"@docsearch/js": "^3.8.0", | ||||||||||||||
"@docsearch/react": "npm:@docsearch/css", | ||||||||||||||
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review @docsearch dependencies configuration The dependency configuration for Consider updating to: "@docsearch/css": "^3.8.0",
"@docsearch/js": "^3.8.0",
- "@docsearch/react": "npm:@docsearch/css",
+ "@docsearch/react": "^3.8.0", 📝 Committable suggestion
Suggested change
|
||||||||||||||
"@opentiny/vue": "workspace:~", | ||||||||||||||
"@opentiny/vue-common": "workspace:~", | ||||||||||||||
"@opentiny/vue-design-aurora": "workspace:~", | ||||||||||||||
|
@@ -48,16 +51,12 @@ | |||||||||||||
"tailwindcss": "^3.2.4", | ||||||||||||||
"vue": "^3.4.31", | ||||||||||||||
"vue-i18n": "^9.1.10", | ||||||||||||||
"vue-router": "4.1.5", | ||||||||||||||
"@docsearch/js": "^3.8.0", | ||||||||||||||
"@docsearch/css": "^3.8.0", | ||||||||||||||
"@docsearch/react": "npm:@docsearch/css" | ||||||||||||||
"vue-router": "4.1.5" | ||||||||||||||
}, | ||||||||||||||
"devDependencies": { | ||||||||||||||
"@opentiny-internal/unplugin-virtual-template": "workspace:~", | ||||||||||||||
"@opentiny/vue-mobile": "workspace:~", | ||||||||||||||
"@playwright/test": "~1.42.0", | ||||||||||||||
"rollup-plugin-visualizer": "^5.12.0", | ||||||||||||||
"@playwright/test": "catalog:", | ||||||||||||||
"@types/markdown-it": "^12.2.3", | ||||||||||||||
"@types/node": "^17.0.45", | ||||||||||||||
"@unocss/preset-icons": "^0.38.2", | ||||||||||||||
|
@@ -78,6 +77,7 @@ | |||||||||||||
"markdown-it-table-of-contents": "^0.6.0", | ||||||||||||||
"markdown-it-toc-done-right": "^4.2.0", | ||||||||||||||
"prettier": "^2.7.1", | ||||||||||||||
"rollup-plugin-visualizer": "^5.12.0", | ||||||||||||||
"stylelint": "^14.9.1", | ||||||||||||||
"stylelint-config-standard": "^26.0.0", | ||||||||||||||
"typescript": "catalog:", | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add timeout and state assertions for better test stability.
The current visibility check might be flaky if multiple inputs exist or if the input's visibility is delayed. Consider:
📝 Committable suggestion