test: Miscellaneous fixes to avoid flaky tests
This commit is contained in:
parent
a56b117ca4
commit
8e9a46fff9
3 changed files with 20 additions and 19 deletions
|
|
@ -31,8 +31,13 @@ context('API Resources', () => {
|
|||
});
|
||||
|
||||
it('Removes the Comments', () => {
|
||||
cy.get_list('Comment').then(body => body.data.forEach(comment => {
|
||||
cy.remove_doc('Comment', comment.name);
|
||||
}));
|
||||
cy.get_list('Comment').then(body => {
|
||||
let comment_names = [];
|
||||
body.data.map(comment => comment_names.push(comment.name));
|
||||
comment_names = [...new Set(comment_names)]; // remove duplicates
|
||||
comment_names.forEach((comment_name) => {
|
||||
cy.remove_doc('Comment', comment_name);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,18 +2,15 @@ context('Datetime Field Validation', () => {
|
|||
before(() => {
|
||||
cy.login();
|
||||
cy.visit('/app/communication');
|
||||
cy.window().its('frappe').then(frappe => {
|
||||
frappe.call("frappe.tests.ui_test_helpers.create_communication_records");
|
||||
});
|
||||
});
|
||||
|
||||
// validating datetime field value when value is set from backend and get validated on form load.
|
||||
it('datetime field form validation', () => {
|
||||
cy.visit('/app/communication');
|
||||
cy.get('a[title="Test Form Communication 1"]').invoke('attr', 'data-name')
|
||||
.then((name) => {
|
||||
cy.visit(`/app/communication/${name}`);
|
||||
cy.get('.indicator-pill').should('contain', 'Open').should('have.class', 'red');
|
||||
});
|
||||
// validating datetime field value when value is set from backend and get validated on form load.
|
||||
cy.window().its('frappe').then(frappe => {
|
||||
return frappe.xcall("frappe.tests.ui_test_helpers.create_communication_record");
|
||||
}).then(doc => {
|
||||
cy.visit(`/app/communication/${doc.name}`);
|
||||
cy.get('.indicator-pill').should('contain', 'Open').should('have.class', 'red');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -62,16 +62,15 @@ def create_todo_records():
|
|||
}).insert()
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_communication_records():
|
||||
if frappe.db.get_all('Communication', {'subject': 'Test Form Communication 1'}):
|
||||
return
|
||||
|
||||
frappe.get_doc({
|
||||
def create_communication_record():
|
||||
doc = frappe.get_doc({
|
||||
"doctype": "Communication",
|
||||
"recipients": "test@gmail.com",
|
||||
"subject": "Test Form Communication 1",
|
||||
"communication_date": frappe.utils.now_datetime(),
|
||||
}).insert()
|
||||
})
|
||||
doc.insert()
|
||||
return doc
|
||||
|
||||
@frappe.whitelist()
|
||||
def setup_workflow():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue