-
Notifications
You must be signed in to change notification settings - Fork 300
test(e2e): [input,link,popeditor] fix input、link、popeditor error e2e test #2586
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
Changes from all 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 |
---|---|---|
|
@@ -5,27 +5,18 @@ test('PopEditor 表单中使用并开启表单校验', async ({ page }) => { | |
await page.goto('popeditor#condition-form') | ||
|
||
const preview = page.locator('#condition-form') | ||
const textBox = preview.getByRole('textbox').nth(2) | ||
const textBoxInput1 = page.getByText('15').nth(1) | ||
const textBoxInput2 = page.getByText('18').nth(1) | ||
const dialogBox = page.locator('div').getByRole('textbox').nth(5) | ||
const del = page | ||
await preview | ||
.locator('div') | ||
.filter({ hasText: /^文本选择确 认取 消$/ }) | ||
.getByRole('textbox') | ||
.click() | ||
Comment on lines
+8
to
+12
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 Simplify and make the locator more maintainable. The current locator chain with text filter is fragile and hard to maintain. Consider using data-testid attributes for more reliable element selection. Example implementation: - await preview
- .locator('div')
- .filter({ hasText: /^文本选择确 认取 消$/ })
- .getByRole('textbox')
- .click()
+ // Add data-testid to the component
+ await preview.getByTestId('text-selector-input').click()
|
||
await page.getByRole('row', { name: 'GFD科技YX公司 福建 福州' }).locator('path').nth(1).click() | ||
await page.getByRole('button', { name: '确 认' }).click() | ||
await preview | ||
.locator('div') | ||
.filter({ hasText: /^文本$/ }) | ||
.getByRole('img') | ||
const confirmBtn = page.getByRole('button', { name: '确 认' }) | ||
const dataItem = page.getByRole('row', { name: 'GFD科技YX公司 福建 福州' }).locator('.tiny-grid-radio.size__mini') | ||
.click() | ||
const tooltip = page.getByRole('tooltip', { name: '必填' }) | ||
|
||
await textBox.click() | ||
await textBoxInput1.click() | ||
await textBoxInput2.click() | ||
await dialogBox.click() | ||
await dataItem.click() | ||
await confirmBtn.click() | ||
await expect(dialogBox).toHaveValue('GFD科技YX公司') | ||
|
||
await del.click() | ||
await expect(dialogBox).toHaveValue('') | ||
await expect(tooltip).toBeVisible() | ||
}) |
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
Consider using a more robust wait strategy.
Instead of using a fixed timeout, consider waiting for the console event directly. This would make the test more reliable and faster in most cases.
Here's a suggested implementation:
📝 Committable suggestion