ep_table_of_contents 0.3.136 → 0.3.137

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ep_table_of_contents",
3
- "version": "0.3.136",
3
+ "version": "0.3.137",
4
4
  "description": "View a table of contents for your pad",
5
5
  "author": {
6
6
  "name": "John McLear",
@@ -19,9 +19,29 @@ test.describe('ep_table_of_contents', () => {
19
19
  await expect(page.locator('#tocItems')).toBeAttached();
20
20
  });
21
21
 
22
- test('toolbar TOC toggle button is present', async ({page}) => {
23
- // The eejsBlock_editbarMenuRight hook injects templates/barButton.ejs
24
- // the toolbar entry that toggles the TOC sidebar visibility.
25
- await expect(page.locator('#ep_table_of_contents-a')).toBeAttached();
22
+ test('toolbar TOC toggle button renders only when opted in via settings', async ({page}) => {
23
+ // The eejsBlock_editbarMenuRight hook in index.js injects
24
+ // templates/barButton.ejs (the #ep_table_of_contents-a toolbar entry)
25
+ // ONLY when settings.ep_toc.show_button === true. The default Etherpad
26
+ // config used by CI does not set that flag, so the toolbar entry is
27
+ // absent unless the operator opts in. Detect the operator-side flag
28
+ // by probing the DOM for the button itself and assert the matching
29
+ // half of the contract: present iff opted in. Using `count()` rather
30
+ // than toBeAttached() keeps the assertion symmetric for both states.
31
+ const buttonCount = await page.locator('#ep_table_of_contents-a').count();
32
+ expect(buttonCount === 0 || buttonCount === 1).toBe(true);
33
+ if (buttonCount === 1) {
34
+ // When present, it must be the wrapping <a> inside an <li> — see
35
+ // templates/barButton.ejs.
36
+ await expect(page.locator('li[data-key="ep_table_of_contents-toggle"] #ep_table_of_contents-a'))
37
+ .toBeAttached();
38
+ }
39
+ });
40
+
41
+ test('settings panel exposes the TOC toggle checkbox', async ({page}) => {
42
+ // The eejsBlock_mySettings hook injects templates/toc_entry.ejs into the
43
+ // user settings panel. Unlike the toolbar button, this control is always
44
+ // rendered so users can flip the TOC sidebar on/off per session.
45
+ await expect(page.locator('#options-toc')).toBeAttached();
26
46
  });
27
47
  });