@networkpro/web 1.14.1 → 1.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build-and-publish.yml +23 -5
- package/.github/workflows/check-codeql.yml +2 -0
- package/.github/workflows/{check-security-txt-expirty.yml → check-security-txt-expiry.yml} +1 -1
- package/.github/workflows/lighthouse.yml +2 -3
- package/.github/workflows/playwright.yml +2 -3
- package/.github/workflows/publish-test.yml +8 -5
- package/.github/workflows/templates/publish.template.yml +228 -0
- package/.node-version +1 -1
- package/.nvmrc +1 -1
- package/CHANGELOG.md +70 -1
- package/cspell.json +2 -0
- package/netlify/edge-functions/csp-report.js +22 -15
- package/package.json +19 -19
- package/src/app.html +1 -1
- package/src/lib/pages/HomeContent.svelte +3 -9
- package/src/lib/pages/PrivacyContent.svelte +45 -31
- package/src/lib/pages/TermsConditionsContent.svelte +2 -2
- package/src/lib/stores/trackingPreferences.js +6 -0
- package/src/lib/styles/css/default.css +9 -4
- package/src/lib/styles/global.min.css +1 -1
- package/src/lib/utils/getUTMParams.js +43 -0
- package/src/lib/utils/purify.js +1 -1
- package/src/lib/utils/utm.js +30 -8
- package/src/routes/contact/+page.svelte +19 -3
- package/src/routes/links/+page.svelte +26 -5
- package/src/routes/posts/+page.svelte +26 -5
- package/src/routes/privacy-rights/+page.svelte +21 -3
- package/tests/unit/utm.test.js +35 -25
package/tests/unit/utm.test.js
CHANGED
|
@@ -6,44 +6,54 @@ SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
|
|
|
6
6
|
This file is part of Network Pro.
|
|
7
7
|
========================================================================== */
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// Mock SvelteKit environment and store
|
|
10
|
+
vi.mock('$app/environment', () => ({ browser: true }));
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
const originalWindow = globalThis.window;
|
|
12
|
+
import { writable } from 'svelte/store';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
vi.mock('$app/stores', () => {
|
|
15
|
+
const mockPageStore = writable({
|
|
16
|
+
url: {
|
|
17
|
+
pathname: '/contact',
|
|
18
|
+
},
|
|
17
19
|
});
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
return {
|
|
22
|
+
getStores: () => ({
|
|
23
|
+
page: mockPageStore,
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
import { appendUTM } from '$lib/utils/utm.js';
|
|
29
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
expect(result).toBe(null);
|
|
26
|
-
});
|
|
31
|
+
describe('appendUTM', () => {
|
|
32
|
+
const originalWindow = globalThis.window;
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
beforeEach(() => {
|
|
29
35
|
globalThis.window = {
|
|
30
|
-
|
|
31
|
-
location: { search: '?utm_source=linkedin' },
|
|
36
|
+
location: { search: '' },
|
|
32
37
|
};
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
globalThis.window = originalWindow;
|
|
42
|
+
});
|
|
33
43
|
|
|
44
|
+
it('should return URL with utm parameters for /contact', () => {
|
|
34
45
|
const url = 'https://example.com';
|
|
35
46
|
const result = appendUTM(url);
|
|
36
|
-
expect(result).toBe(
|
|
47
|
+
expect(result).toBe(
|
|
48
|
+
'https://example.com?utm_source=netwk.pro&utm_medium=redirect&utm_campaign=contact',
|
|
49
|
+
);
|
|
37
50
|
});
|
|
38
51
|
|
|
39
|
-
it('should
|
|
40
|
-
|
|
41
|
-
// @ts-expect-error – mock minimal window for test
|
|
42
|
-
location: { search: '' },
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const url = 'https://example.com';
|
|
52
|
+
it('should append using & if URL already has query params', () => {
|
|
53
|
+
const url = 'https://example.com?existing=value';
|
|
46
54
|
const result = appendUTM(url);
|
|
47
|
-
expect(result).toBe(
|
|
55
|
+
expect(result).toBe(
|
|
56
|
+
'https://example.com?existing=value&utm_source=netwk.pro&utm_medium=redirect&utm_campaign=contact',
|
|
57
|
+
);
|
|
48
58
|
});
|
|
49
59
|
});
|