-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathpublished_spec.js
108 lines (75 loc) · 3.23 KB
/
published_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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
describe("Published Tests", function () {
const firstTitle = "My First CMS Analysis";
it("Publish a CMS Draft", () => {
// create a new ALICE Analysis
// given a random tiltle
cy.createDraft("CMS Analysis", firstTitle, "cms");
cy.visit("/");
cy.get("[data-cy=DraftDocuments-list] a").first().click();
// navigate to edit tab
cy.get("[data-cy=itemNavEdit]").click();
// fill in the required field
cy.get("input#root\\!basic_info\\!cadi_id").type("JME-10-107");
//save the draft
cy.get("[data-cy=draft-save-btn]").click();
// navigate to settings tab
cy.get("[data-cy=itemNavSettings]").click();
// click publish button
cy.get("[data-cy=draftSettingsRecidButton]").click();
// confirm publish action
cy.get("[data-cy=draftSettingsPublish]").click();
// make sure that the current version button is visible
cy.get("[data-cy=draftSettingsCurrentVersionLink]");
});
it("A published report would not be deleted", () => {
// safety handler, in order to have time for the re indexing of elastic
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000);
cy.get("[data-cy=PublishedDocumentsinCAP-list] a").first().click();
cy.get("[data-cy=editPublished]").click();
// navigate to settings tab
cy.get("[data-cy=itemNavSettings]").click();
cy.get("[data-cy=draft-delete-btn]").should("have.attr", "disabled");
});
it("Change a published into a Draft", () => {
cy.get("[data-cy=PublishedDocumentsinCAP-list] a").first().click();
cy.get("[data-cy=editPublished]").click();
cy.get("[data-cy=changeToDraftButton]").click();
cy.get("[data-cy=sidebarStatus]").contains("draft");
});
it("Does not allow publishing a draft with an empty required field", () => {
cy.createDraft("CMS Analysis", "empty-required", "cms");
cy.visit("/");
cy.get("[data-cy=DraftDocuments-list] a").first().click();
// 1. Check that the validation works without modifying the form data
// navigate to settings tab
cy.get("[data-cy=itemNavSettings]").click();
// click publish button
cy.get("[data-cy=draftSettingsRecidButton]").click();
// confirm publish action
cy.get("[data-cy=draftSettingsPublish]").click();
// verify that it throws an error
cy.get("div.ant-notification-notice-message").contains(
"Validation Error while publishing"
);
// 2. Check the that the validation works after modifying the form data
// 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("asd");
// save the draft
cy.get("[data-cy=draft-save-btn]").click();
// navigate to settings tab
cy.get("[data-cy=itemNavSettings]").click();
// click publish button
cy.get("[data-cy=draftSettingsRecidButton]").click();
// confirm publish action
cy.get("[data-cy=draftSettingsPublish]").click();
// verify that it throws an error
cy.get("div.ant-notification-notice-message").contains(
"Validation Error while publishing"
);
});
});