forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample-card-add-page.ts
152 lines (126 loc) · 4.38 KB
/
sample-card-add-page.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
143
144
145
146
147
148
149
150
151
152
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps';
import { detailsPage } from '@console/cypress-integration-tests/views/details-page';
import { addOptions, devNavigationMenu, switchPerspective } from '../../constants';
import { addPagePO, samplesPO } from '../../pageObjects';
import {
addPage,
app,
navigateTo,
perspective,
projectNameSpace,
samplesPage,
topologyPage,
verifyAddPage,
} from '../../pages';
Given('user is at developer perspective', () => {
perspective.switchTo(switchPerspective.Developer);
});
Given('user has created or selected namespace {string}', (projectName: string) => {
projectNameSpace.selectOrCreateProject(`${projectName}`);
});
Given('user is at Add page', () => {
navigateTo(devNavigationMenu.Add);
});
When('user clicks on the {string} link', () => {
cy.get(addPagePO.viewAllSamples).click();
});
When('user is redirected to Samples Page', () => {
cy.byLegacyTestID('resource-title').contains('Sample');
});
When('user clicks on the Samples card', () => {
verifyAddPage.verifyAddPageCard('Samples');
addPage.selectCardFromOptions(addOptions.Samples);
});
When('user selects {string} sample from Samples', (sample: string) => {
samplesPage.search(sample);
samplesPage.selectCardInSamples(sample);
});
When('user is able to see the form header name as {string}', (formName) => {
app.waitForLoad();
detailsPage.titleShouldContain(formName);
});
Then('form is filled with default values', () => {
cy.get('input[name="git.url"]')
.invoke('attr', 'value')
.then((text) => {
if (text !== undefined) {
return true;
}
return false;
});
cy.byLegacyTestID('git-form-input-url').should('be.disabled');
});
Then('user will see builder image below builder image version dropdown', () => {
cy.get('img[alt="Icon"]').should('be.visible');
});
Then('user is able to see different sample applications', () => {
cy.get('[data-test*="Devfile"]').first().should('be.visible');
cy.get('[data-test*="BuilderImage"]').first().should('be.visible');
});
Then('sample applications are based on the builder images', () => {
cy.get('[data-test^="BuilderImage"]').then((elements) => {
if (elements.length >= 1) {
return true;
}
return false;
});
});
When('user clicks on the Create button', () => {
app.waitForLoad();
cy.byLegacyTestID('submit-button').click();
});
When('user selects a sample card', () => {
cy.get('[class*="catalog"]').first().click();
});
Then('user will see the name section', () => {
cy.byLegacyTestID('application-form-app-name').should('be.visible');
});
Then('user will see builder image version dropdown', () => {
cy.byLegacyTestID('dropdown-button').should('be.visible');
});
Then('user will see git url is ineditable field', () => {
cy.byLegacyTestID('git-form-input-url').should('be.visible');
});
Then('user will see create and cancel button', () => {
cy.byLegacyTestID('submit-button').should('be.visible');
cy.byLegacyTestID('reset-button').should('be.visible');
});
Given('user is in Add flow of dev perspective', () => {
navigateTo(devNavigationMenu.Add);
});
When('user assign a new name as {string} in the name section', (workload: string) => {
cy.byLegacyTestID('application-form-app-name').clear().type(workload);
});
When('user changes the builder image version from dropdown to {string}', (version: string) => {
cy.byLegacyTestID('dropdown-button').should('be.visible').click();
cy.byLegacyTestID('dropdown-menu').contains(version).click();
});
Then(
'user is taken to topology with a {string} deployment workload created inside sample application',
(workloadName: string) => {
topologyPage.verifyTopologyPage();
topologyPage.verifyWorkloadInTopologyPage(workloadName);
},
);
Given('user is at Samples page', () => {
navigateTo(devNavigationMenu.Add);
cy.get(addPagePO.viewAllSamples).click();
});
When('user clicks on the {string} card', (sample: string) => {
samplesPage.selectCardInSamples(sample);
});
When(
'user assigns a name {string} in the Name section of Import from Devfile form',
(name: string) => {
app.waitForLoad();
cy.wait(10000);
cy.get(samplesPO.form.name).clear().type(name);
},
);
Then(
'user is taken to Topology page with deployment workload {string} created',
(workloadName: string) => {
topologyPage.verifyTopologyPage();
topologyPage.verifyWorkloadInTopologyPage(workloadName);
},
);