-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathCollectionFunctions.js
94 lines (77 loc) · 2.84 KB
/
CollectionFunctions.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
import CollectionLocators from '../locators/CollectionLocators';
class CollectionFunctions {
click_collections_button() {
cy.get(CollectionLocators.collectionBtn).click();
cy.get(CollectionLocators.addcollectionBtn).click();
}
type_name(name) {
cy.get(CollectionLocators.collectionNameField).type(name).should('have.value', name);
}
type_description(description) {
cy.get(CollectionLocators.collectionDescField).clear().type(description);
}
visibility() {
cy.get(CollectionLocators.onlyMeRadio).click({ force: true });
}
save_collection() {
cy.get(CollectionLocators.saveCollectionBtn).click();
}
open_all_collections_modal() {
cy.get(CollectionLocators.collectionBtn).click();
}
open_everyone_collection() {
cy.contains('Public Collections').should('be.visible').click();
}
verify_everyone_collection_opened() {
cy.url().should('include', '/feed/collection');
cy.get('[data-qa="search-form-main-filters-total"]').should('have.value', 'Results: 1');
}
search_collection() {
cy.get(CollectionLocators.searchCollectionField).click().type('collection{enter}');
//verify result count
//use twice the number of actual elements since this selector appears twice for each element
cy.get(CollectionLocators.selectCollection).should('have.length', 14);
//clear search and verify results
cy.get(CollectionLocators.searchCollectionField).clear().type('{enter}');
cy.get(CollectionLocators.selectCollection).should('have.length', 24);
}
select_collections() {
cy.get(CollectionLocators.selectCollection).eq(0).click();
}
type_post_title(title) {
cy.get(CollectionLocators.postTitleField).eq(0).type(title).should('have.value', title);
}
type_post_description(description) {
cy.get(CollectionLocators.postDescField).type(description);
}
save_post() {
cy.get(CollectionLocators.savePostBtn).click();
}
post_to_collection() {
cy.get(CollectionLocators.submitPostButton).click();
cy.get(CollectionLocators.surveyItem).click();
this.type_post_title('Post Title');
this.type_post_description('Post Description');
cy.get(CollectionLocators.postCheckBox).click({ force: true });
this.save_post();
cy.get(CollectionLocators.successBtn).click();
}
verify_post_added_to_collection() {
this.open_all_collections_modal();
this.select_collections();
cy.contains('Post Title').should('exist');
}
create_collection() {
let collectionName = `Automated Collection-${Math.floor(Math.random() * 100000000000)}`;
this.click_collections_button();
this.type_name(collectionName);
this.type_description('Automated Description');
this.visibility();
this.save_collection();
}
add_post_to_collection() {
this.post_to_collection();
this.verify_post_added_to_collection();
}
}
export default CollectionFunctions;