summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/cypress/e2e/block/images.e2e-spec.ts
blob: 962c135d56fc06eb1b700d17b5076be6ded920ea (plain)
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
import { PoolPageHelper } from '../pools/pools.po';
import { ImagesPageHelper } from './images.po';

describe('Images page', () => {
  const pools = new PoolPageHelper();
  const images = new ImagesPageHelper();

  const poolName = 'e2e_images_pool';

  before(() => {
    cy.login();
    // Need pool for image testing
    pools.navigateTo('create');
    pools.create(poolName, 8, 'rbd');
    pools.existTableCell(poolName);
  });

  after(() => {
    // Deletes images test pool
    pools.navigateTo();
    pools.delete(poolName);
    pools.navigateTo();
    pools.existTableCell(poolName, false);
  });

  beforeEach(() => {
    cy.login();
    images.navigateTo();
  });

  it('should open and show breadcrumb', () => {
    images.expectBreadcrumbText('Images');
  });

  it('should show four tabs', () => {
    images.getTabsCount().should('eq', 4);
  });

  it('should show text for all tabs', () => {
    images.getTabText(0).should('eq', 'Images');
    images.getTabText(1).should('eq', 'Namespaces');
    images.getTabText(2).should('eq', 'Trash');
    images.getTabText(3).should('eq', 'Overall Performance');
  });

  describe('create, edit & delete image test', () => {
    const imageName = 'e2e_images#image';
    const newImageName = 'e2e_images#image_new';

    it('should create image', () => {
      images.createImage(imageName, poolName, '1');
      images.getFirstTableCell(imageName).should('exist');
    });

    it('should edit image', () => {
      images.editImage(imageName, poolName, newImageName, '2');
      images.getFirstTableCell(newImageName).should('exist');
    });

    it('should delete image', () => {
      images.delete(newImageName);
    });
  });

  describe('move to trash, restore and purge image tests', () => {
    const imageName = 'e2e_trash#image';
    const newImageName = 'e2e_newtrash#image';

    before(() => {
      cy.login();
      // Need image for trash testing
      images.createImage(imageName, poolName, '1');
      images.getFirstTableCell(imageName).should('exist');
    });

    it('should move the image to the trash', () => {
      images.moveToTrash(imageName);
      images.getFirstTableCell(imageName).should('exist');
    });

    it('should restore image to images table', () => {
      images.restoreImage(imageName, newImageName);
      images.getFirstTableCell(newImageName).should('exist');
    });

    it('should purge trash in images trash tab', () => {
      images.getFirstTableCell(newImageName).should('exist');
      images.moveToTrash(newImageName);
      images.purgeTrash(newImageName, poolName);
    });
  });
});