1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-21 22:47:43 +00:00
Files
matomo/plugins/SitesManager/tests/UI/SitesManager_spec.js
caddoo 38a1009af5 Add more options for global URL parameter exclusions (#22729)
* Update global settings to support excluding common PII params

* Clean up TS

* Add UI screenshots (with some commented)

* Remove empty test

* Fix broken UI test

* Fix broken UI test

* Fix broken integration test

* Build vue files

* Update UI to hide the list of common exclusions

* Build vue files

* Update UI screenshot

* Update UI screenshot

* Update API interface to keep data integrity

* Switch to using whitelist validator

* Update exceptions to be translated, add missing integration test

* Restore commented out UI tests

* Remove redundant switch statement

* Add return type

* Move common PII exclusions to config

* Translate button text

* Add common PII to config

* Deprecate setGlobalExcludedQueryParameters

* Fix CS issues

* Build vue files

* Fix deprecated test and update changelog

* Use test config data for test, remove static copy of common PII

* Add missing translation key

* Update UI screenshots

* Fix tests

* Update plugins/SitesManager/API.php

Co-authored-by: Marc Neudert <marc@innocraft.com>

* Update plugins/SitesManager/API.php

Co-authored-by: Marc Neudert <marc@innocraft.com>

* Update plugins/SitesManager/API.php

Co-authored-by: Marc Neudert <marc@innocraft.com>

* Update plugins/SitesManager/vue/src/ManageGlobalSettings/ManageGlobalSettings.vue

Co-authored-by: Marc Neudert <marc@innocraft.com>

* Reorder and remove duplicates for CommonPII params

* Clear query parameters when custom_exclusions selected

* Add missing prop type include

* Make old API method more compatible with new methods

* Fix syntax error

* Fix UI screenshot

* Build vue files

* Fix UI screenshot

* Update plugins/SitesManager/API.php

Co-authored-by: Marc Neudert <marc@innocraft.com>

* Make sure URL params are cleaned before validation, and add tests

* Remove redundant check

* Update naming for the exclusion types

* Build vue files

* Update wording once more

* Update ui screenshots

* Update ui screenshots

* Update ui screenshots

* Update ui screenshots

* Update expected integration test

* Update language again

* Update integration test expected result

* Temp split test to get all screenshots

* Fix broken tests

* Remove temp tests

* Split UI tests to "one screenshot per test" for ease of updating

* Remove duplicated translation

---------

Co-authored-by: innocraft-automation <innocraft-automation@users.noreply.github.com>
Co-authored-by: Marc Neudert <marc@innocraft.com>
2024-11-18 14:16:29 +13:00

144 خطوط
5.5 KiB
JavaScript

/*!
* Matomo - free/libre analytics platform
*
* SitesManager screenshot tests.
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("SitesManager", function () {
const parentSuite = this;
this.timeout(0);
this.fixture = "Piwik\\Plugins\\SitesManager\\tests\\Fixtures\\ManySites";
const url = "?module=SitesManager&action=index&idSite=1&period=day&date=yesterday&showaddsite=false";
async function assertScreenshotEquals(screenshotName, test, selectorToWaitFor = ".enrichedHeadline:contains(Manage Measurables)")
{
await test();
await page.waitForNetworkIdle();
const pageWrap = await page.$('#content');
await page.waitForFunction((s) => {
return !!$(s).length;
}, {}, selectorToWaitFor);
expect(await pageWrap.screenshot()).to.matchImage(screenshotName);
}
async function loadNextPage()
{
await (await page.jQuery('.SitesManager .paging:first .next')).click();
}
async function loadPreviousPage()
{
await (await page.jQuery('.SitesManager .paging:first .prev')).click();
}
async function searchForText(textToAppendToSearchField)
{
await (await page.jQuery('.SitesManager .search:first input')).type(textToAppendToSearchField);
await page.waitForTimeout(100);
await (await page.jQuery('.SitesManager .search:first .search_ico')).click();
}
it("should load correctly and show page 0", async function() {
await assertScreenshotEquals("loaded", async function () {
await page.goto(url);
});
});
it("should show page 1 when clicking next", async function() {
await assertScreenshotEquals("page_1", async function () {
await loadNextPage();
});
});
it("should show page 2 when clicking next", async function() {
await assertScreenshotEquals("page_2", async function () {
await loadNextPage();
});
});
it("should show page 1 when clicking prev", async function() {
await assertScreenshotEquals("page_1_again", async function () {
await loadPreviousPage();
});
});
it("should search for websites and reset page to 0", async function() {
await assertScreenshotEquals("search", async function () {
await searchForText('SiteTes');
});
});
it("should page within search result to page 1", async function() {
await assertScreenshotEquals("search_page_1", async function () {
await loadNextPage();
});
});
it("should search for websites no result", async function() {
await assertScreenshotEquals("search_no_result", async function () {
await searchForText('RanDoMSearChTerm');
});
});
it("should load the global settings page", async function() {
await assertScreenshotEquals("global_settings", async function () {
await page.goto('?module=SitesManager&action=globalSettings&idSite=1&period=day&date=yesterday&showaddsite=false');
await page.evaluate(function () {
$('.form-help:contains(UTC time is)').hide();
});
}, "h2:contains(Global websites settings)");
});
it("should be able to open and edit a site directly based on url parameter", async function() {
await assertScreenshotEquals("site_edit_url", async function () {
await page.goto(url + '#/editsiteid=23');
await page.evaluate(function () {
$('.form-help:contains(UTC time is)').hide();
});
});
});
describe('the UI should change depending on what exclusion type gets selected', async function () {
this.title = parentSuite.title; // to make sure the screenshot prefix is the same
async function assertExcludedParametersScreenshot(screenshotName) {
await expect(
await page.screenshotSelector('.siteManagerGlobalExcludedUrlParameters')
).to.matchImage(screenshotName);
}
it('excludes common session parameters by default', async function () {
await page.goto('?module=SitesManager&action=globalSettings');
await assertExcludedParametersScreenshot('global_url_param_exclusion_default')
});
it('excludes recommended parameters if chosen', async function () {
await page.click('#exclusionTypematomo_recommended_pii');
await assertExcludedParametersScreenshot('global_url_param_exclusion_common_exclusions');
});
it('excludes a custom list of parameters if chosen', async function () {
await page.click('#exclusionTypecustom');
await assertExcludedParametersScreenshot('global_url_param_exclusion_custom');
});
it('can add recommended parameters to custom list', async function () {
await page.click('.siteManagerGlobalExcludedUrlParameters input[type=button]');
await assertExcludedParametersScreenshot('global_url_param_exclusion_add_common');
});
it('resets custom list of parameters when changing type', async function () {
await page.click('#exclusionTypematomo_recommended_pii');
await page.click('#exclusionTypecustom');
// screenshot should be identical to first selection of "custom"
await assertExcludedParametersScreenshot('global_url_param_exclusion_custom');
});
});
});