瀏覽代碼

test: Miscellaneous fixes to avoid flaky tests

version-14
Suraj Shetty 3 年之前
父節點
當前提交
8e9a46fff9
共有 3 個文件被更改,包括 20 次插入19 次删除
  1. +8
    -3
      cypress/integration/api.js
  2. +7
    -10
      cypress/integration/datetime_field_form_validation.js
  3. +5
    -6
      frappe/tests/ui_test_helpers.py

+ 8
- 3
cypress/integration/api.js 查看文件

@@ -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);
});
});
});
});

+ 7
- 10
cypress/integration/datetime_field_form_validation.js 查看文件

@@ -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');
});
});
});

+ 5
- 6
frappe/tests/ui_test_helpers.py 查看文件

@@ -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…
取消
儲存