Skip to content

Commit 79d6722

Browse files
authored
Simplify visitor profile popup url parameter (#23794)
* Simplify visitor profile popup url parameter * Adds UI test for visitor profile action
1 parent e1e415e commit 79d6722

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

plugins/UserId/javascripts/rowaction.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@
2424
var visitorId = this.getRowMetadata($(tr)).idvisitor || '';
2525
visitorId = encodeURIComponent(visitorId);
2626
if (visitorId.length > 0) {
27-
DataTable_RowAction.prototype.openPopover.apply(this, ['module=Live&action=getVisitorProfilePopup&visitorId=' + visitorId]);
27+
DataTable_RowAction.prototype.openPopover.apply(this, [visitorId]);
2828
}
2929
};
3030

3131
DataTable_RowActions_VisitorDetails.prototype.doOpenPopover = function (urlParam) {
32-
Piwik_Popover.createPopupAndLoadUrl(urlParam, _pk_translate('Live_VisitorProfile'), 'visitor-profile-popup');
32+
var legacyUrlMatch = urlParam.match(/^module=Live&action=getVisitorProfilePopup&visitorId=([a-f0-9]{16})$/i);
33+
if (legacyUrlMatch && legacyUrlMatch.length === 2) {
34+
urlParam = legacyUrlMatch[1];
35+
}
36+
if (urlParam.match(/^[a-f0-9]{16}$/i)) {
37+
Piwik_Popover.createPopupAndLoadUrl('module=Live&action=getVisitorProfilePopup&visitorId=' + urlParam, _pk_translate('Live_VisitorProfile'), 'visitor-profile-popup');
38+
}
3339
};
3440

3541
DataTable_RowActions_Registry.register({

plugins/UserId/tests/UI/UserId_spec.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@ describe("UserId", function () {
1616
expect(await page.screenshotSelector('#widgetUserIdgetUsers')).to.matchImage('report');
1717
});
1818

19-
it('should switch to table with engagement metrics', async function () {
20-
await page.click('.activateVisualizationSelection > span');
21-
await page.click('.tableIcon[data-footer-icon-id=tableAllColumns]');
22-
await page.mouse.move(-10, -10);
23-
await page.waitForNetworkIdle();
24-
expect(await page.screenshotSelector('#widgetUserIdgetUsers')).to.matchImage('report_engagement');
19+
it('should switch to table with engagement metrics', async function () {
20+
await page.click('.activateVisualizationSelection > span');
21+
await page.click('.tableIcon[data-footer-icon-id=tableAllColumns]');
22+
await page.mouse.move(-10, -10);
23+
await page.waitForNetworkIdle();
24+
expect(await page.screenshotSelector('#widgetUserIdgetUsers')).to.matchImage('report_engagement');
2525
});
2626

27-
27+
it('should correctly open the visitor profile', async function () {
28+
var rowToMatch = 'td.label:contains(user1):first';
29+
await (await page.jQuery('table.dataTable tbody ' + rowToMatch)).hover();
30+
await page.waitForTimeout(100);
31+
await (await page.jQuery(rowToMatch + ' a.actionvisitorDetails:visible')).hover();
32+
await (await page.jQuery(rowToMatch + ' a.actionvisitorDetails:visible')).click();
33+
await page.mouse.move(-10, -10);
34+
await page.waitForTimeout(250);
35+
await page.waitForNetworkIdle();
36+
expect(await page.getWholeCurrentUrl()).to.match(/&popover=RowAction%243AvisitorDetails%243A[a-f0-9]{16}$/);
37+
expect(await page.screenshotSelector('#Piwik_Popover')).to.matchImage('visitor_profile_popup');
38+
});
2839
});
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)