-
Notifications
You must be signed in to change notification settings - Fork 596
/
quickStartsPage.ts
97 lines (94 loc) · 3.49 KB
/
quickStartsPage.ts
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
import { devNavigationMenu } from '../constants/global';
import {
addPagePO,
quickStartLeaveModalPO,
quickStartSidebarPO,
quickStartsPO,
} from '../pageObjects';
import { app, navigateTo } from './app';
function clickVisibleButton(el: string) {
cy.get(quickStartSidebarPO.quickStartSidebarBody).then(($button) => {
const isVisible = $button.find(el).is(':visible');
if (isVisible) {
cy.get(el).click();
clickVisibleButton(el);
} else {
cy.log('quick start is complete');
}
});
}
export function closeQuickStart() {
cy.get(quickStartSidebarPO.quickStartSidebarBody).should('be.visible');
cy.get(quickStartSidebarPO.closePanel).should('be.visible').click();
cy.get(quickStartLeaveModalPO.leaveModal).should('be.visible');
cy.get(quickStartLeaveModalPO.leaveButton).should('be.visible').click();
}
export const quickStartsPage = {
quickStartsCatalog: () => {
navigateTo(devNavigationMenu.Add);
app.waitForDocumentLoad();
cy.get(addPagePO.viewAllQuickStarts).click();
cy.get(quickStartsPO.quickStartTitle).scrollIntoView().should('be.visible');
app.waitForLoad();
cy.get('.pfext-quick-start-catalog__gallery').should('be.visible');
},
filterByKeyword: (filterName: string) => {
cy.get(quickStartsPO.filterKeyword).scrollIntoView().click();
cy.get(quickStartsPO.filterKeyword).type(filterName);
},
cardPresent: (cardName: string) => {
cy.get(cardName).scrollIntoView().should('be.visible');
},
status: () => {
cy.get(quickStartsPO.statusFilter).scrollIntoView().click();
app.waitForLoad();
cy.get(quickStartsPO.statusDropdown).should('be.visible');
},
executeQuickStart: (quickStart: string) => {
cy.get(quickStart)
.parent()
.then(($el) => {
if ($el.find(quickStartsPO.cardStatus).is(':visible')) {
if ($el.text().includes('Complete')) {
cy.log('quick start is complete');
} else {
cy.get(quickStart).scrollIntoView().click();
app.waitForDocumentLoad();
cy.get(quickStartSidebarPO.quickStartSidebarBody).should('be.visible');
clickVisibleButton(quickStartSidebarPO.nextButton);
cy.get(quickStartSidebarPO.quickStartSidebarBody)
.find(quickStartSidebarPO.closeButton)
.click();
cy.get(quickStart)
.parent()
.find(quickStartsPO.cardStatus)
.should('be.visible')
.contains('Complete');
}
} else {
cy.get(quickStart).scrollIntoView().click();
app.waitForDocumentLoad();
cy.get(quickStartSidebarPO.quickStartSidebarBody).should('be.visible');
cy.get(quickStartSidebarPO.quickStartSidebarBody)
.find(quickStartSidebarPO.startButton)
.click();
clickVisibleButton(quickStartSidebarPO.nextButton);
cy.get(quickStartSidebarPO.quickStartSidebarBody)
.find(quickStartSidebarPO.closeButton)
.click();
cy.get(quickStart)
.parent()
.find(quickStartsPO.cardStatus)
.should('be.visible')
.contains('Complete');
}
});
},
leaveQuickStartIncomplete: (quickStart: string) => {
cy.get(quickStart).scrollIntoView().click();
app.waitForDocumentLoad();
cy.get(quickStartSidebarPO.quickStartSidebarBody).should('be.visible');
cy.get(quickStartSidebarPO.quickStartSidebarBody).find(quickStartSidebarPO.startButton).click();
closeQuickStart();
},
};