-
Notifications
You must be signed in to change notification settings - Fork 596
/
console-external-log-link.cy.ts
108 lines (94 loc) · 3.51 KB
/
console-external-log-link.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
import { safeLoad, safeDump } from 'js-yaml';
import * as _ from 'lodash';
import { checkErrors, testName } from '../../support';
import { detailsPage } from '../../views/details-page';
import { errorMessage } from '../../views/form';
import { listPage } from '../../views/list-page';
import { modal } from '../../views/modal';
import { nav } from '../../views/nav';
import * as yamlEditor from '../../views/yaml-editor';
const crd = 'ConsoleExternalLogLink';
describe(`${crd} CRD`, () => {
const name = `${testName}-cell`;
const podName = `${testName}-pod`;
const cell = `[data-test-id=${name}]`;
const text = `${name} Logs`;
const namespaceFilter = '^openshift-';
before(() => {
cy.login();
cy.createProjectWithCLI(testName);
});
beforeEach(() => {
cy.initAdmin();
});
afterEach(() => {
checkErrors();
});
after(() => {
cy.deleteProjectWithCLI(testName);
cy.logout();
});
it(`creates, displays, modifies, and deletes a new ${crd} instance`, () => {
cy.visit(`/k8s/cluster/customresourcedefinitions?custom-resource-definition-name=${crd}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(crd, 'View instances');
listPage.titleShouldHaveText(crd);
listPage.clickCreateYAMLbutton();
yamlEditor.isLoaded();
yamlEditor.getEditorContent().then((content) => {
const newContent = _.defaultsDeep(
{},
{ metadata: { name }, spec: { text } },
safeLoad(content),
);
yamlEditor.setEditorContent(safeDump(newContent, { sortKeys: true })).then(() => {
yamlEditor.clickSaveCreateButton();
cy.get(errorMessage).should('not.exist');
});
});
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}/${name}`);
detailsPage.titleShouldContain(name);
cy.visit(`/k8s/ns/${testName}/pods`);
listPage.clickCreateYAMLbutton();
yamlEditor.isLoaded();
yamlEditor.getEditorContent().then((content) => {
const newContent = _.defaultsDeep(
{},
{ metadata: { name: podName, labels: { app: name } } },
safeLoad(content),
);
yamlEditor.setEditorContent(safeDump(newContent, { sortKeys: true })).then(() => {
yamlEditor.clickSaveCreateButton();
cy.get(errorMessage).should('not.exist');
});
});
cy.visit(`/k8s/ns/${testName}/pods/${podName}/logs`);
cy.get(cell).should('exist');
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}/${name}/yaml`);
yamlEditor.isLoaded();
yamlEditor.getEditorContent().then((content) => {
const newContent = _.defaultsDeep({}, { spec: { namespaceFilter } }, safeLoad(content));
yamlEditor.setEditorContent(safeDump(newContent, { sortKeys: true })).then(() => {
yamlEditor.clickSaveCreateButton();
cy.get(errorMessage).should('not.exist');
});
});
cy.visit(`/k8s/ns/${testName}/pods/${podName}/logs`);
cy.get('[data-test="log-links"').should('exist');
cy.get(cell).should('not.exist');
cy.visit(`/k8s/ns/${testName}/pods?name=${podName}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(podName, 'Delete Pod');
modal.shouldBeOpened();
modal.modalTitleShouldContain('Delete Pod');
modal.submit();
modal.shouldBeClosed();
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
modal.shouldBeOpened();
modal.modalTitleShouldContain(`Delete ${crd}`);
modal.submit();
modal.shouldBeClosed();
});
});