@camunda/e2e-test-suite 0.0.1147 → 0.0.1149

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.
@@ -1,9 +1,19 @@
1
1
  import { Locator } from '@playwright/test';
2
2
  /**
3
- * Selects the cluster named by MODELER_CLUSTER_NAME in a Web Modeler deploy dialog.
3
+ * Points a Web Modeler deploy dialog at the cluster named by MODELER_CLUSTER_NAME.
4
4
  *
5
5
  * No-op when the variable is unset, which is every single-cluster environment. In a topology one
6
6
  * Hub Web Modeler serves several orchestration clusters and preselects one of them, so a test that
7
7
  * does not choose deploys somewhere other than the release under test.
8
+ *
9
+ * Two dialog generations are in the field:
10
+ *
11
+ * - The legacy one offers a per-deploy cluster combobox labelled "Select a cluster".
12
+ * - Hub's stage-based one offers #cluster-selection-dropdown -- labelled "Stage", aria-label
13
+ * "Select a stage" -- which lists only the clusters bound to the process application's stages
14
+ * and arrives with the one ProcessApplicationPage.ensureStageCluster bound already selected.
15
+ *
16
+ * Hence keying the trigger on its id rather than its accessible name: the id says what the
17
+ * control is for and has survived the rename, the label is prose and did not.
8
18
  */
9
19
  export declare function selectModelerCluster(dialog: Locator): Promise<void>;
@@ -3,28 +3,71 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.selectModelerCluster = void 0;
4
4
  const test_1 = require("@playwright/test");
5
5
  /**
6
- * Selects the cluster named by MODELER_CLUSTER_NAME in a Web Modeler deploy dialog.
6
+ * Points a Web Modeler deploy dialog at the cluster named by MODELER_CLUSTER_NAME.
7
7
  *
8
8
  * No-op when the variable is unset, which is every single-cluster environment. In a topology one
9
9
  * Hub Web Modeler serves several orchestration clusters and preselects one of them, so a test that
10
10
  * does not choose deploys somewhere other than the release under test.
11
+ *
12
+ * Two dialog generations are in the field:
13
+ *
14
+ * - The legacy one offers a per-deploy cluster combobox labelled "Select a cluster".
15
+ * - Hub's stage-based one offers #cluster-selection-dropdown -- labelled "Stage", aria-label
16
+ * "Select a stage" -- which lists only the clusters bound to the process application's stages
17
+ * and arrives with the one ProcessApplicationPage.ensureStageCluster bound already selected.
18
+ *
19
+ * Hence keying the trigger on its id rather than its accessible name: the id says what the
20
+ * control is for and has survived the rename, the label is prose and did not.
11
21
  */
12
22
  async function selectModelerCluster(dialog) {
13
23
  const modelerClusterName = process.env.MODELER_CLUSTER_NAME;
14
24
  if (!modelerClusterName) {
15
25
  return;
16
26
  }
17
- const clusterSelect = dialog.getByRole('combobox', {
27
+ const page = dialog.page();
28
+ const stageSelect = dialog.locator('#cluster-selection-dropdown');
29
+ const legacySelect = dialog.getByRole('combobox', {
18
30
  name: 'Select a cluster',
19
31
  });
20
- await clusterSelect.click();
21
- const escapedClusterName = modelerClusterName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
22
- // The option label carries a trailing " (<status>)", so anchor the name and allow that suffix.
23
- await dialog
24
- .getByRole('option', {
25
- name: new RegExp(`^${escapedClusterName}(?: \\(|$)`),
26
- })
27
- .click();
32
+ // Wait on the union so whichever generation this dialog is settles the wait, instead of paying a
33
+ // full timeout probing the other one first.
34
+ const appeared = await stageSelect
35
+ .or(legacySelect)
36
+ .first()
37
+ .waitFor({ state: 'visible', timeout: 30000 })
38
+ .then(() => true)
39
+ .catch(() => false);
40
+ if (!appeared) {
41
+ throw new Error(`The deploy dialog offers no cluster selector, so "${modelerClusterName}" cannot be ` +
42
+ 'chosen: neither #cluster-selection-dropdown (stage-based dialog) nor a "Select a ' +
43
+ 'cluster" combobox (legacy dialog) became visible.');
44
+ }
45
+ const clusterSelect = (await stageSelect.isVisible().catch(() => false))
46
+ ? stageSelect
47
+ : legacySelect;
48
+ // The stage dialog arrives with the bound cluster already selected, so the usual outcome is that
49
+ // nothing is clicked at all. That is not just a saved click: the option list unmounts on the
50
+ // click that lands, so every open is a chance to lose that race.
51
+ const selected = (await clusterSelect.textContent()) ?? '';
52
+ if (!selected.includes(modelerClusterName)) {
53
+ await clusterSelect.click();
54
+ const escapedClusterName = modelerClusterName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
55
+ // A stage option's accessible name is "<stage><cluster> (<generation>)" -- the stage and the
56
+ // cluster sit in adjacent spans with no whitespace between them, so it reads
57
+ // "DevelopmentOrchestration A (8.10.0-alpha3)" and the cluster name is not at a word
58
+ // boundary. A legacy option is just "<cluster> (<status>)". Anchoring the start therefore
59
+ // matches neither reliably; the trailing " (" is what keeps the match honest, and is enough
60
+ // on its own to tell "Orch" from "Orchestration A".
61
+ const optionName = new RegExp(`${escapedClusterName}(?:\\s*\\(|$)`);
62
+ // The stage select is a Radix UI Select: its listbox is portalled to document.body, OUTSIDE
63
+ // the dialog element, so a dialog-scoped option query never resolves even while the option is
64
+ // visible on screen. Query at page scope; the trigger above stays dialog-scoped because it
65
+ // renders inside the dialog.
66
+ await page
67
+ .getByRole('option', { name: optionName })
68
+ .first()
69
+ .click({ timeout: 30000 });
70
+ }
28
71
  await (0, test_1.expect)(clusterSelect).toContainText(modelerClusterName);
29
72
  }
30
73
  exports.selectModelerCluster = selectModelerCluster;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/e2e-test-suite",
3
- "version": "0.0.1147",
3
+ "version": "0.0.1149",
4
4
  "description": "End-to-end test helpers for Camunda 8",
5
5
  "repository": {
6
6
  "type": "git",