@salesforcedevs/sfdocs-e2e 1.0.12-fix-redoc-topic-v-2 → 1.0.12-fix-redoc-topic-v-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/sfdocs-e2e",
3
- "version": "1.0.12-fix-redoc-topic-v-2",
3
+ "version": "1.0.12-fix-redoc-topic-v-3",
4
4
  "description": "E2E test suite for SFDocs static portal pages (SSG)",
5
5
  "license": "ISC",
6
6
  "bin": {
@@ -38,7 +38,11 @@ class ContentActionToolbar {
38
38
 
39
39
  const labelsByGroup: Record<string, string[]> = {};
40
40
  for (const group of groupContainers) {
41
- const heading = (await (await group.$(this.MENU_HEADING_SELECTOR)).getText()).trim();
41
+ // getText() applies the heading's text-transform: uppercase.
42
+ const heading = String(
43
+ (await (await group.$(this.MENU_HEADING_SELECTOR)).getProperty('textContent')) ??
44
+ '',
45
+ ).trim();
42
46
  const options = await group.$$(this.MENU_OPTION_SELECTOR);
43
47
  labelsByGroup[heading] = await Promise.all(
44
48
  options.map(async (option) =>
@@ -112,14 +112,23 @@ export default class Page {
112
112
  }
113
113
 
114
114
  /**
115
- * Toggles a parent tree item open without navigating — the expand icon's own click handler
116
- * calls preventDefault/stopPropagation, unlike the tile's main link. Needed to reach a child
117
- * row (e.g. a nested Redoc spec) that isn't rendered in the DOM until its parent is expanded.
115
+ * Opens a parent row without navigating. The icon toggles, so skip the click when
116
+ * the row is already open. WebDriver's click throws on the SVG inside dx-icon, so
117
+ * click through the DOM instead.
118
118
  */
119
119
  async expandTreeItem(treeItem: WebdriverIO.Element): Promise<void> {
120
120
  const tile = await this.getTreeItemTile(treeItem);
121
121
  const icon = await tile.shadow$('.tile-expand-icon dx-icon');
122
- await icon.click();
122
+ if ((await icon.getAttribute('aria-expanded')) !== 'true') {
123
+ await browser.execute((expandIcon: { click: () => void }) => {
124
+ expandIcon.click();
125
+ }, icon);
126
+ }
127
+
128
+ await browser.waitUntil(async () => (await treeItem.shadow$$('dx-tree-item')).length > 0, {
129
+ timeout: 5000,
130
+ timeoutMsg: 'Expected the tree item to expand and render its children',
131
+ });
123
132
  }
124
133
 
125
134
  async findTreeItemByLabel(
@@ -63,21 +63,18 @@ export default class TopicVersionPage extends Page {
63
63
  return wrapper.$('doc-version-picker');
64
64
  }
65
65
 
66
- /** Clicks a sidebar tree item and waits for the Redoc page it opens to load. */
67
66
  async openRedocFromSidebar(label: string): Promise<void> {
68
67
  const item = await this.getSidebarTreeItem(label);
69
68
  await item.click();
70
69
  await this.waitForRedocTopicLoad();
71
70
  }
72
71
 
73
- /** Selects a version on the Redoc page's own picker and waits for the new spec to load. */
74
72
  async selectRedocVersionByLabel(label: string): Promise<void> {
75
73
  const picker = await this.getRedocPicker();
76
74
  await this.selectVersionByLabel(picker!, label);
77
75
  await this.waitForRedocTopicLoad();
78
76
  }
79
77
 
80
- /** Clicks the Redoc back link and waits for the markdown page it returns to load. */
81
78
  async goBackFromRedoc(): Promise<void> {
82
79
  await (await this.getRedocBackLink()).click();
83
80
  await this.waitForMarkdownTopicLoad();
@@ -149,12 +146,17 @@ export default class TopicVersionPage extends Page {
149
146
  }
150
147
 
151
148
  async getOptionLabel(option: WebdriverIO.Element): Promise<string> {
152
- const label = await option.shadow$('div>div');
149
+ const label = await option.shadow$('.option_label');
153
150
  return (await label.getText()).trim();
154
151
  }
155
152
 
156
153
  async selectVersionByLabel(picker: WebdriverIO.Element, label: string): Promise<void> {
157
154
  await this.openPicker(picker);
155
+ // The menu fades in. isDisplayed is false while its opacity is still 0.
156
+ await browser.waitUntil(async () => (await this.getVersionOptions()).length > 0, {
157
+ timeout: 5000,
158
+ timeoutMsg: 'Expected the version menu to show its options',
159
+ });
158
160
  const options = await this.getVersionOptions();
159
161
  for (const option of options) {
160
162
  if ((await this.getOptionLabel(option)) === label) {
@@ -235,8 +235,8 @@ describe('Topic-level versioning > versioned parent with own content, subtopics
235
235
  page.open();
236
236
  await page.waitForMarkdownTopicLoad();
237
237
 
238
- // "Another Spec API" isn't rendered in the DOM until its parent is expanded — expanding
239
- // doesn't navigate, so Get Started stays the referrer once we click into the spec below.
238
+ // The spec row is absent until its parent is expanded. Expanding does not
239
+ // navigate, so Get Started stays the referrer.
240
240
  const parent = await page.getSidebarTreeItem('Errors and Rate Limits');
241
241
  await page.expandTreeItem(parent);
242
242
 
@@ -249,9 +249,8 @@ describe('Topic-level versioning > versioned parent with own content, subtopics
249
249
  });
250
250
 
251
251
  it('should fall back to the project landing page when the Redoc page is opened with no referrer', async () => {
252
- // Simulates a fresh direct visit: no stored back target, and `page.open()` (a WebDriver
253
- // navigation, not a link click) never sets document.referrer either. Routes through
254
- // globalThis since the tsconfig's lib list omits "DOM" (see readSessionVersionSelections).
252
+ // No stored back target. WebDriver navigation also leaves document.referrer empty.
253
+ // globalThis: this package's tsconfig lib list omits DOM.
255
254
  await browser.execute(() =>
256
255
  (globalThis as any).sessionStorage.removeItem('redoc-back-target'),
257
256
  );
@@ -263,8 +262,7 @@ describe('Topic-level versioning > versioned parent with own content, subtopics
263
262
  await page.selectRedocVersionByLabel(ERRORS_V1_LABEL);
264
263
  await page.goBackFromRedoc();
265
264
 
266
- // Get Started is the first topic in the TOC, so it's the project's landing page
267
- // (headerHref) — and it's unversioned, so no version segment should leak onto it either.
265
+ // With no back target, Back goes to the first TOC topic. That topic is unversioned.
268
266
  await page.waitForUrlToContain(`${BASE}/get-started.html`);
269
267
  expect(await browser.getUrl()).not.toContain('/v1/');
270
268
  });