-
Notifications
You must be signed in to change notification settings - Fork 694
Expand file tree
/
Copy pathweb-terminal-detach.ts
More file actions
78 lines (65 loc) · 3.04 KB
/
web-terminal-detach.ts
File metadata and controls
78 lines (65 loc) · 3.04 KB
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
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps';
import { detachTerminalPage } from '@console/webterminal-plugin/integration-tests/support/step-definitions/pages/web-terminal/detachTerminal-page';
import { webTerminalPage } from '@console/webterminal-plugin/integration-tests/support/step-definitions/pages/web-terminal/webTerminal-page';
Given('user is on the pod details terminal tab for a running pod', () => {
const ns = Cypress.expose('NAMESPACE') || 'aut-terminal-detach';
cy.exec(`oc get pods -n ${ns} -o jsonpath='{.items[0].metadata.name}'`).then((result) => {
const podName = result.stdout.replace(/'/g, '');
cy.visit(`/k8s/ns/${ns}/pods/${podName}/terminal`);
cy.get('.co-terminal', { timeout: 30000 }).should('be.visible');
});
});
When('user clicks the Detach to Cloud Shell button', () => {
detachTerminalPage.clickDetachButton();
});
Then('user will see the Cloud Shell drawer open', () => {
detachTerminalPage.verifyDrawerOpen();
});
Then('user will see a detached session tab with the pod name', () => {
detachTerminalPage.verifyDetachedTabs(1);
});
Given('user has a detached terminal session in the Cloud Shell drawer', () => {
const ns = Cypress.expose('NAMESPACE') || 'aut-terminal-detach';
cy.exec(`oc get pods -n ${ns} -o jsonpath='{.items[0].metadata.name}'`).then((result) => {
const podName = result.stdout.replace(/'/g, '');
cy.visit(`/k8s/ns/${ns}/pods/${podName}/terminal`);
cy.get('.co-terminal', { timeout: 30000 }).should('be.visible');
detachTerminalPage.clickDetachButton();
detachTerminalPage.verifyDetachedTabs(1);
});
});
When('user navigates to a different page', () => {
cy.visit('/k8s/cluster/projects');
cy.url().should('include', '/projects');
});
Then('user will still see the detached session tab in the Cloud Shell drawer', () => {
detachTerminalPage.verifyDetachedTabs(1);
});
When('user clicks the close button on the detached session tab', () => {
detachTerminalPage.closeDetachedTab(0);
});
Then('the detached session tab is removed from the drawer', () => {
detachTerminalPage.verifyNoDetachedTabs();
});
Given('user has five detached terminal sessions in the Cloud Shell drawer', () => {
const ns = Cypress.expose('NAMESPACE') || 'aut-terminal-detach';
cy.exec(`oc get pods -n ${ns} -o jsonpath='{.items[*].metadata.name}'`).then((result) => {
const pods = result.stdout.replace(/'/g, '').split(' ');
const targetPod = pods[0];
for (let i = 0; i < 5; i++) {
cy.visit(`/k8s/ns/${ns}/pods/${targetPod}/terminal`);
cy.get('.co-terminal', { timeout: 30000 }).should('be.visible');
detachTerminalPage.clickDetachButton();
}
detachTerminalPage.verifyDetachedTabs(5);
});
});
Then('the Detach to Cloud Shell button is disabled on the pod terminal', () => {
detachTerminalPage.verifyDetachButtonDisabled();
});
When('user closes the Cloud Shell drawer', () => {
webTerminalPage.closeCurrentTerminalSession();
});
Then('user will not see any detached session tabs', () => {
detachTerminalPage.verifyNoDetachedTabs();
});