Skip to content

Commit 9af8ed1

Browse files
authored
fix: exclude & from link generator in UseCases property test (#189)
The fast-check link generator could produce strings like '#&#0' which the browser's HTML parser interprets as HTML entities when injected via innerHTML. This causes getAttribute('href') to return the decoded value (with replacement char) instead of the raw input, failing the assertion. Add & to the exclusion regex to match the description generator which already excludes it. Signed-off-by: Kyle Hounslow <kylhouns@amazon.com>
1 parent b0deda9 commit 9af8ed1

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

docs/src/components/UseCases.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('UseCases - Property 2: Use case cards contain all required elements',
104104
description: fc.string({ minLength: 20, maxLength: 200 })
105105
.filter(s => s.trim().length >= 20 && !/[<>&"#]/.test(s)),
106106
link: fc.string({ minLength: 5, maxLength: 50 })
107-
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["']/.test(s)),
107+
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["'&]/.test(s)),
108108
}),
109109
(useCase) => {
110110
// Render use case card
@@ -156,7 +156,7 @@ describe('UseCases - Property 2: Use case cards contain all required elements',
156156
description: fc.string({ minLength: 20, maxLength: 200 })
157157
.filter(s => s.trim().length >= 20 && !/[<>&"#]/.test(s)),
158158
link: fc.string({ minLength: 5, maxLength: 50 })
159-
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["']/.test(s)),
159+
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["'&]/.test(s)),
160160
}),
161161
(useCase) => {
162162
container.innerHTML = renderUseCaseCard(useCase);
@@ -230,7 +230,7 @@ describe('UseCases - Property 2: Use case cards contain all required elements',
230230
description: fc.string({ minLength: 20, maxLength: 200 })
231231
.filter(s => s.trim().length >= 20 && !/[<>&"#]/.test(s)),
232232
link: fc.string({ minLength: 5, maxLength: 50 })
233-
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["']/.test(s)),
233+
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["'&]/.test(s)),
234234
}),
235235
(useCase) => {
236236
container.innerHTML = renderUseCaseCard(useCase);
@@ -265,7 +265,7 @@ describe('UseCases - Property 2: Use case cards contain all required elements',
265265
description: fc.string({ minLength: 20, maxLength: 200 })
266266
.filter(s => s.trim().length >= 20 && !/[<>&"#]/.test(s)),
267267
link: fc.string({ minLength: 5, maxLength: 50 })
268-
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["']/.test(s)),
268+
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["'&]/.test(s)),
269269
}),
270270
(useCase) => {
271271
container.innerHTML = renderUseCaseCard(useCase);
@@ -307,7 +307,7 @@ describe('UseCases - Property 2: Use case cards contain all required elements',
307307
description: fc.string({ minLength: 20, maxLength: 200 })
308308
.filter(s => s.trim().length >= 20 && !/[<>&"#]/.test(s)),
309309
link: fc.string({ minLength: 5, maxLength: 50 })
310-
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["']/.test(s)),
310+
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["'&]/.test(s)),
311311
}),
312312
(useCase) => {
313313
container.innerHTML = renderUseCaseCard(useCase);
@@ -352,7 +352,7 @@ describe('UseCases - Property 2: Use case cards contain all required elements',
352352
description: fc.string({ minLength: 20, maxLength: 200 })
353353
.filter(s => s.trim().length >= 20 && !/[<>&"#]/.test(s)),
354354
link: fc.string({ minLength: 5, maxLength: 50 })
355-
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["']/.test(s)),
355+
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["'&]/.test(s)),
356356
}),
357357
{ minLength: 3, maxLength: 10 }
358358
),
@@ -401,7 +401,7 @@ describe('UseCases - Property 2: Use case cards contain all required elements',
401401
description: fc.string({ minLength: 20, maxLength: 200 })
402402
.filter(s => s.trim().length >= 20 && !/[<>&"#]/.test(s)),
403403
link: fc.string({ minLength: 5, maxLength: 50 })
404-
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["']/.test(s)),
404+
.filter(s => (s.startsWith('#') || s.startsWith('http')) && s.trim() === s && !/["'&]/.test(s)),
405405
}),
406406
(useCase) => {
407407
container.innerHTML = renderUseCaseCard(useCase);

0 commit comments

Comments
 (0)