forked from module-federation/module-federation-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckApplications.cy.ts
142 lines (136 loc) · 7.08 KB
/
checkApplications.cy.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import {baseSelectors, commonSelectors} from '../../cypress/common/selectors';
import { BaseMethods } from "../../cypress/common/base";
import { Constants } from "../../cypress/fixtures/constants";
import { getDateWithFormat } from "../../cypress/helpers/base-helper";
import { CssAttr } from '../../cypress/types/cssAttr';
import {returnCommonDynamicAppsData} from "../../cypress/fixtures/commonTestData";
const basePage: BaseMethods = new BaseMethods()
const appsData = returnCommonDynamicAppsData(Constants.commonPhrases.dynamicSystemHostApp.paragraphText)
appsData.forEach(
(
property: {
headerSelector: string
subHeaderSelector: string
isButtonExist: boolean,
buttonSelector: string,
headerText: string,
appNameText: string,
widgetQuantity?: number,
widgetName: string[],
widgetParagraph: string[],
widgetColor: string[]
paragraph: boolean,
host: number
}) => {
const appName = property.host === 3001 ? appsData[0].appNameText : property.host === 3002 ? appsData[1].appNameText : appsData[2].appNameText;
const host = property.host === 3001 ? appsData[0].host : property.host === 3002 ? appsData[1].host : appsData[2].host;
const widget: number = property.host === 3002 ? Number(appsData[1].widgetQuantity) : Number(appsData[2].widgetQuantity);
describe('Dynamic System Host', () => {
context(`Check ${appName}`, () => {
it(`Check ${appName} built and running`, () => {
basePage.openLocalhost({
number: host
})
basePage.checkElementWithTextPresence({
selector: property.headerSelector,
text: property.headerText
})
basePage.checkElementWithTextPresence({
selector: property.subHeaderSelector,
text: appName
})
property.paragraph ?
basePage.checkElementWithTextPresence({
selector: baseSelectors.tags.paragraph,
text: Constants.commonPhrases.dynamicSystemHostApp.hostParagraph,
})
:
basePage.checkElementWithTextPresence({
selector: baseSelectors.tags.paragraph,
text: Constants.commonPhrases.dynamicSystemHostApp.hostParagraph,
isVisible: false
})
})
it(`Check buttons in ${appName} exist`, () => {
basePage.openLocalhost({
number: host
})
property.isButtonExist ?
Constants.elementsText.dynamicRemotesApp.buttonsText.forEach(button => {
basePage.checkElementWithTextPresence({
selector: property.buttonSelector,
text: button
})
})
:
basePage.checkElementVisibility({
selector: property.buttonSelector,
isVisible: property.isButtonExist
})
})
it(`Check functionality in ${appName}`, () => {
basePage.openLocalhost({
number: host
})
if (property.isButtonExist) {
Constants.elementsText.dynamicRemotesApp.buttonsText.forEach(button => {
basePage.clickElementWithText({
selector: property.buttonSelector,
text: button
})
basePage.checkElementVisibility({
selector: commonSelectors.commonWidget.replace(
'{appQuantity}',
(Constants.elementsText.dynamicRemotesApp.buttonsText.indexOf(button) + 2).toString())
})
basePage.checkElementHaveProperty({
selector: commonSelectors.commonWidget.replace(
'{appQuantity}',
(Constants.elementsText.dynamicRemotesApp.buttonsText.indexOf(button) + 2).toString()),
prop: CssAttr.backgroundColor,
value: property.widgetColor[Constants.elementsText.dynamicRemotesApp.buttonsText.indexOf(button)]
})
basePage.checkElementWithTextPresence({
selector: property.subHeaderSelector,
text: property.widgetName[Constants.elementsText.dynamicRemotesApp.buttonsText.indexOf(button)]
})
basePage.checkElementWithTextPresence({
selector: baseSelectors.tags.paragraph,
text: property.widgetParagraph[Constants.elementsText.dynamicRemotesApp.buttonsText.indexOf(button)]
})
basePage.checkElementWithTextPresence({
selector: baseSelectors.tags.paragraph,
text: getDateWithFormat('current', 'MMMM Do YYYY, h:mm')
})
})
} else {
basePage.checkElementVisibility({
selector: commonSelectors.commonWidget.replace(
'{appQuantity}',
(widget + 2).toString())
})
basePage.checkElementHaveProperty({
selector: commonSelectors.commonWidget.replace(
'{appQuantity}',
(widget + 2).toString()),
prop: 'background-color',
value: property.widgetColor[widget]
})
basePage.checkElementWithTextPresence({
selector: property.subHeaderSelector,
text: property.widgetName[widget]
})
basePage.checkElementWithTextPresence({
selector: baseSelectors.tags.paragraph,
text: property.widgetParagraph[widget]
})
basePage.checkElementWithTextPresence({
selector: baseSelectors.tags.paragraph,
text: getDateWithFormat('current', 'MMMM Do YYYY, h:mm')
})
}
})
})
})
}
)