1 import { HostsPageHelper } from '../cluster/hosts.po';
3 describe('Hosts page', () => {
4 const hosts = new HostsPageHelper();
8 Cypress.Cookies.preserveOnce('token');
12 describe('when Orchestrator is available', () => {
13 beforeEach(function () {
14 cy.fixture('orchestrator/inventory.json').as('hosts');
15 cy.fixture('orchestrator/services.json').as('services');
18 it('should not add an exsiting host', function () {
19 const hostname = Cypress._.sample(this.hosts).name;
20 hosts.navigateTo('create');
21 hosts.add(hostname, true);
24 it('should delete a host and add it back', function () {
25 const host = Cypress._.last(this.hosts)['name'];
29 hosts.navigateTo('create');
31 hosts.checkExist(host, true);
34 it('should display inventory', function () {
35 for (const host of this.hosts) {
36 hosts.clickHostTab(host.name, 'Inventory');
37 cy.get('cd-host-details').within(() => {
38 hosts.getTableCount('total').should('be.gte', 0);
43 it('should display daemons', function () {
44 for (const host of this.hosts) {
45 hosts.clickHostTab(host.name, 'Daemons');
46 cy.get('cd-host-details').within(() => {
47 hosts.getTableCount('total').should('be.gte', 0);
52 it('should edit host labels', function () {
53 const hostname = Cypress._.sample(this.hosts).name;
54 const labels = ['foo', 'bar'];
55 hosts.editLabels(hostname, labels, true);
56 hosts.editLabels(hostname, labels, false);
59 it('should enter host into maintenance', function () {
60 const hostname = Cypress._.sample(this.hosts).name;
61 const serviceList = new Array();
62 this.services.forEach((service: any) => {
63 if (hostname === service.hostname) {
64 serviceList.push(service.daemon_type);
67 let enterMaintenance = true;
68 serviceList.forEach((service: string) => {
69 if (service === 'mgr' || service === 'alertmanager') {
70 enterMaintenance = false;
73 if (enterMaintenance) {
74 hosts.maintenance(hostname);
78 it('should exit host from maintenance', function () {
79 const hostname = Cypress._.sample(this.hosts).name;
80 hosts.maintenance(hostname, true);