Skip to content

Commit

Permalink
Improve loading time for UI tests loading the (default) dashboard (#2…
Browse files Browse the repository at this point in the history
…1477)

* Change default UI test fixture, so default dashboard does include only one widget

* use new dashboard ids in tests

* avoid screenshotting unneeded parts in DashboardManager UI tests

* updates expected UI test files

* Move dashboard relaated UI tests to dashboard plugin

* apply review feedback

Co-authored-by: Marc Neudert <[email protected]>

* updates expected UI test files

---------

Co-authored-by: Marc Neudert <[email protected]>
  • Loading branch information
sgiehl and mneudert authored Nov 14, 2023
1 parent 3ca4a18 commit 8786b33
Show file tree
Hide file tree
Showing 61 changed files with 530 additions and 495 deletions.
4 changes: 2 additions & 2 deletions plugins/CoreHome/tests/UI/SingleMetricView_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe('SingleMetricView', function () {
this.timeout(0);

var url = "?module=Widgetize&action=iframe&idSite=1&period=year&date=2012-08-09&moduleToWidgetize=Dashboard&"
+ "actionToWidgetize=index&idDashboard=5";
+ "actionToWidgetize=index&idDashboard=1";
var rangeUrl = "?module=Widgetize&action=iframe&idSite=1&period=range&date=2012-08-07,2012-08-10&moduleToWidgetize=Dashboard&"
+ "actionToWidgetize=index&idDashboard=5";
+ "actionToWidgetize=index&idDashboard=1";

it('should load correctly', async function () {
await page.goto(url);
Expand Down
22 changes: 19 additions & 3 deletions plugins/Dashboard/tests/UI/DashboardManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ describe("DashboardManager", function () {
const selectorToCapture = '.dashboard-manager,.dashboard-manager .dropdown';

const generalParams = 'idSite=1&period=day&date=2012-01-01';
const url = '?module=CoreHome&action=index&' + generalParams + '#?' + generalParams + '&category=Dashboard_Dashboard&subcategory=5';
const url = '?module=CoreHome&action=index&' + generalParams + '#?' + generalParams + '&category=Dashboard_Dashboard&subcategory=1';

it("should load correctly", async function() {
await page.goto(url);
await page.waitForNetworkIdle();

expect(await page.screenshotSelector(selectorToCapture)).to.matchImage('loaded');
});
Expand Down Expand Up @@ -62,6 +63,11 @@ describe("DashboardManager", function () {
});

it("should create new dashboard with new default widget selection when create dashboard process completed", async function() {
// check that widget count on currently loaded dashboard is correct, so we are able to say if
// number of widgets has changed after creating and loading the new one
const widgetsCountBefore = await page.evaluate(() => $('#dashboardWidgetsArea .widget').length);
expect(widgetsCountBefore).to.equal(1);

await page.click('.dashboard-manager .title');
await page.click('li[data-action="createDashboard"]');
await page.waitForSelector('#createDashboardName', { visible: true });
Expand Down Expand Up @@ -97,7 +103,12 @@ describe("DashboardManager", function () {
await page.waitForNetworkIdle();
await page.waitForTimeout(100); // wait for widgets to render fully

expect(await page.screenshot({ fullPage: true })).to.matchImage('create_new');
// check new dashboard was loaded, which should have 10 widgets
const widgetsCount = await page.evaluate(() => $('#dashboardWidgetsArea .widget').length);
expect(widgetsCount).to.equal(10);

// check dashboard has been added to menu, causing menu to switch from listing to selector
expect(await page.screenshotSelector('#secondNavBar .menuTab.active')).to.matchImage('create_new');
});


Expand All @@ -120,6 +131,11 @@ describe("DashboardManager", function () {
await page.waitForSelector('.widget');
await page.waitForNetworkIdle();

expect(await page.screenshot({ fullPage: true })).to.matchImage('removed');
// check initial dashboard was loaded again, which should have 1 widget only
const widgetsCount = await page.evaluate(() => $('#dashboardWidgetsArea .widget').length);
expect(widgetsCount).to.equal(1);

// check dashboard has been removed from menu, causing menu to switch from selector to listing
expect(await page.screenshotSelector('#secondNavBar .menuTab.active')).to.matchImage('removed');
});
});
Loading

0 comments on commit 8786b33

Please sign in to comment.