Skip to content

Commit ced0bbb

Browse files
committed
Added tests & doc on contextual consent configuration
1 parent 70f867e commit ced0bbb

4 files changed

Lines changed: 31 additions & 2 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,21 @@ offering a way to consent in place.
424424
</template>
425425
```
426426

427+
#### Customization
428+
429+
The heading level of the notice's title can be configured via an attribute on
430+
the `template`:
431+
432+
```diff
433+
<template
434+
data-purpose="youtube"
435+
data-contextual
436+
+ data-title-level="6"
437+
>
438+
...
439+
</template>
440+
```
441+
427442
<details>
428443
<summary>Integration tips</summary>
429444

e2e/OrejimePage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export class OrejimePage {
6868
return this.page.getByTestId('orejime-contextual-notice');
6969
}
7070

71+
get contextualNoticeTitle() {
72+
return this.page.getByTestId('orejime-contextual-notice-title');
73+
}
74+
7175
get contextualNoticePlaceholder() {
7276
return this.page.getByTestId('orejime-contextual-notice-placeholder');
7377
}

e2e/orejime.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test.describe('Orejime', () => {
3535
]
3636
},
3737
`
38-
<template data-purpose="contextual" data-contextual>
38+
<template data-purpose="contextual" data-contextual data-title-level="2">
3939
<iframe id="contextual" src=""></iframe>
4040
</template>
4141
@@ -205,6 +205,13 @@ test.describe('Orejime', () => {
205205
await expect(orejimePage.contextualNotice).toBeAttached();
206206
});
207207

208+
test('should use a custom heading level in the contextual consent notice', async () => {
209+
await expect(orejimePage.contextualNoticeTitle).toHaveJSProperty(
210+
'nodeName',
211+
'H2'
212+
);
213+
});
214+
208215
test('should accept contextual consent from the notice', async () => {
209216
await orejimePage.acceptContextualNotice();
210217
await expect(orejimePage.locator('#contextual')).toBeVisible();

src/ui/themes/standard/ContextualNotice.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ const ContextualNotice: ContextualNoticeComponent = ({
2929
className="orejime-ContextualNotice"
3030
data-testid="orejime-contextual-notice"
3131
>
32-
<TitleTag className="orejime-ContextualNotice-title">
32+
<TitleTag
33+
className="orejime-ContextualNotice-title"
34+
data-testid="orejime-contextual-notice-title"
35+
>
3336
{template(t.contextual.title, templateProps)}
3437
</TitleTag>
3538

0 commit comments

Comments
 (0)