|
|
@@ -6,6 +6,7 @@ context('Form', () => { |
|
|
|
return frappe.call("frappe.tests.ui_test_helpers.create_contact_records"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('create a new form', () => { |
|
|
|
cy.visit('/app/todo/new'); |
|
|
|
cy.get_field('description', 'Text Editor').type('this is a test todo', {force: true}).wait(200); |
|
|
@@ -95,4 +96,63 @@ context('Form', () => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
it('let user undo/redo field value changes', { scrollBehavior: false }, () => { |
|
|
|
const jump_to_field = (field_label) => { |
|
|
|
cy.get("body") |
|
|
|
.type("{esc}") // lose focus if any |
|
|
|
.type("{ctrl+j}") // jump to field |
|
|
|
.type(field_label) |
|
|
|
.wait(500) |
|
|
|
.type("{enter}") |
|
|
|
.wait(200) |
|
|
|
.type("{enter}") |
|
|
|
.wait(500); |
|
|
|
}; |
|
|
|
|
|
|
|
const type_value = (value) => { |
|
|
|
cy.focused() |
|
|
|
.clear() |
|
|
|
.type(value) |
|
|
|
.type("{esc}"); |
|
|
|
}; |
|
|
|
|
|
|
|
const undo = () => cy.get("body").type("{esc}").type("{ctrl+z}").wait(500); |
|
|
|
const redo = () => cy.get("body").type("{esc}").type("{ctrl+y}").wait(500); |
|
|
|
|
|
|
|
cy.new_form('User'); |
|
|
|
|
|
|
|
jump_to_field("Email"); |
|
|
|
type_value("admin@example.com"); |
|
|
|
|
|
|
|
jump_to_field("Username"); |
|
|
|
type_value("admin42"); |
|
|
|
|
|
|
|
jump_to_field("Birth Date"); |
|
|
|
type_value("12-31-01"); |
|
|
|
|
|
|
|
jump_to_field("Send Welcome Email"); |
|
|
|
cy.focused().uncheck() |
|
|
|
|
|
|
|
// make a mistake |
|
|
|
jump_to_field("Username"); |
|
|
|
type_value("admin24"); |
|
|
|
|
|
|
|
// undo behaviour |
|
|
|
undo(); |
|
|
|
cy.get_field("username").should('have.value', 'admin42'); |
|
|
|
|
|
|
|
// redo behaviour |
|
|
|
redo(); |
|
|
|
cy.get_field("username").should('have.value', 'admin24'); |
|
|
|
|
|
|
|
// undo everything & redo everything, ensure same values at the end |
|
|
|
undo(); undo(); undo(); undo(); undo(); |
|
|
|
redo(); redo(); redo(); redo(); redo(); |
|
|
|
|
|
|
|
cy.get_field("username").should('have.value', 'admin24'); |
|
|
|
cy.get_field("email").should('have.value', 'admin@example.com'); |
|
|
|
cy.get_field("birth_date").should('have.value', '12-31-2001'); // parsed value |
|
|
|
cy.get_field("send_welcome_email").should('not.be.checked'); |
|
|
|
}); |
|
|
|
}); |