]>
Commit | Line | Data |
---|---|---|
b3b6e05e TL |
1 | import { PageHelper } from '../page-helper.po'; |
2 | ||
3 | const pages = { | |
4 | index: { url: '#/services', id: 'cd-services' }, | |
5 | create: { url: '#/services/create', id: 'cd-service-form' } | |
6 | }; | |
7 | ||
8 | export class ServicesPageHelper extends PageHelper { | |
9 | pages = pages; | |
10 | ||
11 | columnIndex = { | |
12 | service_name: 2, | |
13 | placement: 3, | |
14 | running: 4, | |
15 | size: 5, | |
16 | last_refresh: 6 | |
17 | }; | |
18 | ||
19 | check_for_service() { | |
20 | this.getTableCount('total').should('not.be.eq', 0); | |
21 | } | |
22 | ||
23 | private selectServiceType(serviceType: string) { | |
24 | return this.selectOption('service_type', serviceType); | |
25 | } | |
26 | ||
27 | @PageHelper.restrictTo(pages.create.url) | |
28 | addService(serviceType: string, exist?: boolean) { | |
29 | cy.get(`${this.pages.create.id}`).within(() => { | |
30 | this.selectServiceType(serviceType); | |
31 | if (serviceType === 'rgw') { | |
32 | cy.get('#service_id').type('rgw.foo'); | |
33 | cy.get('#count').type('1'); | |
34 | } else if (serviceType === 'ingress') { | |
35 | this.selectOption('backend_service', 'rgw.rgw.foo'); | |
36 | cy.get('#service_id').should('have.value', 'rgw.rgw.foo'); | |
37 | cy.get('#virtual_ip').type('192.168.20.1/24'); | |
38 | cy.get('#frontend_port').type('8081'); | |
39 | cy.get('#monitor_port').type('8082'); | |
40 | } | |
41 | ||
42 | cy.get('cd-submit-button').click(); | |
43 | }); | |
44 | if (exist) { | |
45 | cy.get('#service_id').should('have.class', 'ng-invalid'); | |
46 | } else { | |
47 | // back to service list | |
48 | cy.get(`${this.pages.index.id}`); | |
49 | } | |
50 | } | |
51 | ||
52 | @PageHelper.restrictTo(pages.index.url) | |
53 | checkExist(serviceName: string, exist: boolean) { | |
54 | this.getTableCell(this.columnIndex.service_name, serviceName).should(($elements) => { | |
55 | const services = $elements.map((_, el) => el.textContent).get(); | |
56 | if (exist) { | |
57 | expect(services).to.include(serviceName); | |
58 | } else { | |
59 | expect(services).to.not.include(serviceName); | |
60 | } | |
61 | }); | |
62 | } | |
63 | ||
64 | @PageHelper.restrictTo(pages.index.url) | |
65 | deleteService(serviceName: string, wait: number) { | |
66 | const getRow = this.getTableCell.bind(this, this.columnIndex.service_name); | |
67 | getRow(serviceName).click(); | |
68 | ||
69 | // Clicks on table Delete button | |
70 | this.clickActionButton('delete'); | |
71 | ||
72 | // Confirms deletion | |
73 | cy.get('cd-modal .custom-control-label').click(); | |
74 | cy.contains('cd-modal button', 'Delete').click(); | |
75 | ||
76 | // Wait for modal to close | |
77 | cy.get('cd-modal').should('not.exist'); | |
78 | ||
79 | // wait for delete operation to complete: tearing down the service daemons | |
80 | cy.wait(wait); | |
81 | ||
82 | this.checkExist(serviceName, false); | |
83 | } | |
84 | } |