@bigbinary/neeto-playwright-commons 6.1.0 → 6.1.2

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.
Files changed (3) hide show
  1. package/index.d.ts +5 -1
  2. package/index.js +17 -5
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -40,6 +40,7 @@ interface AssertCardDetailsProps {
40
40
  cardLocator: Locator;
41
41
  title: string;
42
42
  description: string;
43
+ subLinkId?: string;
43
44
  }
44
45
  type ErrorHandlingResult<T> = {
45
46
  success: true;
@@ -658,6 +659,8 @@ declare class CustomCommands {
658
659
  *
659
660
  * description: The description of the card.
660
661
  *
662
+ * subLinkId (optional): The sidebar sub-link's test ID prefix, used to check it isn't highlighted. Defaults to title.
663
+ *
661
664
  * @example
662
665
  *
663
666
  * await neetoPlaywrightUtilities.assertCardDetails({
@@ -670,7 +673,8 @@ declare class CustomCommands {
670
673
  assertCardDetails: ({
671
674
  cardLocator,
672
675
  title,
673
- description
676
+ description,
677
+ subLinkId
674
678
  }: AssertCardDetailsProps) => Promise<[void, void, void]>;
675
679
  /**
676
680
  *
package/index.js CHANGED
@@ -926,7 +926,7 @@ const NEETO_EDITOR_SELECTORS = {
926
926
  imageUploadLinkButton: "neeto-editor-media-uploader-link-tab",
927
927
  errorText: "neeto-editor-error-text",
928
928
  content: "editor-content",
929
- imageUploadDeleteButton: "neeto-editor-image-menu-Delete",
929
+ imageUploadDeleteButton: "neeto-editor-image-menu-delete",
930
930
  dynamicVariablesButton: "dynamic-variables-button",
931
931
  emojiContainer: "neeto-editor-emoji-picker",
932
932
  characterCount: "neeto-editor-character-count",
@@ -2587,10 +2587,10 @@ class CustomCommands {
2587
2587
  });
2588
2588
  await this.page.mouse.up();
2589
2589
  };
2590
- assertCardDetails = ({ cardLocator, title, description, }) => Promise.all([
2590
+ assertCardDetails = ({ cardLocator, title, description, subLinkId = title, }) => Promise.all([
2591
2591
  expect(cardLocator.getByTestId(ADMIN_PANEL_SELECTORS.settingsItemHeading)).toHaveText(title),
2592
2592
  expect(cardLocator.getByTestId(ADMIN_PANEL_SELECTORS.settingsItemDescription)).toHaveText(description),
2593
- expect(this.page.getByTestId(COMMON_SELECTORS.sidebarSubLink(title))).toHaveCSS("background-color", COLOR.transparent),
2593
+ expect(this.page.getByTestId(COMMON_SELECTORS.sidebarSubLink(subLinkId))).toHaveCSS("background-color", COLOR.transparent),
2594
2594
  ]);
2595
2595
  executeWithErrorHandling = async (asyncFn) => {
2596
2596
  try {
@@ -11096,6 +11096,15 @@ class ProductServer {
11096
11096
  }
11097
11097
 
11098
11098
  const { name, paths, webpackDevFile, setupScript, baseUrl, readyUrl, maxWaitMs, } = CHAT_WIDGET;
11099
+ // A product on Yarn 4 puts its own yarn first on PATH for the scripts it runs, so it's dropped to let the widget use its own Yarn.
11100
+ const widgetEnv = (extraEnv = {}) => {
11101
+ const { BERRY_BIN_FOLDER, ...env } = process.env;
11102
+ const PATH = (env.PATH ?? "")
11103
+ .split(path.delimiter)
11104
+ .filter(dir => !BERRY_BIN_FOLDER || dir !== BERRY_BIN_FOLDER)
11105
+ .join(path.delimiter);
11106
+ return { ...env, PATH, ...extraEnv };
11107
+ };
11099
11108
  // Runs neeto-chat-widget's webpack dev server, as it isn't a Rails product; workers share it like ProductServer.
11100
11109
  class WidgetServer {
11101
11110
  log = (msg) => console.log(`[LocalServer:${name}] ${msg}`);
@@ -11130,7 +11139,8 @@ class WidgetServer {
11130
11139
  fs.writeFileSync(webpackDevFile, content.replace(oldConfig, newConfig));
11131
11140
  };
11132
11141
  ensureSetup = async () => {
11133
- if (!fs.existsSync(webpackDevFile)) {
11142
+ // The marker is written only after setup succeeds, so a clone whose install failed is set up again.
11143
+ if (!fs.existsSync(paths.PREPARED_MARKER)) {
11134
11144
  this.log("Running first-time setup...");
11135
11145
  const [githubToken] = await Promise.all([
11136
11146
  getGithubToken(),
@@ -11140,8 +11150,9 @@ class WidgetServer {
11140
11150
  command: "bash",
11141
11151
  args: [setupScript, paths.DIR],
11142
11152
  logFile: paths.SETUP_LOG,
11143
- env: { ...process.env, GITHUB_TOKEN: githubToken },
11153
+ env: widgetEnv({ GITHUB_TOKEN: githubToken }),
11144
11154
  });
11155
+ fs.writeFileSync(paths.PREPARED_MARKER, "");
11145
11156
  }
11146
11157
  this.patchWebpackPublicPath();
11147
11158
  };
@@ -11158,6 +11169,7 @@ class WidgetServer {
11158
11169
  args: ["start"],
11159
11170
  logFile: paths.LOG,
11160
11171
  cwd: paths.DIR,
11172
+ env: widgetEnv(),
11161
11173
  });
11162
11174
  fs.writeFileSync(paths.STATE_FILE, JSON.stringify({ pid }));
11163
11175
  this.log("Server ready.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-playwright-commons",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "A package encapsulating common playwright code across neeto projects.",
5
5
  "repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
6
6
  "license": "apache-2.0",