@salesforcedevs/sfdocs-e2e 1.0.12 → 1.0.13-fix-tvl-latest-url-1

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",
3
+ "version": "1.0.13-fix-tvl-latest-url-1",
4
4
  "description": "E2E test suite for SFDocs static portal pages (SSG)",
5
5
  "license": "ISC",
6
6
  "bin": {
@@ -149,17 +149,9 @@ describe('Component Specification', () => {
149
149
  'div.container div.sidebar-content dx-tree',
150
150
  );
151
151
 
152
- const getItemText = async (item: WebdriverIO.Element) => {
153
- const link = await item.shadow$('a');
154
- const tiles = await link.$$('dx-tree-tile');
155
- const tileLink = await tiles[0].shadow$('a.tile.sidebar-item');
156
- const label = await tileLink.$('span.tile-label');
157
- return (await label.getText()).trim();
158
- };
159
-
160
152
  const firstItem = (await sidebarTrees[0].shadow$$('dx-tree-item'))[0];
161
153
  const firstChildItem = (await firstItem.shadow$$('dx-tree-item'))[0];
162
- const firstChildText = await getItemText(firstChildItem);
154
+ const firstChildText = await page.getTreeItemLabel(firstChildItem);
163
155
 
164
156
  expect(firstChildText).toBe('Accordion');
165
157
  });
@@ -264,18 +256,10 @@ describe('Component Specification', () => {
264
256
  'div.container div.sidebar-content dx-tree',
265
257
  );
266
258
 
267
- const getItemText = async (item: WebdriverIO.Element) => {
268
- const link = await item.shadow$('a');
269
- const tiles = await link.$$('dx-tree-tile');
270
- const tileLink = await tiles[0].shadow$('a.tile.sidebar-item');
271
- const label = await tileLink.$('span.tile-label');
272
- return (await label.getText()).trim();
273
- };
274
-
275
259
  const auraItem = (await sidebarTrees[1].shadow$$('dx-tree-item'))[0];
276
260
  const lightningItem = (await auraItem.shadow$$('dx-tree-item'))[0];
277
261
  const componentsItem = (await lightningItem.shadow$$('dx-tree-item'))[0];
278
- const firstComponentText = await getItemText(
262
+ const firstComponentText = await page.getTreeItemLabel(
279
263
  (
280
264
  await componentsItem.shadow$$('dx-tree-item')
281
265
  )[0],
@@ -56,7 +56,9 @@ describe('Test Sitemap Routes', () => {
56
56
  );
57
57
 
58
58
  // Spec (Redoc) topics are published without an extension.
59
- expect(data.body).toContain('<loc>/docs/docs-content-type-example/sample-api</loc>');
59
+ expect(data.body).toContain(
60
+ '<loc>/docs/docs-content-type-example/widgets-api-reference</loc>',
61
+ );
60
62
  expect(data.body).toContain('<loc>/docs/docs-content-type-example/new-sample-api</loc>');
61
63
 
62
64
  // Each markdown URL appears exactly once.
@@ -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) =>
@@ -15,71 +15,23 @@ class DocsPage extends Page {
15
15
  });
16
16
  }
17
17
 
18
- async getContentHeading(): Promise<WebdriverIO.Element> {
19
- return (await $('doc-unified-content-layout')).$('div.markdown-content h1');
20
- }
21
-
22
- private async getSidebar(): Promise<WebdriverIO.Element> {
23
- return (await $('>>>doc-content-layout')).shadow$('div > dx-sidebar-old');
24
- }
25
-
26
- async waitForSidebar(): Promise<void> {
27
- await (await this.getSidebar()).waitForDisplayed();
28
- }
29
-
30
- async getSidebarTrees(): Promise<WebdriverIO.ElementArray> {
31
- const sidebar = await this.getSidebar();
32
- return sidebar.shadow$$('div.container div.sidebar-content dx-tree');
33
- }
34
-
35
- private async getTreeTile(treeItem: WebdriverIO.Element): Promise<WebdriverIO.Element> {
36
- return treeItem.shadow$('a > dx-tree-tile');
37
- }
38
-
39
- private async getTreeItemLabel(treeItem: WebdriverIO.Element): Promise<string> {
40
- const treeTile = await this.getTreeTile(treeItem);
41
- const label = await treeTile.shadow$('span.tile-label');
42
- return (await label.getText()).trim();
43
- }
44
-
45
- private async findTreeItemByLabel(
46
- treeItem: WebdriverIO.Element,
47
- label: string,
48
- ): Promise<WebdriverIO.Element | null> {
49
- if ((await this.getTreeItemLabel(treeItem)) === label) {
50
- return treeItem;
51
- }
52
-
53
- const children = await treeItem.shadow$$('dx-tree-item');
54
- for (const child of children) {
55
- const match = await this.findTreeItemByLabel(child, label);
56
- if (match) {
57
- return match;
58
- }
59
- }
60
- return null;
61
- }
62
-
63
18
  async getSidebarTile(label: string): Promise<WebdriverIO.Element> {
64
- const trees = await this.getSidebarTrees();
65
- for (const tree of trees) {
66
- const rootItem = await tree.shadow$('dx-tree-item');
67
- const match = await this.findTreeItemByLabel(rootItem, label);
68
- if (match) {
69
- return match;
70
- }
71
- }
72
- throw new Error(`No sidebar tile found with label "${label}"`);
19
+ return this.getSidebarTreeItemByLabel(label);
73
20
  }
74
21
 
75
22
  async getTileForwardArrow(label: string): Promise<WebdriverIO.Element> {
76
23
  const treeItem = await this.getSidebarTile(label);
77
- return (await this.getTreeTile(treeItem)).shadow$('.tile-forward-arrow');
24
+ return (await this.getTreeItemTile(treeItem)).shadow$('.tile-forward-arrow');
78
25
  }
79
26
 
80
27
  async getTileExternalLinkIcon(label: string): Promise<WebdriverIO.Element> {
81
28
  const treeItem = await this.getSidebarTile(label);
82
- return (await this.getTreeTile(treeItem)).shadow$('.tile-external-link-icon');
29
+ return (await this.getTreeItemTile(treeItem)).shadow$('.tile-external-link-icon');
30
+ }
31
+
32
+ async getTileAnchor(label: string): Promise<WebdriverIO.Element> {
33
+ const treeItem = await this.getSidebarTile(label);
34
+ return (await this.getTreeItemTile(treeItem)).shadow$('a');
83
35
  }
84
36
 
85
37
  async getRedocBackLink(): Promise<WebdriverIO.Element> {
@@ -113,8 +65,16 @@ class DocsPage extends Page {
113
65
  }
114
66
 
115
67
  async selectLanguage(displayText: string): Promise<void> {
68
+ const picker = await this.getLanguagePicker();
69
+ // A hidden mobile/desktop duplicate of the footer nav can overlap this button at the
70
+ // same screen coordinates, so a native pointer click risks getting intercepted by it.
71
+ await browser.execute((el: { click: () => void }) => el.click(), picker);
72
+
116
73
  const options = await $$('>>>dx-dropdown-option');
117
- for (const option of options) {
74
+ const isDisplayed = await Promise.all(options.map((option) => option.isDisplayed()));
75
+ const visibleOptions = options.filter((_, index) => isDisplayed[index]);
76
+
77
+ for (const option of visibleOptions) {
118
78
  const link = await option.shadow$('a.option');
119
79
  if ((await link.getText()).trim() === displayText) {
120
80
  await browser.execute((el: { click: () => void }) => el.click(), link);
@@ -58,6 +58,10 @@ export default class Page {
58
58
  ).waitForDisplayed({ timeout: this.REFERENCE_LOAD_WAIT_TIME });
59
59
  }
60
60
 
61
+ async getContentHeading(): Promise<WebdriverIO.Element> {
62
+ return (await $('doc-unified-content-layout')).$('div.markdown-content h1');
63
+ }
64
+
61
65
  async waitForGuidePageLoad(): Promise<void> {
62
66
  await $('doc-content-layout').waitForDisplayed({ timeout: 5000 });
63
67
  }
@@ -84,6 +88,89 @@ export default class Page {
84
88
  return await $('>>>doc-specification-content');
85
89
  }
86
90
 
91
+ async getTreeItemTile(treeItem: WebdriverIO.Element): Promise<WebdriverIO.Element> {
92
+ return treeItem.shadow$('dx-tree-tile');
93
+ }
94
+
95
+ async getSidebar(): Promise<WebdriverIO.Element> {
96
+ return (await $('>>>doc-content-layout')).shadow$('div > dx-sidebar-old');
97
+ }
98
+
99
+ async waitForSidebar(): Promise<void> {
100
+ await (await this.getSidebar()).waitForDisplayed();
101
+ }
102
+
103
+ async getSidebarTrees(): Promise<WebdriverIO.ElementArray> {
104
+ const sidebar = await this.getSidebar();
105
+ return sidebar.shadow$$('div.container div.sidebar-content dx-tree');
106
+ }
107
+
108
+ async getTreeItemLabel(treeItem: WebdriverIO.Element): Promise<string> {
109
+ const tile = await this.getTreeItemTile(treeItem);
110
+ const label = await tile.shadow$('span.tile-label');
111
+ return (await label.getText()).trim();
112
+ }
113
+
114
+ /**
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
+ */
119
+ async expandTreeItem(treeItem: WebdriverIO.Element): Promise<void> {
120
+ const tile = await this.getTreeItemTile(treeItem);
121
+ const icon = await tile.shadow$('.tile-expand-icon dx-icon');
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
+ });
132
+ }
133
+
134
+ async findTreeItemByLabel(
135
+ treeItem: WebdriverIO.Element,
136
+ label: string,
137
+ ): Promise<WebdriverIO.Element | null> {
138
+ if ((await this.getTreeItemLabel(treeItem)) === label) {
139
+ return treeItem;
140
+ }
141
+
142
+ const children = await treeItem.shadow$$('dx-tree-item');
143
+ for (const child of children) {
144
+ const match = await this.findTreeItemByLabel(child, label);
145
+ if (match) {
146
+ return match;
147
+ }
148
+ }
149
+ return null;
150
+ }
151
+
152
+ async getSidebarTreeItemByLabel(label: string): Promise<WebdriverIO.Element> {
153
+ const trees = await this.getSidebarTrees();
154
+ for (const tree of trees) {
155
+ const rootItem = await tree.shadow$('dx-tree-item');
156
+ const match = await this.findTreeItemByLabel(rootItem, label);
157
+ if (match) {
158
+ return match;
159
+ }
160
+ }
161
+ throw new Error(`No sidebar tree item found with label "${label}"`);
162
+ }
163
+
164
+ /**
165
+ * Options render in a single shared overlay, one per picker on the page, hidden until their
166
+ * own dropdown opens — filtering to visible ones scopes this to whichever just opened.
167
+ */
168
+ async getVersionOptions(): Promise<WebdriverIO.Element[]> {
169
+ const allOptions = await $$('>>>doc-version-picker dx-dropdown-option');
170
+ const isDisplayed = await Promise.all(allOptions.map((option) => option.isDisplayed()));
171
+ return allOptions.filter((_, index) => isDisplayed[index]);
172
+ }
173
+
87
174
  async waitForSpinnerToDisappear(element: WebdriverIO.Element): Promise<void> {
88
175
  await browser.waitUntil(
89
176
  async function () {
@@ -0,0 +1,208 @@
1
+ import Page from './page';
2
+
3
+ /** Must match the sessionStorage key the doc-version-picker component writes to. */
4
+ const TOPIC_VERSION_SELECTIONS_SESSION_KEY = 'sfdocs-topic-version-selections';
5
+
6
+ /**
7
+ * Page object for topic-level (per-topic) version picker interactions.
8
+ *
9
+ * Two `doc-version-picker` instances exist for a versioned topic:
10
+ * - the SIDEBAR picker (small variant), rendered as a sibling of `dx-tree-tile` inside the
11
+ * versioned tree row's own shadow root (`class="tree-item-version-picker"`).
12
+ * - the REDOC SPEC-PAGE picker (default variant), rendered inside `div.redoc-project-header`
13
+ * alongside the back-link/spec title. Redoc mounts this header into BOTH `.menu-content` and
14
+ * `.api-content`, so we always scope through the sidebar's copy (`getRedocProjectHeader`) to
15
+ * avoid matching the duplicate.
16
+ */
17
+ export default class TopicVersionPage extends Page {
18
+ async waitForMarkdownTopicLoad(): Promise<void> {
19
+ await (
20
+ await $('>>>doc-content-layout')
21
+ ).waitForDisplayed({ timeout: this.REFERENCE_LOAD_WAIT_TIME });
22
+ }
23
+
24
+ async waitForRedocTopicLoad(): Promise<void> {
25
+ await $('doc-redoc-reference > .redoc-container').waitForDisplayed({
26
+ timeout: this.REFERENCE_LOAD_WAIT_TIME,
27
+ });
28
+ }
29
+
30
+ async getSidebarTreeItem(label: string): Promise<WebdriverIO.Element> {
31
+ return this.getSidebarTreeItemByLabel(label);
32
+ }
33
+
34
+ /** The sidebar row's own doc-version-picker (small variant), or null if it has none. */
35
+ async getSidebarPicker(rowLabel: string): Promise<WebdriverIO.Element | null> {
36
+ const treeItem = await this.getSidebarTreeItem(rowLabel);
37
+ const picker = await treeItem.shadow$('.tree-item-version-picker');
38
+ return (await picker.isExisting()) ? picker : null;
39
+ }
40
+
41
+ /** Picks a version in the sidebar row's picker and waits for the markdown page to reload. */
42
+ async selectSidebarVersion(rowLabel: string, versionLabel: string): Promise<void> {
43
+ const picker = await this.getSidebarPicker(rowLabel);
44
+ if (!picker) {
45
+ throw new Error(`No version picker found on sidebar row "${rowLabel}"`);
46
+ }
47
+ await this.selectVersionByLabel(picker, versionLabel);
48
+ await this.waitForMarkdownTopicLoad();
49
+ }
50
+
51
+ // --- Redoc spec-page project header (default variant) ---
52
+
53
+ private async getRedocSidebar(): Promise<WebdriverIO.Element> {
54
+ return $('.redoc-wrap > .menu-content');
55
+ }
56
+
57
+ private async getRedocProjectHeader(): Promise<WebdriverIO.Element> {
58
+ return (await this.getRedocSidebar()).$('div.redoc-project-header');
59
+ }
60
+
61
+ /** Back link in the menu header, not the duplicate inside api-content. */
62
+ async getRedocBackLink(): Promise<WebdriverIO.Element> {
63
+ return (await this.getRedocProjectHeader()).$('a.redoc-project-back');
64
+ }
65
+
66
+ /** The Redoc spec-page's own doc-version-picker, or null if this spec has no versions. */
67
+ async getRedocPicker(): Promise<WebdriverIO.Element | null> {
68
+ const header = await this.getRedocProjectHeader();
69
+ const wrapper = await header.$('.redoc-version-picker');
70
+ if (!(await wrapper.isExisting())) {
71
+ return null;
72
+ }
73
+ return wrapper.$('doc-version-picker');
74
+ }
75
+
76
+ async openRedocFromSidebar(label: string): Promise<void> {
77
+ const item = await this.getSidebarTreeItem(label);
78
+ await item.click();
79
+ await this.waitForRedocTopicLoad();
80
+ }
81
+
82
+ async selectRedocVersionByLabel(label: string): Promise<void> {
83
+ const picker = await this.getRedocPicker();
84
+ await this.selectVersionByLabel(picker!, label);
85
+ await this.waitForRedocTopicLoad();
86
+ }
87
+
88
+ async goBackFromRedoc(): Promise<void> {
89
+ await (await this.getRedocBackLink()).click();
90
+ await this.waitForMarkdownTopicLoad();
91
+ }
92
+
93
+ /**
94
+ * The dismissible "Newer Version Available" banner shown on a non-latest Redoc spec version.
95
+ * Reuses the `doc-phase` component, inserted at the top of `.api-content`. Returns null when
96
+ * absent (latest version, single version, or no versions).
97
+ */
98
+ async getRedocVersionBanner(): Promise<WebdriverIO.Element | null> {
99
+ const banner = await $(
100
+ 'doc-redoc-reference > .redoc-container .api-content .doc-phase-wrapper doc-phase',
101
+ );
102
+ return (await banner.isExisting()) ? banner : null;
103
+ }
104
+
105
+ /**
106
+ * The markdown-topic analog of `getRedocVersionBanner`.
107
+ */
108
+ async getMarkdownVersionBanner(): Promise<WebdriverIO.Element | null> {
109
+ const banner = await $('>>>doc-content-layout doc-phase[slot="version-banner"]');
110
+ return (await banner.isExisting()) ? banner : null;
111
+ }
112
+
113
+ async getBannerTitle(banner: WebdriverIO.Element): Promise<string> {
114
+ return (await banner.shadow$('.doc-phase-title')).getText();
115
+ }
116
+
117
+ async getBannerLinkHref(banner: WebdriverIO.Element): Promise<string> {
118
+ const link = await (await banner.shadow$('.doc-phase-body')).$('a');
119
+ return link.getAttribute('href');
120
+ }
121
+
122
+ // --- Generic picker interactions (work for either variant) ---
123
+
124
+ async getSelectedVersionLabel(picker: WebdriverIO.Element): Promise<string> {
125
+ const label = await picker.shadow$('p.selected-version-label');
126
+ return (await label.getText()).trim();
127
+ }
128
+
129
+ async isReadOnly(picker: WebdriverIO.Element): Promise<boolean> {
130
+ return (await picker.shadow$('p.version-picker-readonly')).isExisting();
131
+ }
132
+
133
+ /** Default (non-small) variant only — the redoc spec-page picker. */
134
+ async isLatestBadgeShown(picker: WebdriverIO.Element): Promise<boolean> {
135
+ return (await picker.shadow$('dx-type-badge.latest-badge')).isExisting();
136
+ }
137
+
138
+ async isNotLatestBadgeShown(picker: WebdriverIO.Element): Promise<boolean> {
139
+ return (await picker.shadow$('dx-type-badge.not-latest-badge')).isExisting();
140
+ }
141
+
142
+ /** Small variant only — the sidebar picker shows a colored dot instead of a badge. */
143
+ async isLatestDotShown(picker: WebdriverIO.Element): Promise<boolean> {
144
+ return (await picker.shadow$('span.version-picker-dot-latest')).isExisting();
145
+ }
146
+
147
+ async isNotLatestDotShown(picker: WebdriverIO.Element): Promise<boolean> {
148
+ return (await picker.shadow$('span.version-picker-dot-not-latest')).isExisting();
149
+ }
150
+
151
+ async openPicker(picker: WebdriverIO.Element): Promise<void> {
152
+ const trigger = await picker.shadow$('.version-picker-button');
153
+ await trigger.waitForDisplayed();
154
+ await trigger.waitForClickable();
155
+ await trigger.click();
156
+ }
157
+
158
+ async getOptionLabel(option: WebdriverIO.Element): Promise<string> {
159
+ const label = await option.shadow$('.option_label');
160
+ return (await label.getText()).trim();
161
+ }
162
+
163
+ async selectVersionByLabel(picker: WebdriverIO.Element, label: string): Promise<void> {
164
+ await this.openPicker(picker);
165
+ // The menu fades in. isDisplayed is false while its opacity is still 0.
166
+ await browser.waitUntil(async () => (await this.getVersionOptions()).length > 0, {
167
+ timeout: 5000,
168
+ timeoutMsg: 'Expected the version menu to show its options',
169
+ });
170
+ const options = await this.getVersionOptions();
171
+ for (const option of options) {
172
+ if ((await this.getOptionLabel(option)) === label) {
173
+ await option.waitForClickable();
174
+ await option.click();
175
+ return;
176
+ }
177
+ }
178
+ throw new Error(`No version option found with label "${label}"`);
179
+ }
180
+
181
+ private async waitForUrlCondition(
182
+ description: string,
183
+ predicate: (url: string) => boolean,
184
+ ): Promise<void> {
185
+ await browser.waitUntil(async () => predicate(await browser.getUrl()), {
186
+ timeout: 15000,
187
+ timeoutMsg: `expected URL to ${description}`,
188
+ });
189
+ }
190
+
191
+ async waitForUrlToContain(path: string): Promise<void> {
192
+ await this.waitForUrlCondition(`contain ${path}`, (url) => url.includes(path));
193
+ }
194
+
195
+ async waitForUrlToEndWith(path: string): Promise<void> {
196
+ await this.waitForUrlCondition(`end with ${path}`, (url) => url.endsWith(path));
197
+ }
198
+
199
+ async readSessionVersionSelections(): Promise<Record<string, string> | null> {
200
+ // The tsconfig's lib list omits "DOM", so sessionStorage isn't a known global here even
201
+ // though this callback runs in the browser — route through globalThis to sidestep that.
202
+ const raw = await browser.execute(
203
+ (key) => (globalThis as any).sessionStorage.getItem(key),
204
+ TOPIC_VERSION_SELECTIONS_SESSION_KEY,
205
+ );
206
+ return raw ? JSON.parse(raw) : null;
207
+ }
208
+ }
@@ -85,7 +85,7 @@ describe('Docs content type', () => {
85
85
  await parentTile.click();
86
86
  await page.waitPageLoad();
87
87
 
88
- expect(await browser.getUrl()).toContain('parent-with-refs.html');
88
+ expect(await browser.getUrl()).toContain('errors-and-rate-limits.html');
89
89
  expect(await (await page.getContentHeading()).getText()).toContain(
90
90
  'Errors and Rate Limits',
91
91
  );
@@ -197,7 +197,7 @@ describe('Docs content type > internal links', () => {
197
197
 
198
198
  describe('Docs content type > spec (Redoc) topic', () => {
199
199
  beforeEach(async () => {
200
- page = new DocsPage('/docs/docs-content-type-example/sample-api');
200
+ page = new DocsPage('/docs/docs-content-type-example/widgets-api-reference');
201
201
  page.open();
202
202
  await page.waitForRedocLoad();
203
203
  });
@@ -218,7 +218,7 @@ describe('Docs content type > spec (Redoc) topic', () => {
218
218
 
219
219
  it('falls back to the landing topic when the back link is clicked on a directly opened spec', async () => {
220
220
  await browser.reloadSession();
221
- page = new DocsPage('/docs/docs-content-type-example/sample-api');
221
+ page = new DocsPage('/docs/docs-content-type-example/widgets-api-reference');
222
222
  page.open();
223
223
  await page.waitForRedocLoad();
224
224
 
@@ -245,7 +245,7 @@ describe('Docs content type > locale picker', () => {
245
245
  });
246
246
 
247
247
  it('shows the language picker on a spec topic of a localized project', async () => {
248
- page = new DocsPage('/docs/docs-content-type-example/sample-api');
248
+ page = new DocsPage('/docs/docs-content-type-example/widgets-api-reference');
249
249
  page.open();
250
250
  await page.waitForRedocLoad();
251
251
 
@@ -256,7 +256,7 @@ describe('Docs content type > locale picker', () => {
256
256
  });
257
257
 
258
258
  it('re-renders the spec in the selected locale when switching language on a spec page', async () => {
259
- page = new DocsPage('/docs/docs-content-type-example/sample-api');
259
+ page = new DocsPage('/docs/docs-content-type-example/widgets-api-reference');
260
260
  page.open();
261
261
  await page.waitForRedocLoad();
262
262
 
@@ -306,7 +306,7 @@ describe('Docs content type > localized (ja-jp) rendering', () => {
306
306
  });
307
307
 
308
308
  it('renders the Redoc view from a ja-jp spec URL', async () => {
309
- page = new DocsPage('/docs/ja-jp/docs-content-type-example/sample-api');
309
+ page = new DocsPage('/docs/ja-jp/docs-content-type-example/widgets-api-reference');
310
310
  page.open();
311
311
  await page.waitForRedocLoad();
312
312
 
@@ -355,8 +355,7 @@ describe('Docs content type > external link', () => {
355
355
  await page.waitPageLoad();
356
356
  await page.waitForSidebar();
357
357
 
358
- const tile = await page.getSidebarTile('Salesforce Developers');
359
- const anchor = await tile.shadow$('a');
358
+ const anchor = await page.getTileAnchor('Salesforce Developers');
360
359
  expect(await anchor.getAttribute('href')).toContain('https://developer.salesforce.com');
361
360
  expect(await anchor.getAttribute('target')).toBe('_blank');
362
361
  });
@@ -190,7 +190,7 @@ describe('Redoc API Reference page', () => {
190
190
 
191
191
  const secondItem = sideBarContent[1];
192
192
  const treeItem = await secondItem.shadow$('dx-tree-item');
193
- const treeTile = await treeItem.shadow$('a > dx-tree-tile');
193
+ const treeTile = await refPage.getTreeItemTile(treeItem);
194
194
  const arrowIcon = await treeTile.shadow$(
195
195
  'a > div[role="heading"] > div.tile-forward-arrow',
196
196
  );
@@ -106,7 +106,7 @@ describe('Reference Versioning', () => {
106
106
  const versionBtn = await $('>>>.version-picker-button');
107
107
  await versionBtn.waitForDisplayed();
108
108
  await versionBtn.click();
109
- const versionOptions = await $$('>>>doc-version-picker dx-dropdown-option');
109
+ const versionOptions = await referencePage.getVersionOptions();
110
110
 
111
111
  expect(versionOptions.length).toEqual(2);
112
112
  expect(await (await versionOptions[0].shadow$('div>div')).getText()).toEqual('0.1.3');
@@ -118,20 +118,19 @@ describe('Reference Versioning', () => {
118
118
  const searchBox = await dxInput.shadow$('input');
119
119
 
120
120
  await searchBox.click();
121
- await browser.keys('/cart-coupons');
121
+ await browser.keys('coupon');
122
+ await browser.pause(1000);
122
123
 
123
124
  const dxTreeItems = await $$('>>>dx-tree-item');
124
125
 
125
- expect(dxTreeItems.length > 2).toBeTruthy();
126
-
127
- await (await dxTreeItems[2]).click();
126
+ await dxTreeItems[2].click();
128
127
 
129
128
  const versionBtn = await $('>>>.version-picker-button');
130
129
 
131
130
  await versionBtn.waitForDisplayed();
132
131
  await versionBtn.click();
133
132
 
134
- const versionOptions = await $$('>>>doc-version-picker dx-dropdown-option');
133
+ const versionOptions = await referencePage.getVersionOptions();
135
134
 
136
135
  await versionOptions[1].waitForClickable();
137
136
  await versionOptions[1].click();
@@ -150,7 +149,7 @@ describe('Reference Versioning', () => {
150
149
  await versionPicker.waitForDisplayed();
151
150
  await versionPicker.click();
152
151
 
153
- const versionOptions = await $$('>>>doc-version-picker dx-dropdown-option');
152
+ const versionOptions = await referencePage.getVersionOptions();
154
153
  const selectedVersionText = await (await versionOptions[1].shadow$('div>div')).getText();
155
154
 
156
155
  await versionOptions[1].click();
@@ -0,0 +1,452 @@
1
+ import { it } from 'mocha';
2
+ import TopicVersionPage from '../pageobjects/topic-version.page';
3
+
4
+ // Fixtures live in the `docs-content-type-example` project, kept in sync between this monorepo's
5
+ // local `packages/example-repository` and the remote `salesforcedocs/example-repository`'s
6
+ // `mh/topic-level-version` branch (pinned in example-portal/docsportal.config.js).
7
+ const BASE = '/docs/docs-content-type-example';
8
+
9
+ // Version labels for each fixture's picker, named so a future relabel only needs updating here.
10
+ const OAUTH_V1_LABEL = "SU'26";
11
+ const OAUTH_V2_LABEL = "Winter '26 (API version 65.0) and Spring '26 (API version 66.0)";
12
+ const ERRORS_V2_LABEL = "Summer '26 (API version 67.0)";
13
+ const ERRORS_V1_LABEL = "Spring '26 (API version 66.0)";
14
+ const CLIENT_SDKS_V2_LABEL = "WI'26";
15
+ const CLIENT_SDKS_V1_LABEL = "SU'26";
16
+ const WIDGETS_API_REFERENCE_V2_LABEL = "SU'26";
17
+ const WIDGETS_API_REFERENCE_V1_LABEL = "SP'26";
18
+
19
+ let page: TopicVersionPage;
20
+
21
+ describe('Topic-level versioning > versioned markdown topic', () => {
22
+ // fixture: OAuth — latest is v2 (OAUTH_V2_LABEL), older is v1 (OAUTH_V1_LABEL).
23
+ beforeEach(async () => {
24
+ page = new TopicVersionPage(`${BASE}/oauth.html`);
25
+ page.open();
26
+ await page.waitForMarkdownTopicLoad();
27
+ });
28
+
29
+ it('should render the picker and default to the latest version', async () => {
30
+ const picker = await page.getSidebarPicker('OAuth');
31
+ expect(picker).not.toBeNull();
32
+ expect(await page.getSelectedVersionLabel(picker!)).toEqual(OAUTH_V2_LABEL);
33
+ expect(await page.isLatestDotShown(picker!)).toBeTruthy();
34
+ });
35
+
36
+ it('should list all versions in declared order when the picker is opened', async () => {
37
+ const picker = await page.getSidebarPicker('OAuth');
38
+ await page.openPicker(picker!);
39
+
40
+ const options = await page.getVersionOptions();
41
+ expect(options.length).toEqual(2);
42
+ expect(await page.getOptionLabel(options[0])).toEqual(OAUTH_V2_LABEL);
43
+ expect(await page.getOptionLabel(options[1])).toEqual(OAUTH_V1_LABEL);
44
+ });
45
+
46
+ it('should switch the page content and URL when a non-latest version is selected', async () => {
47
+ await page.selectSidebarVersion('OAuth', OAUTH_V1_LABEL);
48
+
49
+ expect(await (await page.getContentHeading()).getText()).toEqual('OAuth 1.0');
50
+ await page.waitForUrlToContain(`${BASE}/v1/oauth.html`);
51
+ });
52
+
53
+ it('should return to the canonical URL when the latest version is reselected', async () => {
54
+ page = new TopicVersionPage(`${BASE}/v1/oauth.html`);
55
+ page.open();
56
+ await page.waitForMarkdownTopicLoad();
57
+
58
+ await page.selectSidebarVersion('OAuth', OAUTH_V2_LABEL);
59
+
60
+ await page.waitForUrlToEndWith(`${BASE}/oauth.html`);
61
+ const url = await browser.getUrl();
62
+ expect(url.endsWith(`${BASE}/oauth.html`)).toBeTruthy();
63
+ expect(url).not.toContain('/v2/');
64
+ expect(await (await page.getContentHeading()).getText()).toEqual('OAuth 2.0');
65
+ });
66
+
67
+ it('should show the "Newer Version Available" banner when the version is not latest', async () => {
68
+ page = new TopicVersionPage(`${BASE}/v1/oauth.html`);
69
+ page.open();
70
+ await page.waitForMarkdownTopicLoad();
71
+
72
+ const banner = await page.getMarkdownVersionBanner();
73
+ expect(banner).not.toBeNull();
74
+ });
75
+
76
+ it('should not show the "Newer Version Available" banner when the version is latest', async () => {
77
+ const banner = await page.getMarkdownVersionBanner();
78
+ expect(banner).toBeNull();
79
+ });
80
+ });
81
+
82
+ describe('Topic-level versioning > versioned parent with versioned child subtree', () => {
83
+ // fixture: Client SDKs — latest is v2 (CLIENT_SDKS_V2_LABEL), older is v1 (CLIENT_SDKS_V1_LABEL).
84
+ beforeEach(async () => {
85
+ page = new TopicVersionPage(`${BASE}/android.html`);
86
+ page.open();
87
+ await page.waitForMarkdownTopicLoad();
88
+ });
89
+
90
+ it('should render the picker on the parent and default to the latest version', async () => {
91
+ const picker = await page.getSidebarPicker('Client SDKs');
92
+ expect(picker).not.toBeNull();
93
+ expect(await page.getSelectedVersionLabel(picker!)).toEqual(CLIENT_SDKS_V2_LABEL);
94
+ });
95
+
96
+ it('should switch the whole child subtree when the parent version changes', async () => {
97
+ await page.selectSidebarVersion('Client SDKs', CLIENT_SDKS_V1_LABEL);
98
+
99
+ await page.waitForUrlToContain(`${BASE}/v1/android.html`);
100
+ expect(await (await page.getContentHeading()).getText()).toEqual('Android SDK v1');
101
+
102
+ // Sibling child (iOS SDK) should also have moved to the v1 URL, not just this one.
103
+ const iosItem = await page.getSidebarTreeItem('iOS SDK');
104
+ const iosTile = await page.getTreeItemTile(iosItem);
105
+ const iosAnchor = await iosTile.shadow$('a');
106
+ expect(await iosAnchor.getAttribute('href')).toContain('/v1/ios.html');
107
+ });
108
+
109
+ it('should update the picker and sibling hrefs when navigating directly to a different child version', async () => {
110
+ page = new TopicVersionPage(`${BASE}/v1/android.html`);
111
+ page.open();
112
+ await page.waitForMarkdownTopicLoad();
113
+
114
+ page = new TopicVersionPage(`${BASE}/v2/android.html`);
115
+ page.open();
116
+ await page.waitForMarkdownTopicLoad();
117
+
118
+ const picker = await page.getSidebarPicker('Client SDKs');
119
+ expect(await page.getSelectedVersionLabel(picker!)).toEqual(CLIENT_SDKS_V2_LABEL);
120
+
121
+ const iosItem = await page.getSidebarTreeItem('iOS SDK');
122
+ const iosTile = await page.getTreeItemTile(iosItem);
123
+ const iosAnchor = await iosTile.shadow$('a');
124
+ const href = await iosAnchor.getAttribute('href');
125
+ expect(href).toContain('/ios.html');
126
+ expect(href).not.toContain('/v1/');
127
+ });
128
+ });
129
+
130
+ describe('Topic-level versioning > versioned parent with own content, subtopics and a spec subtopic', () => {
131
+ // fixture: Errors and Rate Limits — latest is v2 (ERRORS_V2_LABEL), older is v1 (ERRORS_V1_LABEL).
132
+ beforeEach(async () => {
133
+ page = new TopicVersionPage(`${BASE}/errors-and-rate-limits.html`);
134
+ page.open();
135
+ await page.waitForMarkdownTopicLoad();
136
+ });
137
+
138
+ it('should render the picker and default to the latest version', async () => {
139
+ const picker = await page.getSidebarPicker('Errors and Rate Limits');
140
+ expect(picker).not.toBeNull();
141
+ expect(await page.getSelectedVersionLabel(picker!)).toEqual(ERRORS_V2_LABEL);
142
+ });
143
+
144
+ it("should switch the parent's own page content when the version changes", async () => {
145
+ await page.selectSidebarVersion('Errors and Rate Limits', ERRORS_V1_LABEL);
146
+
147
+ expect(await (await page.getContentHeading()).getText()).toEqual(
148
+ 'Errors and Rate Limits (v1)',
149
+ );
150
+ await page.waitForUrlToContain(`${BASE}/v1/errors-and-rate-limits.html`);
151
+ });
152
+
153
+ it('should switch the markdown subtopics when the version changes', async () => {
154
+ await page.selectSidebarVersion('Errors and Rate Limits', ERRORS_V1_LABEL);
155
+
156
+ const child = await page.getSidebarTreeItem('Common Error Codes');
157
+ await child.click();
158
+ await page.waitForMarkdownTopicLoad();
159
+
160
+ expect(await (await page.getContentHeading()).getText()).toEqual('Common Error Codes (v1)');
161
+ await page.waitForUrlToContain(`${BASE}/v1/extra-child-a.html`);
162
+ });
163
+
164
+ it('should switch the spec (Redoc) subtopic to the matching version when the version changes', async () => {
165
+ // Key cross-type cascade: parent v1 ⇒ the nested spec subtopic is v1 too.
166
+ await page.selectSidebarVersion('Errors and Rate Limits', ERRORS_V1_LABEL);
167
+
168
+ await page.openRedocFromSidebar('Another Spec API');
169
+
170
+ await page.waitForUrlToContain(`${BASE}/v1/new-sample-api`);
171
+ // v1's spec lacks the `GET /errors/{code}` operation that only v2 has — its absence
172
+ // confirms the v1 spec asset loaded, since both versions share the same spec title.
173
+ const getErrorCodeOperation = await $('a[href*="operation/getErrorCode"]');
174
+ expect(await getErrorCodeOperation.isExisting()).toBeFalsy();
175
+ });
176
+
177
+ it('should show the parent topic version selected on the nested Redoc page after Back', async () => {
178
+ await page.openRedocFromSidebar('Another Spec API');
179
+ await page.selectRedocVersionByLabel(ERRORS_V1_LABEL);
180
+ await page.goBackFromRedoc();
181
+
182
+ await page.waitForUrlToContain(`${BASE}/v1/errors-and-rate-limits.html`);
183
+ const parentPicker = await page.getSidebarPicker('Errors and Rate Limits');
184
+ expect(await page.getSelectedVersionLabel(parentPicker!)).toEqual(ERRORS_V1_LABEL);
185
+ });
186
+
187
+ it('should return to the latest parent topic when Redoc is switched back to latest', async () => {
188
+ await page.selectSidebarVersion('Errors and Rate Limits', ERRORS_V1_LABEL);
189
+
190
+ await page.openRedocFromSidebar('Another Spec API');
191
+ await page.selectRedocVersionByLabel(ERRORS_V2_LABEL);
192
+ await page.goBackFromRedoc();
193
+
194
+ await page.waitForUrlToEndWith(`${BASE}/errors-and-rate-limits.html`);
195
+ const parentPicker = await page.getSidebarPicker('Errors and Rate Limits');
196
+ expect(await page.getSelectedVersionLabel(parentPicker!)).toEqual(ERRORS_V2_LABEL);
197
+ });
198
+
199
+ it('should return to the sibling subtopic on the version selected in Redoc', async () => {
200
+ // Open the spec from this sibling so Back returns here, not to the parent.
201
+ const markdownChild = await page.getSidebarTreeItem('Common Error Codes');
202
+ await markdownChild.click();
203
+ await page.waitForMarkdownTopicLoad();
204
+
205
+ await page.openRedocFromSidebar('Another Spec API');
206
+ await page.selectRedocVersionByLabel(ERRORS_V1_LABEL);
207
+ await page.goBackFromRedoc();
208
+
209
+ await page.waitForUrlToContain(`${BASE}/v1/extra-child-a.html`);
210
+ const siblingChild = await page.getSidebarTreeItem('Common Error Codes');
211
+ const siblingTile = await page.getTreeItemTile(siblingChild);
212
+ const siblingAnchor = await siblingTile.shadow$('a');
213
+ expect(await siblingAnchor.getAttribute('href')).toContain('/v1/extra-child-a.html');
214
+ });
215
+
216
+ it('should return to an unrelated topic unaffected by a version switch on the nested Redoc page', async () => {
217
+ page = new TopicVersionPage(`${BASE}/get-started.html`);
218
+ page.open();
219
+ await page.waitForMarkdownTopicLoad();
220
+
221
+ // The spec row is absent until its parent is expanded. Expanding does not
222
+ // navigate, so Get Started stays the referrer.
223
+ const parent = await page.getSidebarTreeItem('Errors and Rate Limits');
224
+ await page.expandTreeItem(parent);
225
+
226
+ await page.openRedocFromSidebar('Another Spec API');
227
+ await page.selectRedocVersionByLabel(ERRORS_V1_LABEL);
228
+ await page.goBackFromRedoc();
229
+
230
+ await page.waitForUrlToContain(`${BASE}/get-started.html`);
231
+ expect(await browser.getUrl()).not.toContain('/v1/');
232
+ });
233
+
234
+ it('should fall back to the project landing page when the Redoc page is opened with no referrer', async () => {
235
+ // No stored back target. WebDriver navigation also leaves document.referrer empty.
236
+ // globalThis: this package's tsconfig lib list omits DOM.
237
+ await browser.execute(() =>
238
+ (globalThis as any).sessionStorage.removeItem('redoc-back-target'),
239
+ );
240
+
241
+ page = new TopicVersionPage(`${BASE}/new-sample-api`);
242
+ page.open();
243
+ await page.waitForRedocTopicLoad();
244
+
245
+ await page.selectRedocVersionByLabel(ERRORS_V1_LABEL);
246
+ await page.goBackFromRedoc();
247
+
248
+ // With no back target, Back goes to the first TOC topic. That topic is unversioned.
249
+ await page.waitForUrlToContain(`${BASE}/get-started.html`);
250
+ expect(await browser.getUrl()).not.toContain('/v1/');
251
+ });
252
+ });
253
+
254
+ describe('Topic-level versioning > standalone Redoc reference', () => {
255
+ // fixture: Widgets API Reference — a spec (forward-arrow) topic, so it never gets a sidebar
256
+ // picker; the picker lives on the Redoc page's own project header instead.
257
+ beforeEach(async () => {
258
+ page = new TopicVersionPage(`${BASE}/widgets-api-reference`);
259
+ page.open();
260
+ await page.waitForRedocTopicLoad();
261
+ });
262
+
263
+ it('should render the Redoc version picker and default to the latest version', async () => {
264
+ const picker = await page.getRedocPicker();
265
+ expect(picker).not.toBeNull();
266
+ expect(await page.getSelectedVersionLabel(picker!)).toEqual(WIDGETS_API_REFERENCE_V2_LABEL);
267
+ });
268
+
269
+ it('should switch the rendered spec when a different version is selected', async () => {
270
+ const picker = await page.getRedocPicker();
271
+ await page.selectVersionByLabel(picker!, WIDGETS_API_REFERENCE_V1_LABEL);
272
+ await page.waitForRedocTopicLoad();
273
+
274
+ await page.waitForUrlToContain(`${BASE}/v1/widgets-api-reference`);
275
+ const apiInfo = await $('>>>div.api-info');
276
+ expect(await apiInfo.getText()).toContain('1.0.0');
277
+ });
278
+
279
+ it('should show the "Newer Version Available" banner when the version is not latest', async () => {
280
+ page = new TopicVersionPage(`${BASE}/v1/widgets-api-reference`);
281
+ page.open();
282
+ await page.waitForRedocTopicLoad();
283
+
284
+ const banner = await page.getRedocVersionBanner();
285
+ expect(banner).not.toBeNull();
286
+ expect(await page.getBannerTitle(banner!)).toEqual('Newer Version Available');
287
+ expect(await page.getBannerLinkHref(banner!)).toContain(`${BASE}/widgets-api-reference`);
288
+ });
289
+
290
+ it('should not show the "Newer Version Available" banner when the version is latest', async () => {
291
+ const banner = await page.getRedocVersionBanner();
292
+ expect(banner).toBeNull();
293
+ });
294
+ });
295
+
296
+ describe('Topic-level versioning > URL resolution (markdown)', () => {
297
+ it('should serve the latest version at the canonical URL', async () => {
298
+ page = new TopicVersionPage(`${BASE}/oauth.html`);
299
+ page.open();
300
+ await page.waitForMarkdownTopicLoad();
301
+ expect(await (await page.getContentHeading()).getText()).toEqual('OAuth 2.0');
302
+ });
303
+
304
+ it('should serve the latest version at its versioned alias URL', async () => {
305
+ page = new TopicVersionPage(`${BASE}/v2/oauth.html`);
306
+ page.open();
307
+ await page.waitForMarkdownTopicLoad();
308
+ expect(await (await page.getContentHeading()).getText()).toEqual('OAuth 2.0');
309
+ });
310
+
311
+ it('should serve an older version at its versioned URL', async () => {
312
+ page = new TopicVersionPage(`${BASE}/v1/oauth.html`);
313
+ page.open();
314
+ await page.waitForMarkdownTopicLoad();
315
+ expect(await (await page.getContentHeading()).getText()).toEqual('OAuth 1.0');
316
+ });
317
+
318
+ it('should initialize the picker from the URL version', async () => {
319
+ page = new TopicVersionPage(`${BASE}/v1/oauth.html`);
320
+ page.open();
321
+ await page.waitForMarkdownTopicLoad();
322
+
323
+ const picker = await page.getSidebarPicker('OAuth');
324
+ expect(await page.getSelectedVersionLabel(picker!)).toEqual(OAUTH_V1_LABEL);
325
+ });
326
+ });
327
+
328
+ describe('Topic-level versioning > URL resolution (spec)', () => {
329
+ it('should serve the latest spec at the canonical URL', async () => {
330
+ page = new TopicVersionPage(`${BASE}/widgets-api-reference`);
331
+ page.open();
332
+ await page.waitForRedocTopicLoad();
333
+ expect(await (await $('>>>div.api-info')).getText()).toContain('2.0.0');
334
+ });
335
+
336
+ it('should serve the latest spec at its versioned alias URL', async () => {
337
+ page = new TopicVersionPage(`${BASE}/v2/widgets-api-reference`);
338
+ page.open();
339
+ await page.waitForRedocTopicLoad();
340
+ expect(await (await $('>>>div.api-info')).getText()).toContain('2.0.0');
341
+ });
342
+
343
+ it('should serve an older spec at its versioned URL', async () => {
344
+ page = new TopicVersionPage(`${BASE}/v1/widgets-api-reference`);
345
+ page.open();
346
+ await page.waitForRedocTopicLoad();
347
+ expect(await (await $('>>>div.api-info')).getText()).toContain('1.0.0');
348
+ });
349
+ });
350
+
351
+ describe('Topic-level versioning > single-version picker (read-only)', () => {
352
+ // A topic with exactly one authored version still renders a picker, but read-only (no
353
+ // dropdown) and never with the "Newer Version Available" banner, since a single version is
354
+ // always the latest by definition.
355
+ // fixture: Widgets API (Beta) — single version 'Beta'.
356
+ it('should render a read-only picker with no dropdown when a Redoc spec has a single version', async () => {
357
+ page = new TopicVersionPage(`${BASE}/widgets-api-beta`);
358
+ page.open();
359
+ await page.waitForRedocTopicLoad();
360
+ const picker = await page.getRedocPicker();
361
+ expect(await page.isReadOnly(picker!)).toBeTruthy();
362
+ expect(await page.getRedocVersionBanner()).toBeNull();
363
+ });
364
+ });
365
+
366
+ describe('Topic-level versioning > topics without a version picker', () => {
367
+ it('should not render a sidebar picker when the markdown topic is evergreen', async () => {
368
+ page = new TopicVersionPage(`${BASE}/get-started.html`);
369
+ page.open();
370
+ await page.waitForMarkdownTopicLoad();
371
+
372
+ const picker = await page.getSidebarPicker('Get Started');
373
+ expect(picker).toBeNull();
374
+ expect(await browser.getUrl()).not.toMatch(/\/v\d+\//);
375
+ expect(await page.getMarkdownVersionBanner()).toBeNull();
376
+ });
377
+
378
+ // fixture: Widgets Status API — plain spec:, no versions: at all.
379
+ it('should not render a picker when the Redoc spec is evergreen', async () => {
380
+ page = new TopicVersionPage(`${BASE}/widgets-status-api`);
381
+ page.open();
382
+ await page.waitForRedocTopicLoad();
383
+ expect(await page.getRedocPicker()).toBeNull();
384
+ expect(await page.getRedocVersionBanner()).toBeNull();
385
+ });
386
+
387
+ it('should show the picker only on versioned rows when the sidebar is mixed', async () => {
388
+ page = new TopicVersionPage(`${BASE}/get-started.html`);
389
+ page.open();
390
+ await page.waitForMarkdownTopicLoad();
391
+ await page.waitForSidebar();
392
+
393
+ expect(await page.getSidebarPicker('OAuth')).not.toBeNull();
394
+ expect(await page.getSidebarPicker('Errors and Rate Limits')).not.toBeNull();
395
+ expect(await page.getSidebarPicker('Client SDKs')).not.toBeNull();
396
+ expect(await page.getSidebarPicker('Get Started')).toBeNull();
397
+ expect(await page.getSidebarPicker('Widget Concepts')).toBeNull();
398
+ });
399
+
400
+ it('should not leak a version segment when navigating to an evergreen topic', async () => {
401
+ page = new TopicVersionPage(`${BASE}/v1/oauth.html`);
402
+ page.open();
403
+ await page.waitForMarkdownTopicLoad();
404
+
405
+ const getStarted = await page.getSidebarTreeItem('Get Started');
406
+ await getStarted.click();
407
+ await page.waitForMarkdownTopicLoad();
408
+
409
+ await page.waitForUrlToContain(`${BASE}/get-started.html`);
410
+ expect(await browser.getUrl()).not.toContain('/v1/');
411
+ });
412
+ });
413
+
414
+ describe('Topic-level versioning > persistence on reload', () => {
415
+ it('should keep the selected version and its content after a refresh', async () => {
416
+ page = new TopicVersionPage(`${BASE}/oauth.html`);
417
+ page.open();
418
+ await page.waitForMarkdownTopicLoad();
419
+
420
+ await page.selectSidebarVersion('OAuth', OAUTH_V1_LABEL);
421
+
422
+ await browser.refresh();
423
+ await page.waitForMarkdownTopicLoad();
424
+
425
+ const pickerAfterReload = await page.getSidebarPicker('OAuth');
426
+ expect(await page.getSelectedVersionLabel(pickerAfterReload!)).toEqual(OAUTH_V1_LABEL);
427
+ expect(await (await page.getContentHeading()).getText()).toEqual('OAuth 1.0');
428
+ expect(await browser.getUrl()).toContain(`${BASE}/v1/oauth.html`);
429
+
430
+ const selections = await page.readSessionVersionSelections();
431
+ expect(selections).not.toBeNull();
432
+ expect(selections![`${BASE}/oauth.html`]).toEqual('v1');
433
+ });
434
+ });
435
+
436
+ describe('Topic-level versioning > invalid version in URL', () => {
437
+ it('should return a 404 when the markdown URL has an invalid version', async () => {
438
+ browser.url(`${BASE}/v999/oauth.html`);
439
+
440
+ const errorComponent = await $('dx-error');
441
+ await errorComponent.waitForDisplayed();
442
+ expect(await browser.getTitle()).toEqual('404 Error | Salesforce Developers');
443
+ });
444
+
445
+ it('should return a 404 when the spec URL has an invalid version', async () => {
446
+ browser.url(`${BASE}/v999/widgets-api-reference`);
447
+
448
+ const errorComponent = await $('dx-error');
449
+ await errorComponent.waitForDisplayed();
450
+ expect(await browser.getTitle()).toEqual('404 Error | Salesforce Developers');
451
+ });
452
+ });