Skip to content

Commit 6e79450

Browse files
committed
ui/test: Fix the volumelist table test
1 parent 05c0245 commit 6e79450

1 file changed

Lines changed: 44 additions & 35 deletions

File tree

ui/cypress/integration/volume/volumelist.spec.js

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ beforeEach(() => {
55

66
// Navigation tests
77
describe('Volume list', () => {
8+
const UNHEALTHY_VOLUME_NAME = 'master-0-alertmanager';
89
it('brings me to the overview tab of the unhealthy volume', () => {
910
// Specify a fake now timestamp to make sure the alert is active.
1011
const now = new Date('2020-11-09T08:33:26.330Z').getTime();
@@ -19,36 +20,40 @@ describe('Volume list', () => {
1920
// According to the default sorting rule, it should appear at the first place.
2021
cy.location('pathname').should(
2122
'eq',
22-
'/volumes/master-0-alertmanager/overview',
23+
`/volumes/${UNHEALTHY_VOLUME_NAME}/overview`,
2324
);
2425
});
2526

26-
it('brings me to the overview tab of worker-0-burry-1 Volume', () => {
27-
// After implementing the virtualized table, not all the volumes are visible at the first render.
28-
// So we should test the first several volumes which are visiable.
29-
30-
cy.visit('/volumes');
31-
cy.stubHistory();
32-
// The application re-renders, it's possible the element we're interacting with has become "dead"
33-
// cy... failed because the element has been detached from the DOM
34-
35-
cy.findByText('worker-0-burry-1').click();
36-
37-
cy.get('@historyPush').should('be.calledWithExactly', {
38-
pathname: '/volumes/worker-0-burry-1/overview',
39-
search: '',
40-
});
41-
});
27+
it(
28+
'brings me to the overview tab of master-0-alertmanager Volume',
29+
{ scrollBehavior: false },
30+
() => {
31+
// After implementing the virtualized table, not all the volumes are visible at the first render.
32+
// So we should test the first several volumes which are visiable.
33+
cy.visit('/volumes');
34+
// The application re-renders, it's possible the element we're interacting with has become "dead"
35+
// cy... failed because the element has been detached from the DOM
36+
cy.findAllByLabelText('Check-circle status healthy');
37+
cy.findByRole('gridcell', {
38+
name: UNHEALTHY_VOLUME_NAME,
39+
}).click({ force: true });
40+
cy.get('[data-cy="volume_detail_card_name"]').should(
41+
'contain',
42+
UNHEALTHY_VOLUME_NAME,
43+
);
44+
cy.url().should('include', `/volumes/${UNHEALTHY_VOLUME_NAME}/overview`);
45+
},
46+
);
4247

4348
it('brings me to another volume with the same tab selected and queryString kept', () => {
4449
cy.visit('/volumes/master-1-prometheus/metrics?from=now-7d');
45-
cy.stubHistory();
4650

47-
cy.findByText('master-0-alertmanager').click();
48-
cy.get('@historyPush').should('be.calledOnce').and('be.calledWithExactly', {
49-
pathname: '/volumes/master-0-alertmanager/metrics',
50-
search: 'from=now-7d',
51-
});
51+
cy.findByText(UNHEALTHY_VOLUME_NAME).click({ force: true });
52+
cy.findByText(/advanced metrics/i);
53+
cy.url().should(
54+
'include',
55+
`/volumes/${UNHEALTHY_VOLUME_NAME}/metrics?from=now-7d`,
56+
);
5257
});
5358

5459
it('brings me to create volume page', () => {
@@ -59,22 +64,26 @@ describe('Volume list', () => {
5964
cy.get('@historyPush').and('be.calledWithExactly', '/volumes/createVolume');
6065
});
6166

62-
it('updates url with the search', () => {
63-
cy.visit('/volumes');
64-
cy.stubHistory();
65-
66-
cy.get('[data-cy="volume_list_search"]').type('hello');
67-
cy.get('@historyPush').and('be.calledWithExactly', '?search=hello');
67+
it('updates url query param with the search input', () => {
68+
cy.visit('/volumes/master-1-prometheus/overview');
69+
//E
70+
cy.findAllByLabelText('Check-circle status healthy');
71+
cy.findByText(/delete volume/i);
72+
cy.findByRole('textbox').type('hello');
73+
//V
74+
cy.url().should(
75+
'include',
76+
`/volumes/master-1-prometheus/overview?search=hello`,
77+
);
6878
});
6979

70-
it(`keeps warning severity for the alert while searching the node`, () => {
80+
it('keeps warning severity for the alert while searching the node', () => {
7181
cy.visit('/volumes/master-1-prometheus/alerts?severity=warning');
72-
cy.stubHistory();
7382

74-
cy.get('[data-cy="volume_list_search"]').type('hello');
75-
cy.get('@historyPush').should(
76-
'be.calledWithExactly',
77-
'?severity=warning&search=hello',
83+
cy.findByRole('textbox').type('hello');
84+
cy.url().should(
85+
'include',
86+
'/volumes/master-1-prometheus/alerts?severity=warning&search=hello',
7887
);
7988
});
8089
});

0 commit comments

Comments
 (0)