-
Notifications
You must be signed in to change notification settings - Fork 285
chore: Auto UI test based on cypress #2668
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: 'http://localhost:10086/#/', | ||
specPattern: 'cypress/e2e/**/*.js', | ||
}, | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
viewportWidth: 414, | ||
viewportHeight: 896, | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from 'react' | ||
import { mount } from 'cypress/react18' | ||
import { ActionSheet } from '../../src/packages/actionsheet/actionsheet' | ||
|
||
const menulist = [ | ||
{ | ||
name: '选项一', | ||
description: '选项一的描述信息', | ||
danger: true, | ||
}, | ||
{ | ||
name: '选项二', | ||
disabled: true, | ||
}, | ||
{ | ||
name: '必填', | ||
name1: '选项三', | ||
}, | ||
] | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('props test options ', () => { | ||
mount( | ||
<ActionSheet | ||
visible | ||
title="弹层标题" | ||
description="弹层描述信息" | ||
cancelText="关闭弹层" | ||
options={menulist} | ||
/> | ||
) | ||
cy.get('.nut-actionsheet-list .nut-actionsheet-item').should('have.length', 3) | ||
}) | ||
|
||
it('props test cancelText ', async () => { | ||
mount( | ||
<ActionSheet | ||
visible | ||
title="弹层标题" | ||
description="弹层描述信息" | ||
cancelText="关闭弹层" | ||
options={menulist} | ||
/> | ||
) | ||
cy.get('.nut-actionsheet-cancel').then(($el) => { | ||
const el = cy.wrap($el) | ||
el.should('have.text', '关闭弹层') | ||
}) | ||
}) | ||
|
||
it('props test has value ', async () => { | ||
mount( | ||
<ActionSheet | ||
visible | ||
title="弹层标题" | ||
description="弹层描述信息" | ||
cancelText="关闭弹层" | ||
options={menulist} | ||
/> | ||
) | ||
cy.get('.nut-actionsheet-list .nut-actionsheet-item') | ||
.eq(0) | ||
.then(($el) => { | ||
const el = cy.wrap($el) | ||
el.should('have.text', '选项一选项一的描述信息') | ||
el.should('have.class', 'danger') | ||
}) | ||
}) | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react' | ||
import { Button } from '../../src/packages/button/button' | ||
|
||
it('playground', () => { | ||
cy.mount(<Button type="primary">123</Button>) | ||
}) | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react' | ||
import { Cell } from '../../src/packages/cell/cell.taro' | ||
import { Switch } from '../../src/packages/switch/switch.taro' | ||
|
||
it('prop title extra description test', () => { | ||
cy.mount( | ||
<Cell | ||
data-testid="prop" | ||
title="我是标题" | ||
description="我是描述" | ||
extra="描述文字" | ||
/> | ||
) | ||
cy.get('.nut-cell-title').should('contain.text', '我是标题') | ||
cy.get('.nut-cell-description').should('contain.text', '我是描述') | ||
cy.get('.nut-cell-extra').should('contain.text', '描述文字') | ||
}) | ||
it('prop ', () => { | ||
cy.mount(<Cell title="URL 跳转" extra="https://m.jd.com/" />) | ||
cy.get('.nut-cell-extra').should('be.visible') | ||
}) | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('emit click event', () => { | ||
const testClick = () => {} | ||
cy.mount(<Cell data-testid="emit-click" onClick={() => testClick()} />) | ||
cy.get('[data-testid="emit-click"]').click().trigger('testClick') | ||
}) | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('slot default test', () => { | ||
cy.mount(<Cell title={<div>自定义内容</div>} extra="描述文字" />) | ||
cy.root().should('contain.html', '<div>自定义内容</div>') | ||
}) | ||
|
||
it('slot extra', () => { | ||
cy.mount(<Cell title="Switch" extra={<Switch defaultChecked />} />) | ||
cy.get('.nut-switch').should('be.visible') | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import './taro/base.cy' | ||
import './taro/layout.cy' | ||
import './taro/nav.cy' | ||
import './taro/dentry.cy' | ||
|
||
Cypress.on('uncaught:exception', (err, runnable) => { | ||
return false | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
const getPath = (component) => `base/pages/${component}/index` | ||
|
||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
describe('base components test', () => { | ||
it('button successfully passes', () => { | ||
cy.visit(getPath('button')) | ||
cy.get('.applets-demo-header').contains('Button') | ||
// Click Loading Test and loading icon shows | ||
cy.contains('button', 'Click me').scrollIntoView().click() | ||
cy.contains('button', 'Click me') | ||
.parent() | ||
.find('i.nut-icon-Loading') | ||
.should('exist') | ||
cy.wait(500) | ||
}) | ||
|
||
it('cell successfully passes', () => { | ||
cy.visit(getPath('cell')) | ||
cy.get('.applets-demo-header').contains('Cell') | ||
// Click Switch | ||
cy.contains('自定义右侧区域').scrollIntoView() | ||
cy.get('.nut-switch-button').click() | ||
cy.get('.nut-switch-button') | ||
.parent() | ||
.should('have.class', 'nut-switch-close') | ||
cy.get('.nut-switch-button').click() | ||
cy.get('.nut-switch-button') | ||
.parent() | ||
.should('have.class', 'nut-switch-open') | ||
// Jump URL | ||
cy.contains('链接 | 分组用法').scrollIntoView() | ||
cy.contains('/pages/index/index').click() | ||
cy.wait(500) | ||
cy.window().then((location) => { | ||
expect(location.location.pathname).to.equal('/') | ||
}) | ||
cy.wait(400) | ||
}) | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('ConfigProvider successfully passes', () => { | ||
cy.visit(getPath('configprovider')) | ||
cy.get('.applets-demo-header').contains('ConfigProvider') | ||
// Expected Rate | ||
cy.get('.nut-rate') | ||
.first() | ||
.find('.nut-rate-item') | ||
.eq(-2) | ||
.find('.nut-rate-item-icon') | ||
.click() | ||
cy.get('.nut-rate') | ||
.first() | ||
.find('.nut-rate-item .nut-rate-item-icon') | ||
.filter('.nut-rate-item-icon-disabled') | ||
.should('have.length', 1) | ||
cy.get('.nut-rate') | ||
.first() | ||
.find('.nut-rate-item') | ||
.first() | ||
.find('.nut-rate-item-icon') | ||
.click() | ||
cy.get('.nut-rate') | ||
.first() | ||
.find('.nut-rate-item .nut-rate-item-icon') | ||
.filter('.nut-rate-item-icon-disabled') | ||
.should('have.length', 4) | ||
cy.wait(400) | ||
}) | ||
|
||
it('Icon successfully passes', () => { | ||
cy.visit(getPath('icon')) | ||
cy.get('.applets-demo-header').contains('Icon') | ||
// V12 Icon Click Test | ||
cy.contains('V12 Icon').scrollIntoView() | ||
cy.get('i.nut-icon-thumbs-up').click() | ||
cy.contains('<ThumbsUp />') | ||
cy.get( | ||
'i.nut-icon-heart-fill.nut-icon-am-breathe.nut-icon-am-infinite' | ||
).click() | ||
cy.contains( | ||
`<HeartFill className='nut-icon-am-breathe nut-icon-am-infinite' />` | ||
) | ||
cy.wait(400) | ||
}) | ||
it('Image successfully passes', () => { | ||
cy.visit(getPath('image')) | ||
cy.get('.applets-demo-header').contains('Image') | ||
cy.wait(500) | ||
// Lazy Load Scroll | ||
cy.contains('图片懒加载').scrollIntoView() | ||
cy.get('.taro-scroll-view__scroll-y .taro-img__mode-scaletofill') | ||
.filter('[src]') | ||
.should('have.length', 3) | ||
cy.get('.taro-scroll-view__scroll-y').scrollTo('bottom', { duration: 1000 }) | ||
cy.get('.taro-scroll-view__scroll-y .taro-img__mode-scaletofill') | ||
.filter('[src]') | ||
.should('have.length.greaterThan', 3) | ||
cy.wait(400) | ||
}) | ||
it('Overlay successfully passes', () => { | ||
cy.visit(getPath('overlay')) | ||
cy.get('.applets-demo-header').contains('Overlay') | ||
// Display Overlay | ||
cy.contains('嵌套内容').scrollIntoView() | ||
cy.get('.nut-button-success').click() | ||
cy.contains('这里是正文') | ||
cy.contains('这里是正文') | ||
.parent() | ||
.parent() | ||
.should('have.class', 'nut-overlay') | ||
.click() | ||
cy.contains('这里是正文').should('not.exist') | ||
cy.get('nut-overlay').should('not.exist') | ||
}) | ||
}) | ||
Cypress.on('uncaught:exception', (err, runnable) => { | ||
return false | ||
}) | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,45 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const componentTest = (comName, fn) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const dentryArr = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Calendar', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'CalendarCard', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Cascader', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Checkbox', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'DatePicker', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Form', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Input', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'InputNumber', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const getPath = (component) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
`${dentryArr.includes(component) ? 'dentry' : 'dentry1'}/pages/${component.toLowerCase()}/index` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it(`${comName} successfully passes`, () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.visit(getPath(comName)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.applets-demo-header').contains(comName) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.wait(400) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fn() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+1
to
+22
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. 测试工具函数需要改进 工具函数存在以下问题:
建议进行如下修改: const componentTest = (comName, fn) => {
+ if (typeof comName !== 'string' || typeof fn !== 'function') {
+ throw new Error('Invalid parameters: comName must be string, fn must be function')
+ }
const dentryArr = [
'Address',
'Calendar',
'CalendarCard',
'Cascader',
'Checkbox',
'DatePicker',
'Form',
'Input',
'InputNumber',
+ 'Menu',
+ 'NumberKeyboard',
+ 'Picker',
+ 'Radio',
+ 'Range',
+ 'Rate',
+ 'SearchBar',
+ 'ShortPassword',
+ 'Signature',
+ 'Switch',
+ 'TextArea',
+ 'Uploader'
]
const getPath = (component) =>
`${dentryArr.includes(component) ? 'dentry' : 'dentry1'}/pages/${component.toLowerCase()}/index`
it(`${comName} successfully passes`, () => {
cy.visit(getPath(comName))
cy.get('.applets-demo-header').contains(comName)
- cy.wait(400)
+ // 使用 Cypress 内置的等待机制替代固定时间等待
+ cy.get('.applets-demo-header').should('be.visible')
fn()
})
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
describe('layout components test', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Address', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Calendar', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('CalendarCard', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Cascader', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Checkbox', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('DatePicker', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Form', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Input', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('InputNumber', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Menu', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('NumberKeyboard', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Picker', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Radio', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Range', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Rate', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('SearchBar', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('ShortPassword', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Signature', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Switch', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('TextArea', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
componentTest('Uploader', () => {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+23
to
+45
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. 测试用例实现不完整 当前的测试实现存在以下问题:
建议为每个组件添加具体的测试用例。我可以帮助生成详细的测试实现代码,包括:
是否需要我为某个特定组件生成完整的测试用例实现? |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,78 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const getPath = (component) => `layout/pages/${component}/index` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+1
to
+2
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 建议将 getPath 函数移至共享工具文件 考虑到该函数在多个测试文件中被重复使用,建议将其提取到一个共享的工具文件中(例如 +// cypress/support/utils.js
+export const getPath = (component) => `layout/pages/${component}/index`
-// cypress/e2e/taro/layout.cy.js
-const getPath = (component) => `layout/pages/${component}/index`
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
describe('layout components test', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('divider successfully passes', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.visit(getPath('divider')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.applets-demo-header').contains('Divider') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Click URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('垂直分割线').scrollIntoView() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('链接').click() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.window().then((win) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const currentPath = win.location.pathname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(currentPath).to.equal('/') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.wait(400) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+15
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 建议优化测试稳定性
it('divider successfully passes', () => {
cy.visit(getPath('divider'))
cy.get('.applets-demo-header').contains('Divider')
// Click URL
- cy.contains('垂直分割线').scrollIntoView()
+ cy.contains('垂直分割线').should('be.visible').scrollIntoView()
cy.contains('链接').click()
cy.window().then((win) => {
const currentPath = win.location.pathname
expect(currentPath).to.equal('/')
})
- cy.wait(400)
}) 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('grid successfully passes', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.visit(getPath('grid')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.applets-demo-header').contains('Grid') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// GridItem Click | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('点击子项事件').scrollIntoView() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('h2').then((element) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (element.has('点击子项事件')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.wrap(element) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.next() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.then((nextElement) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 在这里对下一个节点进行操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nextElement.find('.nut-grid-item').eq(-2).click() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('点击了文字,第2个') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.wait(400) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+17
to
+34
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 建议简化测试逻辑并统一语言风格
- it('grid successfully passes', () => {
+ it('Grid 组件测试', () => {
cy.visit(getPath('grid'))
cy.get('.applets-demo-header').contains('Grid')
- // GridItem Click
+ // 测试点击事件
cy.contains('点击子项事件').scrollIntoView()
- cy.get('h2').then((element) => {
- if (element.has('点击子项事件')) {
- cy.wrap(element)
- .next()
- .then((nextElement) => {
- // 在这里对下一个节点进行操作
- nextElement.find('.nut-grid-item').eq(-2).click()
- cy.contains('点击了文字,第2个')
- })
- }
- })
- cy.wait(400)
+ cy.contains('点击子项事件')
+ .parent()
+ .find('.nut-grid-item')
+ .eq(1)
+ .click()
+ cy.contains('点击了文字,第2个').should('be.visible')
}) 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('layout successfully passes', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.visit(getPath('layout')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.applets-demo-header').contains('Layout') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// layout test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('span:24').parent().children().should('have.length', 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('span:12').parent().parent().children().should('have.length', 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('span:8').parent().parent().children().should('have.length', 3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('span:6').parent().parent().children().should('have.length', 4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.wait(400) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('space successfully passes', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.visit(getPath('space')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.applets-demo-header').contains('Space') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Space Test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('垂直') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.next() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.find('.nut-space') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.should('have.class', 'nut-space-vertical') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.wait(400) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('sticky successfully passes', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.visit(getPath('sticky')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.applets-demo-header').contains('Sticky') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Scroll Sticky | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.demo').scrollTo('bottom') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('距离顶部120px').parent().should('have.css', 'top', '120px') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.demo').scrollTo('top') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.contains('距离底部0px').parent().should('have.css', 'bottom', '0px') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.wait(400) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+58
to
+67
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 建议增强 Sticky 组件测试的稳定性
it('sticky successfully passes', () => {
cy.visit(getPath('sticky'))
cy.get('.applets-demo-header').contains('Sticky')
- // Scroll Sticky
+ // 测试顶部固定效果
cy.get('.demo').scrollTo('bottom')
+ cy.contains('距离顶部120px').should('be.visible')
cy.contains('距离顶部120px').parent().should('have.css', 'top', '120px')
+
+ // 测试底部固定效果
cy.get('.demo').scrollTo('top')
+ cy.contains('距离底部0px').should('be.visible')
cy.contains('距离底部0px').parent().should('have.css', 'bottom', '0px')
- cy.wait(400)
}) 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('safearea successfully passes', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.visit(getPath('safearea')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.applets-demo-header').contains('SafeArea') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// SafeArea Class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.demo').scrollTo('bottom') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.nut-safe-area').should('exist') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.get('.nut-safe-area-position-bottom').should('exist') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.wait(400) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) |
Uh oh!
There was an error while loading. Please reload this page.