2023-09-08 10:51:59 -05:00
|
|
|
import { e2e } from '../utils';
|
2022-01-11 10:47:30 -06:00
|
|
|
const PAGE_UNDER_TEST = 'OY8Ghjt7k/repeating-a-panel-vertically';
|
|
|
|
|
|
|
|
describe('Repeating a panel vertically', () => {
|
2022-02-07 10:24:30 -06:00
|
|
|
beforeEach(() => {
|
2023-09-27 05:33:00 -05:00
|
|
|
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
|
2022-02-07 10:24:30 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should be able to repeat a panel vertically', () => {
|
2022-01-11 10:47:30 -06:00
|
|
|
e2e.flows.openDashboard({ uid: PAGE_UNDER_TEST });
|
|
|
|
|
|
|
|
let prevTop = Number.NEGATIVE_INFINITY;
|
2023-09-08 10:51:59 -05:00
|
|
|
let prevLeft: number | null = null;
|
2022-01-11 10:47:30 -06:00
|
|
|
const panelTitles = ['Panel Title 1', 'Panel Title 2', 'Panel Title 3'];
|
|
|
|
panelTitles.forEach((title) => {
|
|
|
|
e2e.components.Panels.Panel.title(title)
|
|
|
|
.should('be.visible')
|
|
|
|
.then(($el) => {
|
|
|
|
const { left, top } = $el[0].getBoundingClientRect();
|
|
|
|
expect(top).to.be.greaterThan(prevTop);
|
|
|
|
if (prevLeft !== null) {
|
|
|
|
expect(left).to.be.equal(prevLeft);
|
|
|
|
}
|
|
|
|
prevLeft = left;
|
|
|
|
prevTop = top;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-02-07 10:24:30 -06:00
|
|
|
it('responds to changes to the variables', () => {
|
|
|
|
e2e.flows.openDashboard({ uid: PAGE_UNDER_TEST });
|
|
|
|
|
|
|
|
let prevTop = Number.NEGATIVE_INFINITY;
|
2023-09-08 10:51:59 -05:00
|
|
|
let prevLeft: number | null = null;
|
2022-02-07 10:24:30 -06:00
|
|
|
const panelTitles = ['Panel Title 1', 'Panel Title 2', 'Panel Title 3'];
|
|
|
|
panelTitles.forEach((title) => {
|
|
|
|
e2e.components.Panels.Panel.title(title).should('be.visible');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Change to only show panels 1 + 3
|
|
|
|
e2e.pages.Dashboard.SubMenu.submenuItemLabels('vertical').click();
|
|
|
|
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('1').click();
|
|
|
|
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('3').click();
|
|
|
|
// blur the dropdown
|
2023-09-11 05:20:54 -05:00
|
|
|
cy.get('body').click();
|
2022-02-07 10:24:30 -06:00
|
|
|
|
|
|
|
const panelsShown = ['Panel Title 1', 'Panel Title 3'];
|
|
|
|
const panelsNotShown = ['Panel Title 2'];
|
|
|
|
panelsShown.forEach((title) => {
|
|
|
|
e2e.components.Panels.Panel.title(title)
|
|
|
|
.should('be.visible')
|
|
|
|
.then(($el) => {
|
|
|
|
const { left, top } = $el[0].getBoundingClientRect();
|
|
|
|
expect(top).to.be.greaterThan(prevTop);
|
|
|
|
if (prevLeft !== null) {
|
|
|
|
expect(left).to.be.equal(prevLeft);
|
|
|
|
}
|
|
|
|
prevLeft = left;
|
|
|
|
prevTop = top;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
panelsNotShown.forEach((title) => {
|
|
|
|
e2e.components.Panels.Panel.title(title).should('not.exist');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('loads a dashboard based on the query params correctly', () => {
|
|
|
|
// Have to manually add the queryParams to the url because they have the same name
|
|
|
|
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?var-vertical=1&var-vertical=3` });
|
|
|
|
|
|
|
|
let prevTop = Number.NEGATIVE_INFINITY;
|
2023-09-08 10:51:59 -05:00
|
|
|
let prevLeft: number | null = null;
|
2022-02-07 10:24:30 -06:00
|
|
|
const panelsShown = ['Panel Title 1', 'Panel Title 3'];
|
|
|
|
const panelsNotShown = ['Panel Title 2'];
|
|
|
|
panelsShown.forEach((title) => {
|
|
|
|
e2e.components.Panels.Panel.title(title)
|
|
|
|
.should('be.visible')
|
|
|
|
.then(($el) => {
|
|
|
|
const { left, top } = $el[0].getBoundingClientRect();
|
|
|
|
expect(top).to.be.greaterThan(prevTop);
|
|
|
|
if (prevLeft !== null) {
|
|
|
|
expect(left).to.be.equal(prevLeft);
|
|
|
|
}
|
|
|
|
prevLeft = left;
|
|
|
|
prevTop = top;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
panelsNotShown.forEach((title) => {
|
|
|
|
e2e.components.Panels.Panel.title(title).should('not.exist');
|
|
|
|
});
|
|
|
|
});
|
2022-01-11 10:47:30 -06:00
|
|
|
});
|