-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcreate_draft_spec.js
91 lines (62 loc) · 2.66 KB
/
create_draft_spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { DRAFTS } from "../../routes";
describe("Create Draft", function () {
let firstTitle = "Random Title";
let updatedTitle = "This is my new title";
it("Create a new Draft", () => {
// create a new CMS Analysis
// given a random tiltle
cy.createDraft("CMS Analysis", firstTitle);
});
it("Update the title but discard saving", () => {
// navigate to the draft
cy.get("[data-cy=DraftDocuments-list] a").first().click();
cy.get("[data-cy=editableTitleEdit]").click();
cy.get("[data-cy=editableInput]").type(updatedTitle);
// cancel the changes
cy.get("[data-cy=editableTitleClose]").click();
cy.get("[data-cy=editableTitleValue]").contains(firstTitle);
});
it("Update the general title of the draft", () => {
cy.get("[data-cy=DraftDocuments-list] a").first().click();
cy.get("[data-cy=editableTitleEdit]").click();
// erase the previous title and insert the new one
cy.get("[data-cy=editableInput]").clear().type(`${updatedTitle}{enter}`);
cy.get("[data-cy=editableTitleValue]").contains(updatedTitle);
});
it("Delete Draft", () => {
cy.get("[data-cy=DraftDocuments-list] a").first().click();
// navigate to settings tab
cy.get("[data-cy=itemNavSettings]").click();
// open the Popconfirm
cy.get("[data-cy=draft-delete-btn]").click();
// validate delete
cy.get(".ant-popconfirm-buttons button").contains("Delete").click();
cy.url().should("not.include", DRAFTS);
});
it("Does not allow to continue when anatype is not selected", () => {
// open the Create modal
cy.get("[data-cy=headerCreateButton]").contains("Create").click();
// type in a General Title
cy.get("input[type='text']").type("This is my new draft");
// Start Preserving
cy.get("div").contains("Start Preserving").click();
cy.url().should("not.include", DRAFTS);
});
it("Save a draft with an empty required field", () => {
// navigate to the draft
cy.get("[data-cy=DraftDocuments-list] a").first().click();
// navigate to edit tab
cy.get("[data-cy=itemNavEdit]").click();
// type in a normal field but leave the required field empty
cy.get("textarea#root\\!basic_info\\!abstract").type("whatever");
// save the draft
cy.get("[data-cy=draft-save-btn]").click();
// validate save
cy.get("div.ant-notification-notice-message").contains("Draft saved");
});
});