/
events.cy.ts
74 lines (66 loc) · 1.95 KB
/
events.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
import { testName, checkErrors } from '../../support';
const name = `${testName}-event-test-pod`;
const testpod = {
apiVersion: 'v1',
kind: 'Pod',
metadata: {
name,
namespace: testName,
},
spec: {
securityContext: {
runAsNonRoot: true,
seccompProfile: {
type: 'RuntimeDefault',
},
},
containers: [
{
name: 'httpd',
image: 'image-registry.openshift-image-registry.svc:5000/openshift/httpd:latest-error', // intentionally invalid image url
securityContext: {
allowPrivilegeEscalation: false,
capabilities: {
drop: ['ALL'],
},
},
},
],
},
};
describe('Events', () => {
before(() => {
cy.login();
cy.createProjectWithCLI(testName);
try {
cy.exec(`echo '${JSON.stringify(testpod)}' | kubectl create -n ${testName} -f -`);
} catch (error) {
console.error(`\nFailed to create pod ${name}:\n${error}`);
}
});
afterEach(() => {
checkErrors();
});
after(() => {
try {
cy.exec(`kubectl delete pods ${name} -n ${testName}`);
} catch (error) {
console.error(`\nFailed to delete pod ${name}:\n${error}`);
}
cy.deleteProjectWithCLI(testName);
});
it('displays events for a newly created Pod', () => {
cy.visit(`/k8s/ns/${testName}/events`);
cy.log('Pod should exist in events list');
cy.byTestID(name).should('exist');
cy.log('Event type filter should work');
cy.byLegacyTestID('dropdown-button').click();
cy.get('[data-test-dropdown-menu="warning"]').click();
cy.byTestID('event-totals').should('have.text', 'Showing 3 events');
cy.byTestID('event-warning').should('have.length', 3);
cy.log('Event text filter should work');
cy.byLegacyTestID('item-filter').type('Error: ImagePullBackOff');
cy.byTestID('event-totals').should('have.text', 'Showing 1 event');
cy.byTestID('event-warning').should('have.length', 1);
});
});