chore: add expect to eslintrc
This commit is contained in:
parent
0608c6b956
commit
cb47502fb9
4 changed files with 35 additions and 33 deletions
|
|
@ -137,6 +137,7 @@
|
|||
"Cypress": true,
|
||||
"cy": true,
|
||||
"it": true,
|
||||
"expect": true,
|
||||
"context": true,
|
||||
"before": true,
|
||||
"beforeEach": true
|
||||
|
|
|
|||
|
|
@ -1,37 +1,38 @@
|
|||
context('Rating Control', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('Administrator', 'qwe');
|
||||
});
|
||||
});
|
||||
|
||||
it('click on the star rating to record value', () => {
|
||||
cy.visit('/desk')
|
||||
cy.dialog('Rating', {
|
||||
'fieldname': 'rate', 'fieldtype': 'Rating',
|
||||
}).as('dialog');
|
||||
it('click on the star rating to record value', () => {
|
||||
cy.visit('/desk')
|
||||
cy.dialog('Rating', {
|
||||
'fieldname': 'rate',
|
||||
'fieldtype': 'Rating',
|
||||
}).as('dialog');
|
||||
|
||||
cy.get('div.rating')
|
||||
.children('i.fa')
|
||||
.first()
|
||||
.click()
|
||||
.should('have.class', 'star-click');
|
||||
cy.get('@dialog').then(dialog => {
|
||||
var value = dialog.get_value('rate');
|
||||
expect(value).to.equal(1)
|
||||
})
|
||||
});
|
||||
|
||||
it('hover on the star', () => {
|
||||
cy.visit('/desk')
|
||||
cy.dialog('Rating', {
|
||||
'fieldname': 'rate', 'fieldtype': 'Rating',
|
||||
})
|
||||
cy.get('div.rating')
|
||||
.children('i.fa')
|
||||
.first()
|
||||
.invoke('trigger', 'mouseenter')
|
||||
.should('have.class', 'star-hover')
|
||||
.invoke('trigger', 'mouseleave')
|
||||
.should('not.have.class', 'star-hover');
|
||||
});
|
||||
cy.get('div.rating')
|
||||
.children('i.fa')
|
||||
.first()
|
||||
.click()
|
||||
.should('have.class', 'star-click');
|
||||
cy.get('@dialog').then(dialog => {
|
||||
var value = dialog.get_value('rate');
|
||||
expect(value).to.equal(1);
|
||||
})
|
||||
});
|
||||
|
||||
it('hover on the star', () => {
|
||||
cy.visit('/desk')
|
||||
cy.dialog('Rating', {
|
||||
'fieldname': 'rate',
|
||||
'fieldtype': 'Rating',
|
||||
})
|
||||
cy.get('div.rating')
|
||||
.children('i.fa')
|
||||
.first()
|
||||
.invoke('trigger', 'mouseenter')
|
||||
.should('have.class', 'star-hover')
|
||||
.invoke('trigger', 'mouseleave')
|
||||
.should('not.have.class', 'star-hover');
|
||||
});
|
||||
});
|
||||
|
|
@ -74,6 +74,6 @@ Cypress.Commands.add('dialog', (title, fields) => {
|
|||
}
|
||||
});
|
||||
d.show();
|
||||
return d
|
||||
return d;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,12 +52,12 @@ frappe.form.formatters = {
|
|||
Percent: function(value, docfield, options) {
|
||||
return frappe.form.formatters._right(flt(value, 2) + "%", options)
|
||||
},
|
||||
Rating: function(value, docfield, options, doc) {
|
||||
Rating: function(value, docfield, options) {
|
||||
return `
|
||||
<div class="rating">
|
||||
${Array.from(new Array(5)).map((_, i) =>
|
||||
`<i class="fa fa-fw fa-star ${i < (value || 0) ? "star-click": "" } star-icon" data-idx="${(i+1)}"></i>`
|
||||
).join('')}
|
||||
).join('')}
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue