@alfresco/aca-playwright-shared 8.1.0-36718859092 → 8.1.0-36827201917

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.
@@ -232,8 +232,8 @@ const crypto = require('crypto');
232
232
  class Utils {
233
233
  static { this.string257Long = 'x'.repeat(257); }
234
234
  static { this.string513Long = 'x'.repeat(513); }
235
- static random() {
236
- return crypto.getRandomValues(new Uint32Array(1))[0].toString(36).substring(0, 5).toLowerCase();
235
+ static random(length = 5) {
236
+ return Array.from(crypto.getRandomValues(new Uint8Array(length)), (b) => (b % 36).toString(36)).join('');
237
237
  }
238
238
  static retryCall(fn, retry = 30, delay = 1500) {
239
239
  const pause = (duration) => new Promise((res) => setTimeout(res, duration));
@@ -5480,60 +5480,6 @@ class FileActionsApi {
5480
5480
  throw new Error(message);
5481
5481
  }
5482
5482
  }
5483
- async queryNodesSearchHighlight(searchTerm) {
5484
- const data = {
5485
- query: {
5486
- query: `cm:name:"${searchTerm}*"`,
5487
- language: 'afts'
5488
- },
5489
- filterQueries: [{ query: `+TYPE:'cm:folder' OR +TYPE:'cm:content'` }],
5490
- highlight: {
5491
- prefix: "<span class='aca-highlight'>",
5492
- postfix: '</span>',
5493
- fields: [
5494
- {
5495
- field: 'cm:title'
5496
- },
5497
- {
5498
- field: 'cm:name'
5499
- },
5500
- {
5501
- field: 'cm:description',
5502
- snippetCount: 1
5503
- },
5504
- {
5505
- field: 'cm:content',
5506
- snippetCount: 1
5507
- }
5508
- ]
5509
- }
5510
- };
5511
- try {
5512
- return this.apiService.search.search(data);
5513
- }
5514
- catch {
5515
- return new ResultSetPaging();
5516
- }
5517
- }
5518
- async waitForNodesSearchHighlight(searchTerm, data) {
5519
- const predicate = (totalItems) => totalItems === data.expect;
5520
- const apiCall = async () => {
5521
- try {
5522
- return (await this.queryNodesSearchHighlight(searchTerm)).list?.pagination?.totalItems || 0;
5523
- }
5524
- catch (error) {
5525
- logger.warn(`queryNodesSearchHighlight failed for "${searchTerm}": ${JSON.stringify(error)}`);
5526
- return 0;
5527
- }
5528
- };
5529
- try {
5530
- await waitForApi(apiCall, predicate, 30, 2500);
5531
- logger.log(`waitForNodesSearchHighlight: Found ${data.expect} nodes with search term "${searchTerm}"`);
5532
- }
5533
- catch (error) {
5534
- logger.error(`Error: ${JSON.stringify(error)}`);
5535
- }
5536
- }
5537
5483
  async updateNodeContent(nodeId, content, majorVersion = true, comment, newName) {
5538
5484
  try {
5539
5485
  const opts = { majorVersion };
@@ -6742,6 +6688,42 @@ class SearchApi {
6742
6688
  throw new Error(errorMessage);
6743
6689
  }
6744
6690
  }
6691
+ async waitForContentIndexing(contentTerm, expectedFileName, maxRetries) {
6692
+ const query = {
6693
+ query: {
6694
+ query: `cm:content:"${contentTerm}"`,
6695
+ language: 'afts'
6696
+ },
6697
+ filterQueries: [{ query: "+TYPE:'cm:content'" }],
6698
+ paging: { skipCount: 0, maxItems: 25 }
6699
+ };
6700
+ const retryLimit = maxRetries ?? 90;
6701
+ let retryCount = 0;
6702
+ let found = false;
6703
+ do {
6704
+ let result;
6705
+ try {
6706
+ result = await this.apiService.search.search(query);
6707
+ }
6708
+ catch {
6709
+ result = new ResultSetPaging();
6710
+ }
6711
+ found = (result.list?.entries ?? []).some((entry) => entry.entry?.name === expectedFileName);
6712
+ if (!found) {
6713
+ retryCount++;
6714
+ if (retryCount % 10 === 0) {
6715
+ logger.info(`waitForContentIndexing: Still waiting for content "${contentTerm}" in "${expectedFileName}" after ${retryCount} retries (max ${retryLimit}).`);
6716
+ }
6717
+ if (retryCount >= retryLimit) {
6718
+ const message = `waitForContentIndexing: content "${contentTerm}" not indexed for "${expectedFileName}" after ${retryLimit} retries`;
6719
+ logger.error(message);
6720
+ throw new Error(message);
6721
+ }
6722
+ await Utils.delayInSeconds(1);
6723
+ }
6724
+ } while (!found);
6725
+ logger.info(`waitForContentIndexing: content "${contentTerm}" is indexed for "${expectedFileName}".`);
6726
+ }
6745
6727
  }
6746
6728
 
6747
6729
  /*!