-
Notifications
You must be signed in to change notification settings - Fork 592
/
common.ts
72 lines (59 loc) · 2.7 KB
/
common.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
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps';
import { detailsPage } from '@console/cypress-integration-tests/views/details-page';
import { guidedTour } from '@console/cypress-integration-tests/views/guided-tour';
import { modal } from '@console/cypress-integration-tests/views/modal';
import { nav } from '@console/cypress-integration-tests/views/nav';
import { switchPerspective, devNavigationMenu, adminNavigationMenu } from '../../constants';
import { perspective, projectNameSpace, navigateTo } from '../../pages';
Given('user is at developer perspective', () => {
perspective.switchTo(switchPerspective.Developer);
cy.testA11y('Developer perspective with guide tour modal');
guidedTour.close();
nav.sidenav.switcher.shouldHaveText(switchPerspective.Developer);
// Commenting below line, because it is executing on every test scenario - we will remove this in future releases
// cy.testA11y('Developer perspective');
});
Given('user has created namespace starts with {string}', (projectName: string) => {
const d = new Date();
const timestamp = d.getTime();
projectNameSpace.selectOrCreateProject(`${projectName}-${timestamp}-ns`);
cy.testA11y('Developer perspective display after creating or selecting project');
});
Given('user has created or selected namespace {string}', (projectName: string) => {
Cypress.env('NAMESPACE', projectName);
projectNameSpace.selectOrCreateProject(`${projectName}`);
});
Given('user is at Monitoring page', () => {
navigateTo(devNavigationMenu.Observe);
});
Given('user is at namespace {string}', (projectName: string) => {
Cypress.env('NAMESPACE', projectName);
projectNameSpace.selectOrCreateProject(projectName);
});
When('user switches to developer perspective', () => {
perspective.switchTo(switchPerspective.Developer);
guidedTour.close();
});
When('user selects {string} option from Actions menu', (option: string) => {
cy.byTestActionID(option).click();
});
Then('modal with {string} appears', (header: string) => {
modal.modalTitleShouldContain(header);
});
Then('user will be redirected to Pipelines page', () => {
detailsPage.titleShouldContain(adminNavigationMenu.pipelines);
});
When('user clicks create button', () => {
cy.get('button[type="submit"]').click();
});
Given('user has selected namespace {string}', (projectName: string) => {
projectNameSpace.selectProject(projectName);
cy.log(`User has selected namespace ${projectName}`);
});
When('user clicks on {string} link', (buttonName: string) => {
cy.byButtonText(buttonName).click();
});
When('user is at namespace {string}', (projectName: string) => {
perspective.switchTo(switchPerspective.Developer);
projectNameSpace.selectOrCreateProject(projectName);
});