Skip to content

Commit fdcf6bc

Browse files
committed
Fix E2E stress test errors - lint fixes to package-release and privacy-policy-version
1 parent 4d464c9 commit fdcf6bc

3 files changed

Lines changed: 66 additions & 61 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {
2+
getPackageRelease,
3+
getPrivacyPolicyVersion,
4+
} from '@components/scripts/utils/environmentClient'
5+
6+
interface EnvClientValues {
7+
packageRelease: string
8+
privacyPolicyVersion: string
9+
}
10+
type EnvValueKey = 'package-release' | 'privacy-policy-version'
11+
type EnvElementState = 'ready' | 'error'
12+
13+
const setValue = (
14+
key: EnvValueKey,
15+
value: string,
16+
state: EnvElementState = 'ready'
17+
) => {
18+
const element: HTMLOutputElement | null = (
19+
document.querySelector(`[data-env-value="${key}"]`)
20+
)
21+
if (!element) return
22+
element.textContent = value
23+
element.dataset['state'] = state
24+
}
25+
26+
const values: EnvClientValues = {
27+
packageRelease: '',
28+
privacyPolicyVersion: '',
29+
}
30+
31+
try {
32+
values.packageRelease = getPackageRelease()
33+
setValue('package-release', values.packageRelease)
34+
} catch (error) {
35+
values.packageRelease = String(error)
36+
setValue('package-release', values.packageRelease, 'error')
37+
}
38+
39+
try {
40+
values.privacyPolicyVersion = getPrivacyPolicyVersion()
41+
setValue('privacy-policy-version', values.privacyPolicyVersion)
42+
} catch (error) {
43+
values.privacyPolicyVersion = String(error)
44+
setValue('privacy-policy-version', values.privacyPolicyVersion, 'error')
45+
}
46+
47+
window.environmentClientValues = values
Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
/**
3-
* @file Environment client fixture for E2E tests.
4-
* @description This page intentionally skips BaseLayout to keep hydration minimal for diagnostics.
5-
* @note Exception: page fixtures normally wrap content in BaseLayout, but this file avoids it on purpose.
3+
* @file Environment client fixture for E2E tests. This page intentionally
4+
* skips BaseLayout to keep hydration minimal for diagnostics.
65
*/
76
const pageTitle = 'Environment Client Values'
87
---
@@ -14,36 +13,42 @@ const pageTitle = 'Environment Client Values'
1413
<meta name="robots" content="noindex, nofollow" />
1514
<style>
1615
html {
17-
font-family: system-ui, sans-serif;
1816
background: #0b1118;
1917
color: #f4f7fb;
18+
font-family: system-ui, sans-serif;
2019
}
20+
2121
body {
2222
margin: 0;
2323
padding: 2rem;
2424
}
25+
2526
main {
26-
max-width: 42rem;
2727
margin: 0 auto;
28+
max-width: 42rem;
2829
}
30+
2931
.env-grid {
3032
display: grid;
3133
gap: 1rem;
3234
}
35+
3336
.env-card {
34-
border: 1px solid rgba(244, 247, 251, 0.2);
37+
background: rgb(255 255 255 / 4%);
38+
border: 1px solid rgb(244 247 251 / 20%);
3539
border-radius: 0.5rem;
3640
padding: 1rem;
37-
background: rgba(255, 255, 255, 0.04);
3841
}
42+
3943
.env-label {
40-
text-transform: uppercase;
44+
display: block;
4145
font-size: 0.75rem;
4246
letter-spacing: 0.08em;
43-
opacity: 0.7;
4447
margin-bottom: 0.35rem;
45-
display: block;
48+
opacity: 0.7;
49+
text-transform: uppercase;
4650
}
51+
4752
.env-value {
4853
font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
4954
font-size: 1rem;
@@ -69,55 +74,8 @@ const pageTitle = 'Environment Client Values'
6974
</article>
7075
</section>
7176
</main>
72-
<script type="module" is:inline>
73-
import {
74-
getPackageRelease,
75-
getPrivacyPolicyVersion,
76-
} from '@components/scripts/utils/environmentClient'
77-
78-
/**
79-
* @typedef {'package-release' | 'privacy-policy-version'} EnvValueKey
80-
* @typedef {'ready' | 'error'} EnvElementState
81-
* @typedef {{ packageRelease: string; privacyPolicyVersion: string }} EnvClientValues
82-
*/
83-
84-
/**
85-
* @param {EnvValueKey} key
86-
* @param {string} value
87-
* @param {EnvElementState} [state='ready']
88-
*/
89-
const setValue = (key, value, state = 'ready') => {
90-
const element = /** @type {HTMLOutputElement | null} */ (
91-
document.querySelector(`[data-env-value="${key}"]`)
92-
)
93-
if (!element) return
94-
element.textContent = value
95-
element.dataset['state'] = state
96-
}
97-
98-
/** @type {EnvClientValues} */
99-
const values = {
100-
packageRelease: '',
101-
privacyPolicyVersion: '',
102-
}
103-
104-
try {
105-
values.packageRelease = getPackageRelease()
106-
setValue('package-release', values.packageRelease)
107-
} catch (error) {
108-
values.packageRelease = String(error)
109-
setValue('package-release', values.packageRelease, 'error')
110-
}
111-
112-
try {
113-
values.privacyPolicyVersion = getPrivacyPolicyVersion()
114-
setValue('privacy-policy-version', values.privacyPolicyVersion)
115-
} catch (error) {
116-
values.privacyPolicyVersion = String(error)
117-
setValue('privacy-policy-version', values.privacyPolicyVersion, 'error')
118-
}
119-
120-
window.environmentClientValues = values
77+
<script>
78+
import '@pages/testing/_environment-client-values'
12179
</script>
12280
</body>
12381
</html>

test/e2e/helpers/cookieHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const captureSnapshot = async (page: Page): Promise<SetupSnapshot | null> => {
5151
readyState: document.readyState,
5252
theme: localStorage.getItem('theme'),
5353
transitionPersistCount: document.querySelectorAll('[transition\\:persist]').length,
54-
historyLength: history.length,
54+
historyLength: window.history.length,
5555
navigationType: typeof lastEntry?.type === 'string' ? lastEntry.type : null,
5656
isPlaywrightControlled: isPlaywrightRun,
5757
}
@@ -75,7 +75,7 @@ const logSetupPhase = async (
7575
}
7676
if (!snapshot.isPlaywrightControlled) return
7777

78-
const { isPlaywrightControlled, ...rest } = snapshot
78+
const { isPlaywrightControlled: _isPlaywrightControlled, ...rest } = snapshot
7979
console.info(`[${label}] setupCleanTestPage:${phase}`, {
8080
...rest,
8181
...extra,

0 commit comments

Comments
 (0)