Переглянути джерело

chore: add expect to eslintrc

version-14
Mangesh-Khairnar 6 роки тому
джерело
коміт
cb47502fb9
4 змінених файлів з 35 додано та 33 видалено
  1. +1
    -0
      .eslintrc
  2. +31
    -30
      cypress/integration/control_rating.js
  3. +1
    -1
      cypress/support/commands.js
  4. +2
    -2
      frappe/public/js/frappe/form/formatters.js

+ 1
- 0
.eslintrc Переглянути файл

@@ -137,6 +137,7 @@
"Cypress": true, "Cypress": true,
"cy": true, "cy": true,
"it": true, "it": true,
"expect": true,
"context": true, "context": true,
"before": true, "before": true,
"beforeEach": true "beforeEach": true


+ 31
- 30
cypress/integration/control_rating.js Переглянути файл

@@ -1,37 +1,38 @@
context('Rating Control', () => { context('Rating Control', () => {
beforeEach(() => { beforeEach(() => {
cy.login('Administrator', 'qwe'); 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');
});
}); });

+ 1
- 1
cypress/support/commands.js Переглянути файл

@@ -74,6 +74,6 @@ Cypress.Commands.add('dialog', (title, fields) => {
} }
}); });
d.show(); d.show();
return d
return d;
}); });
}); });

+ 2
- 2
frappe/public/js/frappe/form/formatters.js Переглянути файл

@@ -52,12 +52,12 @@ frappe.form.formatters = {
Percent: function(value, docfield, options) { Percent: function(value, docfield, options) {
return frappe.form.formatters._right(flt(value, 2) + "%", options) return frappe.form.formatters._right(flt(value, 2) + "%", options)
}, },
Rating: function(value, docfield, options, doc) {
Rating: function(value, docfield, options) {
return ` return `
<div class="rating"> <div class="rating">
${Array.from(new Array(5)).map((_, i) => ${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>` `<i class="fa fa-fw fa-star ${i < (value || 0) ? "star-click": "" } star-icon" data-idx="${(i+1)}"></i>`
).join('')}
).join('')}
</div> </div>
`; `;
}, },


Завантаження…
Відмінити
Зберегти