Skip to content

Commit 57caa8e

Browse files
committed
Fix PHPStan snapshot and UI screenshots
1 parent 754051c commit 57caa8e

11 files changed

Lines changed: 35 additions & 34 deletions

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4658,11 +4658,6 @@ parameters:
46584658
count: 1
46594659
path: plugins/ScheduledReports/ScheduledReports.php
46604660

4661-
-
4662-
message: "#^Negated boolean expression is always true\\.$#"
4663-
count: 1
4664-
path: plugins/SegmentEditor/API.php
4665-
46664661
-
46674662
message: "#^Parameter \\#2 \\$idSites of class Piwik\\\\Segment constructor expects array, int\\|null given\\.$#"
46684663
count: 1

plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*/
99

1010
describe("SegmentSelectorEditorTest", function () {
11+
const getSegmentQuery = n => '.segmentList li:nth-of-type(' + (n+1) + ')';
12+
const getSegmentStarQuery = n => getSegmentQuery(n) + ' .starSegment';
1113
var selectorsToCapture = ".segmentEditorPanel,.segmentEditorPanel .dropdown-body,.segment-element";
1214
var generalParams = 'idSite=1&period=year&date=2012-08-09';
1315
var url = '?module=CoreHome&action=index&' + generalParams + '#?' + generalParams + '&category=General_Actions&subcategory=General_Pages';
@@ -64,30 +66,31 @@ describe("SegmentSelectorEditorTest", function () {
6466
});
6567

6668
it("should star all segments", async function() {
67-
await page.click('.segmentList li:nth-child(2) .starSegment');
68-
await page.click('.segmentList li:nth-child(3) .starSegment');
69-
await page.click('.segmentList li:nth-child(4) .starSegment');
70-
const firstSegment = await page.$('.segmentList li:nth-child(2)');
71-
expect(firstSegment.className).to.contain('segmentStarred');
72-
expect(firstSegment.find('.starSegment').attr('data-state')).to.equal('');
69+
await page.click(getSegmentStarQuery(1));
70+
await page.click(getSegmentStarQuery(2));
71+
await page.click(getSegmentStarQuery(3));
72+
const firstSegmentClassName = await page.evaluate(() => $('.segmentList li:nth-of-type(2)').attr('class'));
73+
expect(firstSegmentClassName).to.match(/segmentStarred/);
74+
const firstSegmentStarState = await page.evaluate(() => $('.segmentList li:nth-of-type(2) .starSegment').attr('data-state') || '');
75+
expect(firstSegmentStarState).to.equal('');
7376
expect(await page.screenshotSelector(selectorsToCapture)).to.matchImage('1_selector_starred');
7477
});
7578

7679
it("should unstar first segment", async function() {
77-
await page.click('.segmentList li:nth-child(2) .starSegment');
78-
const firstSegment = await page.$('.segmentList li:nth-child(2)');
79-
expect(firstSegment.className).to.not.contain('segmentStarred');
80-
expect(firstSegment.find('.starSegment').attr('data-state')).to.equal('');
80+
await page.click(getSegmentStarQuery(1));
81+
const firstSegmentClassName = await page.evaluate(() => $('.segmentList li:nth-of-type(2)').attr('class'));
82+
expect(firstSegmentClassName).to.not.match(/segmentStarred/);
83+
const firstSegmentStarState = await page.evaluate(() => $('.segmentList li:nth-of-type(2) .starSegment').attr('data-state') || '');
84+
expect(firstSegmentStarState).to.equal('');
8185
expect(await page.screenshotSelector(selectorsToCapture)).to.matchImage('1b_selector_unstarred');
8286
});
8387

8488
it("should have disabled star for anonymous users", async function() {
8589
await switchToAnonymousUser();
8690
await page.goto(url);
8791
await page.click('.segmentationContainer .title');
88-
const firstSegment = await page.$('.segmentList li:nth-child(2)');
89-
expect(firstSegment.className).to.contain('segmentStarred');
90-
expect(firstSegment.find('.starSegment').attr('data-state')).to.equal('');
92+
const firstSegmentStarState = await page.evaluate(() => $('.segmentList li:nth-of-type(2) .starSegment').attr('data-state') || '');
93+
expect(firstSegmentStarState).to.equal('disabled');
9194
});
9295

9396
it("should open segment editor when edit link clicked for existing segment", async function() {
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)