Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update folv tests acceptance #1612

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

BobrikovMikhail
Copy link
Contributor

@BobrikovMikhail BobrikovMikhail commented Aug 6, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced asynchronous handling in various acceptance tests for improved reliability and clarity.
  • Bug Fixes

    • Improved error handling and flow control in tests by replacing nested promise handling with async/await syntax.
  • Documentation

    • Updated test descriptions to reflect changes in asynchronous operations and structure.
  • Refactor

    • Streamlined test logic by removing unnecessary nesting and callbacks, improving readability and maintainability across multiple test files.

Copy link

sonarcloud bot commented Aug 6, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
32.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

{ "ruleId": "ember/no-test-import-export", "line": 1, "column": 1 },
{ "ruleId": "ember/no-test-and-then", "line": 27, "column": 9 }
{ "ruleId": "no-unused-vars", "line": 76, "column": 15 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это лучше поправить а не в исключения добавлять

],
"tests/acceptance/components/flexberry-objectlistview/folv-delete-button-in-row-test.js": [
{ "ruleId": "ember/no-test-import-export", "line": 3, "column": 1 },
{ "ruleId": "ember/no-test-and-then", "line": 29, "column": 9 }
{ "ruleId": "no-unused-vars", "line": 10, "column": 65 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это тоже

],
"tests/acceptance/components/flexberry-objectlistview/folv-paging-dropdown-test.js": [
{ "ruleId": "ember/no-test-import-export", "line": 2, "column": 1 },
{ "ruleId": "ember/no-test-and-then", "line": 22, "column": 7 }
{ "ruleId": "no-unused-vars", "line": 1, "column": 17 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и это

],
"tests/acceptance/components/flexberry-objectlistview/folv-sorting-clear-test.js": [
{ "ruleId": "no-unused-vars", "line": 3, "column": 10 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и это

@@ -1118,13 +1090,12 @@
{ "ruleId": "ember/no-test-and-then", "line": 6, "column": 3 }
],
"tests/acceptance/components/flexberry-objectlistview/folv-sorting-test.js": [
{ "ruleId": "no-unused-vars", "line": 3, "column": 10 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и это

{ "ruleId": "ember/no-test-and-then", "line": 12, "column": 3 },
{ "ruleId": "ember/no-test-and-then", "line": 24, "column": 5 }
{ "ruleId": "no-unused-vars", "line": 3, "column": 10 },
{ "ruleId": "no-unused-vars", "line": 4, "column": 18 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и тут обе строки

let result = await store.query(modelName, builder.build());
await visit(path + '?perPage=' + result.meta.count);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

какой-то странный пробел

@@ -1,109 +1,101 @@
import { run } from '@ember/runloop';
import {all} from 'rsvp';
import $ from 'jquery';
import RSVP from 'rsvp';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этот кажется не нужен


let resolvedPromises;
run(() => {
resolvedPromises = RSVP.all(promises);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

просто all

Copy link

coderabbitai bot commented Oct 23, 2024

Walkthrough

The pull request introduces comprehensive updates to various test files in an Ember.js application, focusing on enhancing asynchronous operations by adopting async/await syntax. This includes modifying the executeTest function signatures to be asynchronous, allowing for better control flow and readability. Additionally, the .eslint-todo-errors.json file is updated to reflect new and resolved linting rule violations across multiple components, controllers, routes, and tests, indicating ongoing efforts to improve code quality.

Changes

File Path Change Summary
.eslint-todo-errors.json Added new linting errors and removed resolved ones, consolidating similar errors for better reporting.
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-cancel-test.js Updated executeTest to async, improved async handling with await for various operations.
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js Updated executeTest to async, enhanced async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-test.js Updated executeTest to async, improved async handling with await for promises and queries.
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-data-cancel-test.js Updated executeTest to async, enhanced async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-data-immediately-test.js Updated executeTest to async, improved async handling with await for promises.
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-test.js Updated executeTest to async, enhanced async handling with await for various operations.
tests/acceptance/components/flexberry-objectlistview/folv-delete-button-in-row-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-delete-button-test.js Updated executeTest to async, enhanced async handling with await for promises and queries.
tests/acceptance/components/flexberry-objectlistview/folv-getCellComponent-test.js Updated executeTest to async, improved async handling with await for various operations.
tests/acceptance/components/flexberry-objectlistview/folv-limit-function-test.js Updated executeTest to async, improved async handling with await for promises and queries.
tests/acceptance/components/flexberry-objectlistview/folv-locales-test.js Updated executeTest and toolbarBtnTextAssert to async, improved async handling with await.
tests/acceptance/components/flexberry-objectlistview/folv-open-newform-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-paging-dropdown-test.js Updated executeTest to async, improved async handling with await for promises and queries.
tests/acceptance/components/flexberry-objectlistview/folv-paging-navigation-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-sorting-by-computable-field-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-sorting-clear-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-sorting-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-sorting-with-default-setting-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-toolbar-custom-components-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-user-button-test.js Updated executeTest to async, improved async handling with await for operations.
tests/acceptance/components/flexberry-objectlistview/folv-user-settings-test.js Updated executeTest, checkWithDisabledUserSettings, and deleteUserSetting to async; improved async handling.
tests/acceptance/components/flexberry-objectlistview/folv-wrapper-projection-test.js Updated executeTest to async, improved async handling with await for operations.

Poem

In a world where code does hop,
With async waits, we reach the top.
Errors fixed, the tests now gleam,
Linting rules, a coder's dream!
Hooray for changes, big and small,
For every rabbit, let's code for all! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fdcaa3d and 6180170.

📒 Files selected for processing (23)
  • .eslint-todo-errors.json (10 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-cancel-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-data-cancel-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-data-immediately-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-delete-button-in-row-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-delete-button-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-getCellComponent-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-limit-function-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-locales-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-open-newform-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-paging-dropdown-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-paging-navigation-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-sorting-by-computable-field-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-sorting-clear-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-sorting-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-sorting-with-default-setting-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-toolbar-custom-components-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-user-button-test.js (1 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-user-settings-test.js (4 hunks)
  • tests/acceptance/components/flexberry-objectlistview/folv-wrapper-projection-test.js (1 hunks)
🧰 Additional context used
🔇 Additional comments (29)
tests/acceptance/components/flexberry-objectlistview/folv-open-newform-test.js (1)

3-9: LGTM! Clean async/await conversion.

The conversion from callback-based to async/await syntax improves readability and maintainability. The asynchronous operations are properly awaited.

tests/acceptance/components/flexberry-objectlistview/folv-user-button-test.js (1)

1-3: LGTM!

The addition of the settled helper import is appropriate for managing asynchronous operations in the test.

tests/acceptance/components/flexberry-objectlistview/folv-locales-test.js (1)

9-14: LGTM: Proper async/await implementation

The conversion to async/await syntax and proper awaiting of the visit operation improves test reliability and readability.

tests/acceptance/components/flexberry-objectlistview/folv-toolbar-custom-components-test.js (1)

6-6: LGTM! Good async/await adoption

The update to make the test function async is correct and follows modern testing practices.

tests/acceptance/components/flexberry-objectlistview/folv-sorting-by-computable-field-test.js (3)

7-47: LGTM on the overall test structure and async/await migration

The test has been successfully migrated to use async/await syntax, making it more readable and maintainable. The test flow and assertions are well-structured and comprehensive, covering ascending, descending, and reset sorting scenarios.


19-23: Consider using async/await with store operations more consistently

The store query is properly awaited, but accessing the array and getting properties could potentially be asynchronous operations. Consider using await for these operations as well if they return promises.

#!/bin/bash
# Check if similar patterns exist in other test files
rg "store\.query.*\.toArray" --type js

36-38: 🛠️ Refactor suggestion

Improve test reliability with better selectors

Using array index [9] for selecting elements is fragile and could break if the structure changes. Consider using more specific data-test-* attributes for reliable element selection.

- let $cellText = $('div.oveflow-text')[9];
+ let cellText = find('[data-test-comments-count]');
tests/acceptance/components/flexberry-objectlistview/folv-sorting-with-default-setting-test.js (2)

10-14: ⚠️ Potential issue

Add missing await for click operation.

The click operation should be awaited to ensure proper test synchronization.

- await click('.ui.clear-sorting-button');
+ await click('.ui.clear-sorting-button');

Likely invalid or redundant comment.


10-54: Consider adding edge case test coverage.

While the test covers the basic sorting functionality, consider adding test cases for:

  1. Sorting with empty data
  2. Sorting with null/undefined values
  3. Sorting with special characters
  4. Performance with large datasets
tests/acceptance/components/flexberry-objectlistview/folv-paging-dropdown-test.js (2)

9-13: LGTM: Good modernization of test setup!

The conversion to async/await and use of const for immutable variables follows modern JavaScript best practices.


9-61: Verify coverage of edge cases for paging dropdown.

While this test covers the basic functionality, we should ensure edge cases are covered elsewhere.

✅ Verification successful

Let me check the content of these files to better understand the edge case coverage.


Based on the gathered information, I can now provide a final response about the test coverage:

Paging dropdown test coverage is comprehensive across multiple test files

The codebase has thorough test coverage for paging functionality including:

  • Basic paging dropdown functionality in folv-paging-dropdown-test.js
  • User settings for perPage values in folv-user-settings-on-multi-list-test.js with multiple test cases (9, 12, 15 items)
  • Navigation between pages in folv-paging-navigation-test.js covering:
    • First/last page transitions
    • Ellipsis handling
    • Active page states
    • Multiple page sizes

The original concern about edge cases is addressed through:

  1. Tests with varying page sizes in user settings
  2. Navigation tests that handle boundary conditions
  3. Multiple list configurations tested simultaneously
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for related paging dropdown tests
echo "Searching for related paging dropdown tests..."
rg -l "paging.*dropdown" tests/acceptance/components/flexberry-objectlistview/

# Search for specific edge case scenarios
echo "Searching for edge case handling..."
rg -l "perPage.*0|perPage.*null|perPage.*undefined" tests/acceptance/components/flexberry-objectlistview/

Length of output: 969


Script:

#!/bin/bash
# Check content of limit function test which might handle edge cases
echo "=== Content of folv-limit-function-test.js ==="
rg -A 10 "perPage" tests/acceptance/components/flexberry-objectlistview/folv-limit-function-test.js

echo -e "\n=== Content of user settings test ==="
rg -A 10 "perPage" tests/acceptance/components/flexberry-objectlistview/folv-user-settings-on-multi-list-test.js

# Look for any explicit paging-related assertions
echo -e "\n=== Paging-related assertions ==="
rg "assert.*page|assert.*perPage" tests/acceptance/components/flexberry-objectlistview/

Length of output: 11250

tests/acceptance/components/flexberry-objectlistview/folv-wrapper-projection-test.js (1)

6-13: LGTM: Proper async/await implementation for test setup

The navigation sequence is well-structured with proper async/await usage for both visit and click operations.

tests/acceptance/components/flexberry-objectlistview/folv-sorting-clear-test.js (2)

10-10: LGTM: Appropriate async/await adoption

The function signature update properly enables async/await usage throughout the test, improving readability and control flow.


13-14: Verify clear button click timing

While the await usage is correct, consider adding a wait condition after clicking the clear-sorting-button to ensure the UI has fully updated before proceeding with assertions.

tests/acceptance/components/flexberry-objectlistview/folv-sorting-test.js (2)

10-20: LGTM: Test setup properly uses async/await pattern

The conversion to async/await improves readability and maintains proper test flow control.


47-53: ⚠️ Potential issue

Verify DOM element existence before assertions

The test assumes DOM elements will always exist, which could lead to fragile tests. Consider adding existence checks.

Add null checks before assertions:

 $thead = $('th.dt-head-left', $olv)[0];
 let $ord = $('.object-list-view-order-icon', $thead);
 let $divOrd = $('div', $ord);
+assert.ok($divOrd.length, 'Order icon div exists');
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-test.js (1)

9-77: Overall implementation looks good!

The test successfully validates the deletion functionality with proper async/await usage and covers all necessary scenarios. The suggested improvements above are mainly about code organization and maintainability, but the core functionality is solid.

tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-test.js (1)

17-25: LGTM! Clean async/await implementation

The conversion to async/await syntax is well-implemented, properly handling both the record creation and store operations.

tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js (1)

25-25: ⚠️ Potential issue

Add missing await for visit() helper

The visit() helper is asynchronous and should be properly awaited.

- await visit(path + '?perPage=' + result.meta.count);
+ await visit(path + `?perPage=${result.meta.count}`);

Likely invalid or redundant comment.

tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-data-cancel-test.js (1)

9-14: LGTM: Clean test setup with proper async conversion

The test setup is well-structured with clear variable naming and proper async/await implementation.

tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-data-immediately-test.js (2)

9-80: Consider adding edge case tests

While the test covers the basic flow, it might miss important edge cases:

  1. Concurrent deletion attempts
  2. Network failures during deletion
  3. Server-side validation failures
#!/bin/bash
# Check for existing error handling tests
rg -A 5 "test.*error.*delete|test.*fail.*delete" tests/acceptance/components/flexberry-objectlistview/

Consider adding additional test cases to cover these scenarios for better reliability.


44-55: 🛠️ Refactor suggestion

Potential race condition in parallel delete operations

While using Promise.all for parallel delete operations is efficient, it might cause race conditions or state inconsistencies. Also, the code uses jQuery for DOM manipulation where modern test helpers would be more appropriate.

Consider sequential deletion for better reliability:

-    let clickPromises = [];
-    $rows().forEach(function(element)  {
-      let nameRecord = $.trim(element.children[1].innerText);
-      if (nameRecord.indexOf(uuid) >= 0) {
-        let $deleteBtnInRow = $('.object-list-view-row-delete-button', element)[0];
-        clickPromises.push(click($deleteBtnInRow));
-      }
-    });
-    await Promise.all(clickPromises);
+    const rows = await findAll('table.object-list-view tbody tr');
+    for (const row of rows) {
+      const nameRecord = row.textContent.trim();
+      if (nameRecord.includes(uuid)) {
+        await click(row.querySelector('.object-list-view-row-delete-button'));
+      }
+    }
tests/acceptance/components/flexberry-objectlistview/folv-getCellComponent-test.js (4)

3-3: LGTM: Appropriate test helper import added

The addition of settled from @ember/test-helpers is appropriate for managing async operations in modern Ember tests.


8-14: LGTM: Proper async/await test setup

The conversion to async/await pattern is well implemented:

  • Correct async function declaration
  • Proper awaiting of the visit operation
  • Assertions are correctly positioned after the awaited operations

15-17: LGTM: Proper async locale loading

The locale loading is correctly handled with async/await and well-documented.


57-61: LGTM: Proper async refresh function implementation

The refresh function is correctly converted to use async/await pattern.

tests/acceptance/components/flexberry-objectlistview/folv-delete-button-test.js (1)

14-20: LGTM! Well-structured test setup

Good improvements:

  • Proper async/await syntax
  • Using const for immutable values
  • Clear test structure with explicit assertions count
tests/acceptance/components/flexberry-objectlistview/folv-user-settings-test.js (1)

6-7: LGTM! Modern import syntax and constant declarations.

The changes improve code quality by:

  • Using named imports instead of the Ember global object
  • Converting variables to constants where appropriate

Also applies to: 12-14

.eslint-todo-errors.json (1)

Line range hint 1007-1108: Address previously identified issues before suppressing new ones

Previous review comments from TeterinaSvetlana identified specific issues that should be fixed rather than suppressed. Maintaining consistency with this guidance, consider addressing these identified issues first before adding new suppressions.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

🛑 Comments failed to post (54)
tests/acceptance/components/flexberry-objectlistview/folv-open-newform-test.js (1)

6-6: 🛠️ Refactor suggestion

Consider using modern Ember service injection.

Instead of using the private __container__ lookup, consider using Ember's dependency injection pattern for better maintainability and testing.

- const controller = app.__container__.lookup('controller:' + currentRouteName());
+ const controller = this.owner.lookup('controller:' + currentRouteName());

Or better yet, if you're using newer versions of Ember:

- const controller = app.__container__.lookup('controller:' + currentRouteName());
+ import { getOwner } from '@ember/application';
+ const controller = getOwner(this).lookup('controller:' + currentRouteName());

Committable suggestion was skipped due to low confidence.

tests/acceptance/components/flexberry-objectlistview/folv-user-button-test.js (3)

24-27: 🛠️ Refactor suggestion

Modernize Ember syntax and improve assertion messages.

The code uses deprecated get syntax and lacks descriptive assertion messages.

-  assert.notOk(controller.get('modelFromClickedRow'));
+  assert.notOk(controller.modelFromClickedRow, 'No row should be selected initially');
   await click('.ui.button > .bug.icon:first');
   await settled;
-  assert.equal(controller.get('modelFromClickedRow.id'), controller.get('model.firstObject.id'))
+  assert.equal(controller.modelFromClickedRow?.id, controller.model.firstObject?.id, 'Clicked row model should match the first record');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  assert.notOk(controller.modelFromClickedRow, 'No row should be selected initially');
  await click('.ui.button > .bug.icon:first');
  await settled;
  assert.equal(controller.modelFromClickedRow?.id, controller.model.firstObject?.id, 'Clicked row model should match the first record');

11-11: 🛠️ Refactor suggestion

Use template literals for controller lookup path.

Modern JavaScript favors template literals over string concatenation.

-  let controller = app.__container__.lookup('controller:' + currentRouteName());
+  let controller = app.__container__.lookup(`controller:${currentRouteName()}`);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  let controller = app.__container__.lookup(`controller:${currentRouteName()}`);

14-22: ⚠️ Potential issue

Inconsistent async operation handling.

The test mixes async/await with the legacy andThen pattern and has an unhandled promise from click.

Apply these changes to maintain consistent async handling:

  await click('.toggle-hi-button');

  // First click.
  await click('.test-click-button');
  assert.equal(controller.clickCounter, 2, 'Test button was pressed');

  // Second click.
-  click('.test-click-button');
-  andThen(() => assert.equal(controller.clickCounter, 3, 'Test button was pressed'));
+  await click('.test-click-button');
+  assert.equal(controller.clickCounter, 3, 'Test button was pressed');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  await click('.toggle-hi-button');

    // First click.
  await click('.test-click-button');
  assert.equal(controller.clickCounter, 2, 'Test button was pressed');

  // Second click.
  await click('.test-click-button');
  assert.equal(controller.clickCounter, 3, 'Test button was pressed');
tests/acceptance/components/flexberry-objectlistview/folv-locales-test.js (1)

16-22: 🛠️ Refactor suggestion

Consider using modern Ember test helpers

While the async conversion is good, consider replacing jQuery selectors with modern @ember/test-helpers for better maintainability and reliability:

- async function toolbarBtnTextAssert(currentLocale) {
-   assert.notEqual($toolBarButtons.length, 0, 'buttons in toolbar exists');
-   assert.equal($toolBarButtons[0].innerText.trim(), get(currentLocale, 'components.olv-toolbar.refresh-button-text'), 'button refresh exist');
-   assert.equal($toolBarButtons[1].innerText.trim(), get(currentLocale, 'components.olv-toolbar.add-button-text'), 'button create exist');
-   assert.equal($toolBarButtons[2].innerText.trim(), get(currentLocale, 'components.olv-toolbar.delete-button-text'), 'button delete exist');
-   assert.equal($($toolBarButtons[2]).hasClass('disabled'), true, 'button delete is disabled');
+ async function toolbarBtnTextAssert(currentLocale) {
+   const buttons = await findAll('.ui.secondary.menu button');
+   assert.ok(buttons.length > 0, 'Toolbar buttons should exist');
+   
+   assert.dom(buttons[0]).hasText(
+     get(currentLocale, 'components.olv-toolbar.refresh-button-text'),
+     'Refresh button should have correct text'
+   );
+   assert.dom(buttons[1]).hasText(
+     get(currentLocale, 'components.olv-toolbar.add-button-text'),
+     'Add button should have correct text'
+   );
+   assert.dom(buttons[2]).hasText(
+     get(currentLocale, 'components.olv-toolbar.delete-button-text'),
+     'Delete button should have correct text'
+   );
+   assert.dom(buttons[2]).hasClass('disabled', 'Delete button should be disabled');
}

Committable suggestion was skipped due to low confidence.

tests/acceptance/components/flexberry-objectlistview/folv-toolbar-custom-components-test.js (2)

14-22: 🛠️ Refactor suggestion

Consider using modern Ember test selectors

The test currently uses jQuery selectors for DOM manipulation. Consider using data-test-* selectors with @ember/test-helpers for better maintainability and alignment with modern Ember testing practices.

Example refactor:

-  let $toolbar = $('.flexberry-olv-toolbar');
-  let $dropdown = $toolbar.children('.flexberry-dropdown');
+  let toolbar = find('[data-test-olv-toolbar]');
+  let dropdown = find('[data-test-olv-dropdown]');

Also update your template to include these attributes:

<div data-test-olv-toolbar class="flexberry-olv-toolbar">
  <div data-test-olv-dropdown class="flexberry-dropdown">

6-44: 💡 Codebase verification

Based on the comprehensive results, I can now provide a final response about the async patterns in the test suite:

Async patterns need standardization across test files

The verification revealed mixed patterns that need attention:

  • Several files still use the outdated andThen pattern
  • Some click operations are not properly awaited
  • Inconsistent usage of settled() after async operations

Key findings:

  • Many newer tests correctly use async/await with settled()
  • The file under review (folv-toolbar-custom-components-test.js) follows modern practices
  • However, there are numerous files that need updates to follow the same patterns

The codebase would benefit from standardizing on modern async patterns:

  1. Replace all andThen usage with async/await
  2. Ensure all click operations are properly awaited
  3. Consistently use settled() after user interactions
  4. Update test declarations to use async functions where needed

This standardization will improve test reliability and maintainability.

🔗 Analysis chain

Verify async test helper usage across the test suite

The async patterns in this file look good, but let's ensure consistent usage across related test files.


Let me generate a new script to better verify the async patterns, particularly focusing on the click interactions since the previous regex had issues.

The previous results showed that there are several files using the outdated andThen pattern, but we need to verify the current patterns being used with click interactions and settled usage to make a complete assessment.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential inconsistent async patterns in test files
echo "Checking for potentially missing await statements..."
rg "visit\([^)]+\)[^;]" "tests/acceptance"

echo "Checking for outdated andThen usage..."
rg "andThen\(" "tests/acceptance"

echo "Checking for consistent settled usage after interactions..."
rg "click\([^)]+\);(?!.*settled)" "tests/acceptance"

Length of output: 10231


Script:

#!/bin/bash
# Check for click interactions without await
echo "Checking for non-awaited click interactions..."
rg "click\([^)]+\);" tests/acceptance

# Check for proper async/await usage in test files
echo -e "\nChecking for proper async test usage..."
rg "test\(['\"].*['\"],\s*(async)?\s*\([^)]*\)\s*=>" tests/acceptance

# Check for proper settled usage
echo -e "\nChecking for settled usage..."
rg "settled\(\)" tests/acceptance

Length of output: 16276

tests/acceptance/components/flexberry-objectlistview/folv-sorting-by-computable-field-test.js (2)

30-32: ⚠️ Potential issue

Add await to click operation in refreshFunction

The click operation inside the async refresh function should be awaited to ensure proper handling of asynchronous behavior.

let refreshFunction = async function() {
-  click($thead);
+  await click($thead);
};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  let refreshFunction =  async function() {
  await click($thead);
  };

25-26: 🛠️ Refactor suggestion

Consider migrating from jQuery selectors to modern testing selectors

The test is using jQuery selectors ($) for DOM traversal. Consider using modern Ember test helpers like find() or findAll() for better maintainability and alignment with current best practices.

- let $olv = $('.object-list-view ');
- let $thead = $('th.dt-head-left', $olv)[9];
+ let thead = findAll('.object-list-view th.dt-head-left')[9];

Committable suggestion was skipped due to low confidence.

tests/acceptance/components/flexberry-objectlistview/folv-sorting-with-default-setting-test.js (2)

22-28: ⚠️ Potential issue

Improve refresh function implementation.

Two issues need to be addressed:

  1. The click operation inside the refresh function should be awaited
  2. The run loop wrapper is unnecessary for async functions
- await run(async () => {
- await loadingLocales('ru', app);
- // Refresh function.
- let refreshFunction = async function () {
-   let $thead = $('th.dt-head-left', $olv)[0];
-   click($($thead));
- };
+ await loadingLocales('ru', app);
+ 
+ // Refresh function.
+ let refreshFunction = async function () {
+   let $thead = $('th.dt-head-left', $olv)[0];
+   await click($($thead));
+ };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  await loadingLocales('ru', app);
  
  // Refresh function.
  let refreshFunction = async function () {
    let $thead = $('th.dt-head-left', $olv)[0];
    await click($($thead));
  };

30-36: 🛠️ Refactor suggestion

Refactor repeated jQuery selectors.

The jQuery selectors for header elements are duplicated throughout the test. Consider extracting them into helper functions for better maintainability.

+ const getHeaderElements = ($olv) => {
+   const $thead = $('th.dt-head-left', $olv)[0];
+   const $ord = $('.object-list-view-order-icon', $thead);
+   const $divOrd = $('div', $ord);
+   return { $thead, $ord, $divOrd };
+ };

- let $thead = $('th.dt-head-left', $olv)[0];
- let $ord = $('.object-list-view-order-icon', $thead);
- let $divOrd = $('div', $ord);
+ const { $thead, $ord, $divOrd } = getHeaderElements($olv);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  const getHeaderElements = ($olv) => {
    const $thead = $('th.dt-head-left', $olv)[0];
    const $ord = $('.object-list-view-order-icon', $thead);
    const $divOrd = $('div', $ord);
    return { $thead, $ord, $divOrd };
  };

  const { $thead, $ord, $divOrd } = getHeaderElements($olv);

  assert.equal($divOrd.attr('title'), get(I18nRuLocale, 'components.object-list-view.sort-ascending'), 'title is Order ascending');
  assert.equal($('.icon', $divOrd).hasClass('ascending'), true, 'sorting symbol added');
  assert.equal(controller.sort, '+name', 'up sorting in URL');
tests/acceptance/components/flexberry-objectlistview/folv-paging-dropdown-test.js (2)

38-47: 🛠️ Refactor suggestion

Consider making the timeout configurable and simplifying the async structure.

The hardcoded 500ms timeout could lead to flaky tests on slower systems. Also, the Promise/later combination could be simplified.

-      let timeout = 500;
-      return new Promise((resolve) => {
-        later(async() => {
-          let menuIsVisible = $menu.hasClass('visible');
-          assert.strictEqual(menuIsVisible, true, 'menu is visible');
-          let $choosedItem = $('.item', $menu);
-          await click($choosedItem[1]);
-          resolve();
-        }, timeout);
-      });
+      const DROPDOWN_ANIMATION_TIMEOUT = 500; // Consider moving to test config
+      await new Promise(resolve => later(resolve, DROPDOWN_ANIMATION_TIMEOUT));
+      
+      let menuIsVisible = $menu.hasClass('visible');
+      assert.strictEqual(menuIsVisible, true, 'menu is visible');
+      let $choosedItem = $('.item', $menu);
+      await click($choosedItem[1]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      const DROPDOWN_ANIMATION_TIMEOUT = 500; // Consider moving to test config
      await new Promise(resolve => later(resolve, DROPDOWN_ANIMATION_TIMEOUT));
      
      let menuIsVisible = $menu.hasClass('visible');
      assert.strictEqual(menuIsVisible, true, 'menu is visible');
      let $choosedItem = $('.item', $menu);
      await click($choosedItem[1]);

28-34: 🛠️ Refactor suggestion

Consider using data-test- attributes for more reliable selectors.*

The jQuery selectors based on classes like '.flexberry-dropdown.compact' and '.menu' could be fragile if styles change. Consider using dedicated test attributes.

-      let $folvPerPageButton = $('.flexberry-dropdown.compact');
-      let $menu = $('.menu', $folvPerPageButton);
+      let $folvPerPageButton = $('[data-test-per-page-dropdown]');
+      let $menu = $('[data-test-dropdown-menu]', $folvPerPageButton);

Committable suggestion was skipped due to low confidence.

tests/acceptance/components/flexberry-objectlistview/folv-wrapper-projection-test.js (2)

14-16: 🛠️ Refactor suggestion

Simplify projection name retrieval

The arrow function wrapper for getting the projection name adds unnecessary complexity.

Consider simplifying to a direct property getter:

-  let projectionName = () => { return get(controller, 'modelProjection'); };
+  const getProjectionName = () => get(controller, 'modelProjection');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  let controller = app.__container__.lookup('controller:' + currentRouteName());
  const getProjectionName = () => get(controller, 'modelProjection');


37-48: 🛠️ Refactor suggestion

Improve projection attribute verification logic

The current implementation using a mutable flag and forEach could be more functional.

Consider refactoring to use array methods:

-  let flag = true;
-  /* eslint-disable no-unused-vars */
-  Object.keys(attrs).forEach((element, index, array) => {
-    if (attrs[element].kind !== 'hasMany') {
-      flag = flag && ($.trim(dtHeadTable[index].innerText) === attrs[element].caption);
-    }
-  });
-  /* eslint-enable no-unused-vars */
-  assert.ok(flag, 'projection = columns names');
+  const columnsMatch = Object.entries(attrs)
+    .filter(([_, attr]) => attr.kind !== 'hasMany')
+    .every(([_, attr], index) => 
+      $.trim(dtHeadTable[index].innerText) === attr.caption
+    );
+  assert.ok(columnsMatch, 'projection columns match attribute captions');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  await loadingLocales('en', app.__container__.owner);
  // Check projectionName.
  let attrs = projectionName().attributes;
  const columnsMatch = Object.entries(attrs)
    .filter(([_, attr]) => attr.kind !== 'hasMany')
    .every(([_, attr], index) => 
      $.trim(dtHeadTable[index].innerText) === attr.caption
    );
  assert.ok(columnsMatch, 'projection columns match attribute captions');
tests/acceptance/components/flexberry-objectlistview/folv-sorting-clear-test.js (2)

39-43: 🛠️ Refactor suggestion

Consider making the refresh function more reusable

The refresh function could be moved to the shared test utilities and made more generic to handle different header selections.

-  let refreshFunction =  async function() {
-    await click( $thead);
-  };
+  let refreshFunction = async function(selector) {
+    await click(selector || $thead);
+  };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  // Refresh function.
  let refreshFunction = async function(selector) {
    await click(selector || $thead);
  };
  await refreshListByFunction(refreshFunction, controller)

54-57: 🛠️ Refactor suggestion

Use data-test- attributes for selectors*

Consider using data-test-* attributes instead of class selectors for test stability. Classes might change for styling purposes, breaking the tests.

-    let $clearButton = $('.clear-sorting-button');
+    let $clearButton = $('[data-test-clear-sorting]');

Add the attribute to your clear button component:

-<button class="ui clear-sorting-button">
+<button class="ui clear-sorting-button" data-test-clear-sorting>

Committable suggestion was skipped due to low confidence.

tests/acceptance/components/flexberry-objectlistview/folv-limit-function-test.js (2)

17-23: 🛠️ Refactor suggestion

Improve variable naming and error handling

  1. The variable result is reused which reduces code clarity
  2. The empty data check should be performed before accessing the array elements
-  let result = await store.query(modelName, builder1.build());
-  let arr = result.toArray();
+  let queryResult1 = await store.query(modelName, builder1.build());
+  let arr = queryResult1.toArray();
   count = arr.length;
   let builder2 = new Builder(store).from(modelName).selectByProjection('SuggestionL').where('address', FilterOperator.Neq, '');
-  result = await store.query(modelName, builder2.build());
-  arr = result.toArray();
+  let queryResult2 = await store.query(modelName, builder2.build());
+  arr = queryResult2.toArray();
+  
+  if (arr.length < 2) {
+    assert.ok(false, 'Load empty data');
+    return;
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  let builder1 = new Builder(store).from(modelName).selectByProjection('SuggestionL');
  let queryResult1 = await store.query(modelName, builder1.build());
  let arr = queryResult1.toArray();
  count = arr.length;
  let builder2 = new Builder(store).from(modelName).selectByProjection('SuggestionL').where('address', FilterOperator.Neq, '');
  let queryResult2 = await store.query(modelName, builder2.build());
  arr = queryResult2.toArray();
  
  if (arr.length < 2) {
    assert.ok(false, 'Load empty data');
    return;
  }

43-64: 🛠️ Refactor suggestion

Simplify async handling by removing unnecessary assert.async()

Since the test is using async/await, the assert.async() calls and their corresponding done calls are no longer needed. This will make the code cleaner and easier to understand.

-  let done1 = assert.async();
   await refreshListByFunction(refreshFunction, controller)
   let resultText = $('.oveflow-text')[0];
   assert.notEqual(controller.model.content.length, count, 'Folv load with object current count');
   assert.equal(resultText.innerText, result1, 'Correct result afther apply limitFunction');

   controller.set('limitFunction', result2);

-  let done2 = assert.async();
   await refreshListByFunction(refreshFunction, controller);
   resultText = $('.oveflow-text')[0];
   assert.notEqual(controller.model.content.length, count, 'Folv load with current object count');
   assert.equal(resultText.innerText, result2, 'Correct result afther apply limitFunction');

   controller.set('limitFunction', undefined);

-  let done3 = assert.async();
   await refreshListByFunction(refreshFunction, controller);
   assert.equal(controller.model.content.length, count, 'Folv load with current object count');
-  done3();
-  done2();
-  done1();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  await refreshListByFunction(refreshFunction, controller)
  let resultText = $('.oveflow-text')[0];
  assert.notEqual(controller.model.content.length, count, 'Folv load with object current count');
  assert.equal(resultText.innerText, result1, 'Correct result afther apply limitFunction');

  controller.set('limitFunction', result2);

  await refreshListByFunction(refreshFunction, controller);
  resultText = $('.oveflow-text')[0];
  assert.notEqual(controller.model.content.length, count, 'Folv load with current object count');
  assert.equal(resultText.innerText, result2, 'Correct result afther apply limitFunction');

  controller.set('limitFunction', undefined);

  await refreshListByFunction(refreshFunction, controller);
  assert.equal(controller.model.content.length, count, 'Folv load with current object count');
tests/acceptance/components/flexberry-objectlistview/folv-delete-button-in-row-test.js (4)

18-27: ⚠️ Potential issue

Move visit() outside of run()

The visit() helper should not be wrapped in run() as it manages its own runloop. This could cause timing issues.

- await run(async () => {
-   let newRecord = store.createRecord(modelName, { name: uuid });
-   await newRecord.save();
-   addDataForDestroy(newRecord);
-   let builder = new Builder(store).from(modelName).count();
-   let result = await store.query(modelName, builder.build());
-   await visit(path + '?perPage=' + result.meta.count);
- });

+ await run(async () => {
+   let newRecord = store.createRecord(modelName, { name: uuid });
+   await newRecord.save();
+   addDataForDestroy(newRecord);
+ });
+ 
+ let builder = new Builder(store).from(modelName).count();
+ let result = await store.query(modelName, builder.build());
+ await visit(path + '?perPage=' + result.meta.count);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  await run(async () => {
    let newRecord = store.createRecord(modelName, { name: uuid });
    await newRecord.save();
    addDataForDestroy(newRecord);
  });
  
  let builder = new Builder(store).from(modelName).count();
  let result = await store.query(modelName, builder.build());
  await visit(path + '?perPage=' + result.meta.count);

34-44: 🛠️ Refactor suggestion

Consider using modern test helpers instead of jQuery

The test heavily relies on jQuery selectors which is discouraged in modern Ember testing. Consider using @ember/test-helpers functions like find() and findAll().

- let $folvContainer = $(olvContainerClass);
- let $rows = () => { return $(trTableClass, $folvContainer).toArray(); };
- let recordIsForDeleting = await run(() => {
-   return $rows().reduce((sum, element) => {
-     let nameRecord = $.trim(element.children[1].innerText);
-     let flag = nameRecord.indexOf(uuid) >= 0;
-     return sum + flag;
-   }, 0);
- });

+ const rows = await findAll(`${olvContainerClass} ${trTableClass}`);
+ const matchingRecordsCount = rows.filter(row => 
+   row.children[1].textContent.trim().includes(uuid)
+ ).length;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  const rows = await findAll(`${olvContainerClass} ${trTableClass}`);
  const matchingRecordsCount = rows.filter(row => 
    row.children[1].textContent.trim().includes(uuid)
  ).length;

48-59: 🛠️ Refactor suggestion

Improve delete operation handling

Several improvements can be made to the delete operation:

  1. Remove unnecessary eslint-disable comments
  2. Use modern test helpers for button selection
  3. Consider adding a small delay between deletes to prevent potential race conditions
- /* eslint-disable no-unused-vars */
- let clickPromises = [];
- $rows().forEach(function(element) {
-   let nameRecord = $.trim(element.children[1].innerText);
-   if (nameRecord.indexOf(uuid) >= 0) {
-     let $deleteBtnInRow = $('.object-list-view-row-delete-button', element)[0];
-     clickPromises.push(run(() => click($deleteBtnInRow)));
-   }
- });
- /* eslint-enable no-unused-vars */
- await Promise.all(clickPromises);

+ const rows = await findAll(`${olvContainerClass} ${trTableClass}`);
+ for (const row of rows) {
+   const nameRecord = row.children[1].textContent.trim();
+   if (nameRecord.includes(uuid)) {
+     const deleteButton = row.querySelector('.object-list-view-row-delete-button');
+     await click(deleteButton);
+     await settled(); // Ensure each delete completes before next
+   }
+ }

Committable suggestion was skipped due to low confidence.


71-80: 🛠️ Refactor suggestion

Simplify store verification logic

The current implementation uses arbitrary timeouts and complex Promise nesting. Consider using settled() or waitFor() instead.

- let timeout = 500;
- await new Promise(resolve => {
-   run(() => {
-     later(async () => {
-       let result = await store.query(modelName, builder2.build());
-       assert.notOk(result.meta.count, 'record \'' + uuid + '\' not found in store');
-       resolve();
-     }, timeout);
-   });
- });

+ await settled();
+ const result = await store.query(modelName, builder2.build());
+ assert.notOk(result.meta.count, `record '${uuid}' not found in store`);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  // Check that the records have been removed into store.
  let builder2 = new Builder(store, modelName).where('name', FilterOperator.Eq, uuid).count();
  await settled();
  const result = await store.query(modelName, builder2.build());
  assert.notOk(result.meta.count, `record '${uuid}' not found in store`);
tests/acceptance/components/flexberry-objectlistview/folv-sorting-test.js (3)

55-69: 🛠️ Refactor suggestion

Consider extracting repeated assertion patterns

The test repeats similar assertion patterns for different sorting states. This could be refactored into a helper function for better maintainability.

Create a helper function:

async function assertSortingState(assert, controller, expectedTitle, expectedIconClass, expectedSort, expectedOrderBy) {
  const $thead = $('th.dt-head-left', $olv)[0];
  const $ord = $('.object-list-view-order-icon', $thead);
  const $divOrd = $('div', $ord);

  assert.equal($divOrd.attr('title'), expectedTitle, `title is ${expectedTitle}`);
  assert.equal($('.icon', $divOrd).hasClass(expectedIconClass), true, 'correct sorting icon');
  assert.equal(controller.sort, expectedSort, 'correct sorting in URL');
  
  const isTrue = await checkSortingList(store, projectionName, $olv, expectedOrderBy);
  assert.ok(isTrue, 'sorting applied correctly');
}

71-76: ⚠️ Potential issue

Add assertions for the final sorting cycle

The test verifies the sort parameter but doesn't assert the actual sorting state or icon presence in the final cycle.

Add missing assertions:

 await refreshListByFunction(refreshFunction, controller);
 assert.equal(controller.sort, null, 'no sorting in URL');
+assert.ok($thead.children[0].children.length === 1, 'sorting icon removed');
+const isTrue = await checkSortingList(store, projectionName, $olv, null);
+assert.ok(isTrue, 'sorting removed correctly');
 
 await refreshListByFunction(refreshFunction, controller);
 assert.equal(controller.sort, '+address', 'up sorting in URL');
+assert.ok($('.icon', $divOrd).hasClass("ascending"), 'sorting cycle completed correctly');

Committable suggestion was skipped due to low confidence.


23-29: 🛠️ Refactor suggestion

Consider using querySelector instead of jQuery

While the code works, modern DOM APIs like querySelector could replace jQuery selectors for better maintainability and reduced dependencies.

-let $olv = $('.object-list-view ');
-let $thead = $('th.dt-head-left', $olv)[0];
+const olv = document.querySelector('.object-list-view');
+const thead = olv.querySelector('th.dt-head-left');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  const olv = document.querySelector('.object-list-view');
  const thead = olv.querySelector('th.dt-head-left');

  let currentSorting = controller.get('computedSorting');
  if (!$.isEmptyObject(currentSorting)) {
    orderByClause = getOrderByClause(currentSorting);
  }
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-test.js (3)

44-55: 🛠️ Refactor suggestion

Simplify promise collection and remove unnecessary eslint comments.

The click promises collection can be simplified using map and the eslint comments appear unnecessary.

-    /* eslint-disable no-unused-vars */
-    let clickPromises = [];
-    $rows().forEach(function(element)  {
-      let nameRecord = $.trim(element.children[1].innerText);
-      if (nameRecord.indexOf(uuid) >= 0) {
-        let $deleteBtnInRow = $('.object-list-view-row-delete-button', element)[0];
-        clickPromises.push(click($deleteBtnInRow));
-      }
-    });
-    /* eslint-enable no-unused-vars */
+    const clickPromises = $rows()
+      .filter(element => $.trim(element.children[1].innerText).includes(uuid))
+      .map(element => click($('.object-list-view-row-delete-button', element)[0]));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    const clickPromises = $rows()
      .filter(element => $.trim(element.children[1].innerText).includes(uuid))
      .map(element => click($('.object-list-view-row-delete-button', element)[0]));

    await Promise.all(clickPromises);

69-77: 🛠️ Refactor suggestion

Improve final verification step readability.

The timeout-based verification could be made more explicit and simplified.

-  let timeout = 500;
-  await new Promise(resolve => 
-    later(async() => {
-      let result = await store.query(modelName, builder2.build());
-      assert.notOk(result.meta.count, 'record \'' + uuid + '\'not found in store');
-      resolve();
-    }), timeout);
+  const DELETION_VERIFICATION_TIMEOUT = 500; // ms - Time to wait for deletion to complete
+  await new Promise(resolve => later(resolve, DELETION_VERIFICATION_TIMEOUT));
+  
+  const result = await store.query(modelName, builder2.build());
+  assert.notOk(result.meta.count, `record '${uuid}' not found in store`);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  // Check that the records had been removed from store.
  let builder2 = new Builder(store, modelName).where('name', FilterOperator.Eq, uuid).count();
  const DELETION_VERIFICATION_TIMEOUT = 500; // ms - Time to wait for deletion to complete
  await new Promise(resolve => later(resolve, DELETION_VERIFICATION_TIMEOUT));
  
  const result = await store.query(modelName, builder2.build());
  assert.notOk(result.meta.count, `record '${uuid}' not found in store`);

29-40: 🛠️ Refactor suggestion

Refactor repeated selectors and simplify record counting.

The jQuery selectors and record counting logic could be simplified for better maintainability.

-    let olvContainerClass = '.object-list-view-container';
-    let trTableClass = 'table.object-list-view tbody tr';
-
-    let $folvContainer = $(olvContainerClass);
-    let $rows = () => { return $(trTableClass, $folvContainer).toArray(); };
-
-    // Check that the records have been added.
-    let recordIsForDeleting = $rows().reduce((sum, element) => {
-      let nameRecord = $.trim(element.children[1].innerText);
-      let flag = nameRecord.indexOf(uuid) >= 0;
-      return sum + flag;
-    }, 0);
+    const SELECTORS = {
+      container: '.object-list-view-container',
+      rows: 'table.object-list-view tbody tr'
+    };
+    
+    const getRows = () => $(SELECTORS.rows, $(SELECTORS.container)).toArray();
+    
+    // Check that the records have been added.
+    const recordIsForDeleting = getRows().some(element => 
+      $.trim(element.children[1].innerText).includes(uuid)
+    );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    const SELECTORS = {
      container: '.object-list-view-container',
      rows: 'table.object-list-view tbody tr'
    };
    
    const getRows = () => $(SELECTORS.rows, $(SELECTORS.container)).toArray();
    
    // Check that the records have been added.
    const recordIsForDeleting = getRows().some(element => 
      $.trim(element.children[1].innerText).includes(uuid)
    );
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-test.js (2)

71-82: 🛠️ Refactor suggestion

Improve timeout handling and promise chain

Two suggestions for improvement:

  1. The hardcoded timeout value should be defined as a named constant at the top of the file
  2. The promise chain with run/later could be simplified

Consider this refactor:

+ const STORE_QUERY_TIMEOUT = 500;

- let timeout = 500;
- await new Promise(resolve => {
-     run(() => {
-       later(async() => {
-         let result = await store.query(modelName, builder2.build());
-         assert.notOk(result.meta.count, 'record \'' + uuid + '\'not found in store');
-         resolve();
-       }, timeout);
-     });
-   });
+ await new Promise(resolve => 
+   later(async () => {
+     let result = await store.query(modelName, builder2.build());
+     assert.notOk(result.meta.count, 'record \'' + uuid + '\'not found in store');
+     resolve();
+   }, STORE_QUERY_TIMEOUT)
+ );

Committable suggestion was skipped due to low confidence.


29-52: 🛠️ Refactor suggestion

Consider modernizing DOM operations

The test is using jQuery for DOM manipulation which is discouraged in modern Ember applications. Consider refactoring to use @ember/test-helpers methods instead.

Example refactor:

-  let $folvContainer = $(olvContainerClass);
-  let $rows = () => { return $(trTableClass, $folvContainer).toArray(); };
+  let folvContainer = document.querySelector(olvContainerClass);
+  let rows = () => Array.from(folvContainer.querySelectorAll(trTableClass));

-  let recordIsForDeleting = $rows().reduce((sum, element) => {
-    let nameRecord = $.trim(element.children[1].innerText);
+  let recordIsForDeleting = rows().reduce((sum, element) => {
+    let nameRecord = element.children[1].innerText.trim();

Committable suggestion was skipped due to low confidence.

tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-cancel-test.js (4)

32-33: 🛠️ Refactor suggestion

Modernize DOM interaction approach.

The test heavily relies on jQuery and direct DOM manipulation which is discouraged in modern Ember testing. Consider using @ember/test-helpers methods and data-test-* selectors.

-  let $folvContainer = $(olvContainerClass);
-  let $rows = () => { return $(trTableClass, $folvContainer).toArray(); };
+  let rows = () => document.querySelectorAll('[data-test-folv-row]');
+  let getRowName = (row) => row.querySelector('[data-test-folv-name]').textContent.trim();

Also applies to: 36-40


17-22: 🛠️ Refactor suggestion

Consider removing redundant run loop wrapper.

In modern Ember.js applications with async/await, explicitly wrapping operations in run is usually unnecessary as Ember handles this automatically.

-  await run(async() => {
+  let newRecord = store.createRecord(modelName, { name: uuid });
+  await newRecord.save();
+  addDataForDestroy(newRecord);
-    let newRecord = store.createRecord(modelName, { name: uuid });
-    await newRecord.save()
-    addDataForDestroy(newRecord);
-  });

Committable suggestion was skipped due to low confidence.


71-78: ⚠️ Potential issue

Improve test stability and cleanup.

The test uses an arbitrary timeout of 500ms and nests cleanup within the timeout callback, which could lead to flaky tests and unreliable cleanup.

Consider restructuring like this:

-  let timeout = 500;
-  await new Promise(resolve => 
-      later(async() => {
-      let result = await store.query(modelName, builder2.build());
-      assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store');
-      resolve();
-      await newRecord.destroyRecord();
-    }, timeout));
+  // Wait for any pending operations to settle
+  await settled();
+  
+  let result = await store.query(modelName, builder2.build());
+  assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store');
+  
+  // Cleanup should be in a try/finally block
+  await newRecord.destroyRecord();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  // Wait for any pending operations to settle
  await settled();
  
  let result = await store.query(modelName, builder2.build());
  assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store');
  
  // Cleanup should be in a try/finally block
  await newRecord.destroyRecord();

11-11: 💡 Codebase verification

⚠️ Potential issue

Path in test file needs to be updated to match the actual route path

The test file's path contains a typo that doesn't match the actual route definitions in the application. The router.js shows that the correct path is:

components-examples/flexberry-objectlistview/before-delete-record/folv-for-before-delete-record-data-cancel

while the test uses:

components-examples/flexberry-objectlistview/before-delete-record/folv-for-before-delete-record-data-cancel

The test path should be updated to match the route definition in router.js to ensure proper test navigation.

🔗 Analysis chain

Fix typo in the test path.

The path contains a typo "recoed" which should be "record". This might indicate that the actual route path also contains this typo.

Let's verify if this typo exists in route definitions:


Let me gather more information about the route definitions to understand if this is a consistent naming pattern across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for both correct and incorrect spellings to identify mismatches
echo "Searching for route definitions with 'recoed'..."
rg -l "before-delete-recoed" 

echo "Searching for route definitions with 'record'..."
rg -l "before-delete-record"

Length of output: 928


Script:

#!/bin/bash
# Check the actual route definition in router.js
echo "Content of router.js route definition:"
rg -A 5 -B 5 "before-delete-record" tests/dummy/app/router.js

# Check if there are any route templates or components with this naming
echo -e "\nSearching for related template files:"
fd -e hbs . | rg -i "before-delete"

# Check for any controller or route files
echo -e "\nSearching for related controller/route files:"
fd -e js . | rg "(controller|route).+before-delete"

Length of output: 4671

tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js (5)

9-79: 💡 Codebase verification

Assertion count mismatch detected in test

The test declares assert.expect(5) but contains 6 actual assertions:

  1. assert.equal(currentPath(), path)
  2. assert.equal(recordIsForDeleting > 0, true, ...)
  3. assert.ok(controller.recordWasNotDelete, ...)
  4. assert.ok(recordsIsDeleteBtnInRow, ...)
  5. assert.ok(result.meta.count, ...)
  6. The initial assert.expect(5) itself counts as an assertion

This mismatch could lead to test failures or mask potential issues. The assert.expect() count should be updated to 6 to match the actual number of assertions in the test.

🔗 Analysis chain

Verify assertion count matches test expectations

The test expects 5 assertions. Let's verify that all assertion points are properly counted.


Let me gather more specific information about the assertions to understand this discrepancy better.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Count actual assertions in the test file
echo "Checking assertion count..."
rg "assert\." tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js -c

Length of output: 189


Script:

#!/bin/bash
# Get all assertions with context to analyze them
echo "Listing all assertions with context..."
rg "assert\." tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js -B 1 -A 1

Length of output: 1110


70-77: 🛠️ Refactor suggestion

Improve timeout-based verification logic

The current implementation has several issues:

  1. The timeout value should be defined as a constant
  2. The Promise wrapping can be simplified
  3. The async/await usage is unnecessarily complex
- let timeout = 500;
- await new Promise(resolve => 
-   later(async() => {
-   let result = await store.query(modelName, builder2.build());
-     assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store');
-     resolve();
-     await newRecord.destroyRecord();
-   }, timeout));
+ const VERIFICATION_TIMEOUT = 500;
+ await new Promise(resolve => later(resolve, VERIFICATION_TIMEOUT));
+ const result = await store.query(modelName, builder2.build());
+ assert.ok(result.meta.count, `record '${uuid}' not found in store`);
+ await newRecord.destroyRecord();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  const VERIFICATION_TIMEOUT = 500;
  await new Promise(resolve => later(resolve, VERIFICATION_TIMEOUT));
  const result = await store.query(modelName, builder2.build());
  assert.ok(result.meta.count, `record '${uuid}' not found in store`);
  await newRecord.destroyRecord();

17-22: 🛠️ Refactor suggestion

Simplify async code by removing unnecessary run() wrapper

The run() wrapper is not needed here as we're already in an async context. Modern Ember.js recommends avoiding run() for async operations.

- await run(async() => {
+ let newRecord = store.createRecord(modelName, { name: uuid });
+ await newRecord.save();
+ addDataForDestroy(newRecord);
- });

Committable suggestion was skipped due to low confidence.


43-54: 🛠️ Refactor suggestion

Simplify delete operations using async/await with filter and map

The delete operation collection can be simplified using modern array methods and async/await.

- let clickPromises = [];
- $rows().forEach(function(element, i, arr)  {
-   let nameRecord = $.trim(element.children[1].innerText);
-   if (nameRecord.indexOf(uuid) >= 0) {
-     let $deleteBtnInRow = $('.object-list-view-row-delete-button', element)[0];
-     clickPromises.push(click($deleteBtnInRow));
-   }
- });
- await Promise.all(clickPromises);
+ const rowsToDelete = $rows()
+   .filter(element => element.children[1].innerText.trim().includes(uuid));
+ await Promise.all(
+   rowsToDelete.map(row => 
+     click(row.querySelector('.object-list-view-row-delete-button'))
+   )
+ );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    /* eslint-disable no-unused-vars */
    const rowsToDelete = $rows()
      .filter(element => element.children[1].innerText.trim().includes(uuid));
    await Promise.all(
      rowsToDelete.map(row => 
        click(row.querySelector('.object-list-view-row-delete-button'))
      )
    );
    /* eslint-enable no-unused-vars */

28-32: 🛠️ Refactor suggestion

Modernize DOM queries by using test helpers instead of jQuery

Consider using modern Ember test helpers like find() and findAll() instead of jQuery selectors for better maintainability and consistency with current Ember testing practices.

- let $folvContainer = $(olvContainerClass);
- let $rows = () => { return $(trTableClass, $folvContainer).toArray(); };
+ let $rows = () => { return findAll(`${olvContainerClass} ${trTableClass}`); };

Committable suggestion was skipped due to low confidence.

tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-data-cancel-test.js (3)

17-21: 🛠️ Refactor suggestion

Consider simplifying the async structure

The nested async functions can be flattened, and the run() wrapper might be unnecessary in modern Ember versions.

Consider simplifying to:

-  await run(async() => {
-    let newRecord = store.createRecord(modelName, { name: uuid });
-
-    await newRecord.save();
-    addDataForDestroy(newRecord);
+  let newRecord = store.createRecord(modelName, { name: uuid });
+  await newRecord.save();
+  addDataForDestroy(newRecord);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  let newRecord = store.createRecord(modelName, { name: uuid });
  await newRecord.save();
  addDataForDestroy(newRecord);

29-33: 🛠️ Refactor suggestion

Consider migrating from jQuery to native DOM APIs

Modern Ember.js applications should prefer native DOM APIs over jQuery for better performance and maintainability.

Example refactor:

-    let $folvContainer = $(olvContainerClass);
-    let $rows = () => { return $(trTableClass, $folvContainer).toArray(); };
+    let folvContainer = document.querySelector(olvContainerClass);
+    let rows = () => Array.from(folvContainer.querySelectorAll(trTableClass));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    let olvContainerClass = '.object-list-view-container';
    let trTableClass = 'table.object-list-view tbody tr';

    let folvContainer = document.querySelector(olvContainerClass);
    let rows = () => Array.from(folvContainer.querySelectorAll(trTableClass));

69-78: 🛠️ Refactor suggestion

Simplify the timeout and cleanup logic

The current implementation uses complex promise nesting with timeouts. This can be simplified using modern async/await patterns.

Consider restructuring:

-  await new Promise(resolve => 
-    later(async() => {
-      let result = await store.query(modelName, builder2.build());
-      assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store');
-      resolve();
-      await newRecord.destroyRecord();
-    }, timeout));
+  await new Promise(resolve => later(resolve, timeout));
+  let result = await store.query(modelName, builder2.build());
+  assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store');
+  await newRecord.destroyRecord();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  // Check that the records haven't been removed from store.
  let builder2 = new Builder(store, modelName).where('name', FilterOperator.Eq, uuid).count();
  let timeout = 500;
  await new Promise(resolve => later(resolve, timeout));
  let result = await store.query(modelName, builder2.build());
  assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store');
  await newRecord.destroyRecord();
tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-with-promise-data-immediately-test.js (2)

69-78: 🛠️ Refactor suggestion

Simplify asynchronous verification logic

The current implementation uses a timeout-based approach with nested promises, which is fragile and hard to maintain. The later() wrapper with a new Promise is unnecessarily complex when using async/await.

Consider simplifying the verification:

-    let timeout = 500;
-    await new Promise(resolve => 
-      later(async() => {
-        let result = await store.query(modelName, builder2.build());
-        assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store');
-        resolve();
-        await newRecord.destroyRecord();
-      }, timeout));
+    // Wait for any pending operations to complete
+    await settled();
+    
+    const result = await store.query(modelName, builder2.build());
+    assert.ok(result.meta.count, `record '${uuid}' not found in store`);
+    
+    await newRecord.destroyRecord();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    // Check that the records have been removed from store.
    let builder2 = new Builder(store, modelName).where('name', FilterOperator.Eq, uuid).count();
    // Wait for any pending operations to complete
    await settled();
    
    const result = await store.query(modelName, builder2.build());
    assert.ok(result.meta.count, `record '${uuid}' not found in store`);
    
    await newRecord.destroyRecord();

17-42: 🛠️ Refactor suggestion

Consider modernizing test helpers usage

The test uses older patterns that could be updated:

  1. run() is typically unnecessary in modern Ember tests with async/await
  2. jQuery selectors could be replaced with modern test helpers

Consider updating to modern test helpers:

-  await run(async() => {
+  let newRecord = store.createRecord(modelName, { name: uuid });
+  await newRecord.save();
+  addDataForDestroy(newRecord);
+
+  let builder = new Builder(store).from(modelName).count();
+  let result = await store.query(modelName, builder.build());
+  await visit(path + '?perPage=' + result.meta.count);
+
+  assert.equal(currentPath(), path);
+
+  // Use modern test helpers instead of jQuery
+  const rows = await findAll('table.object-list-view tbody tr');
+  const recordExists = rows.some(row => {
+    return row.textContent.includes(uuid);
+  });
+
+  assert.true(recordExists, '1 record added');
-  });

Committable suggestion was skipped due to low confidence.

tests/acceptance/components/flexberry-objectlistview/folv-getCellComponent-test.js (1)

18-40: 🛠️ Refactor suggestion

Consider modernizing DOM queries

The current implementation heavily relies on jQuery selectors. Consider refactoring to use modern Ember test selectors for better maintainability and reliability.

-  let $folvContainer = $('.object-list-view-container');
-  let $table = $('table.object-list-view', $folvContainer);
+  let folvContainer = find('[data-test-folv-container]');
+  let table = find('[data-test-folv-table]');

You'll need to add corresponding data-test attributes to your templates:

<div data-test-folv-container class="object-list-view-container">
  <table data-test-folv-table class="object-list-view">
tests/acceptance/components/flexberry-objectlistview/folv-delete-button-test.js (3)

38-43: 🛠️ Refactor suggestion

Simplify promise handling

The promise resolution can be simplified by removing the unnecessary run wrapper and intermediate variable.

-let resolvedPromises;
-run(() => {
-  resolvedPromises = RSVP.all(promises);
-});
-await resolvedPromises;
-assert.ok(resolvedPromises, 'All records saved.');
+await all(promises);
+assert.ok(true, 'All records saved.');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  await all(promises);
  assert.ok(true, 'All records saved.');

58-62: 🛠️ Refactor suggestion

Consider modernizing the record verification

The record verification could be more readable and maintainable.

-let recordIsForDeleting = $rows().reduce((sum, current) => {
-  let nameRecord = $.trim(current.children[1].innerText);
-  let flag = (nameRecord.indexOf(uuid) >= 0);
-  return sum + flag;
-}, 0);
+let recordIsForDeleting = $rows().filter((row) => {
+  const nameRecord = $.trim(row.children[1].innerText);
+  return nameRecord.includes(uuid);
+}).length;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  let recordIsForDeleting = $rows().filter((row) => {
    const nameRecord = $.trim(row.children[1].innerText);
    return nameRecord.includes(uuid);
  }).length;

66-78: 🛠️ Refactor suggestion

Simplify checkRecords promise handling

The promise handling in checkRecords can be simplified by removing the manual promises array management.

 let checkRecords = async function() {
-  promises.clear();
-  $rows().forEach((row) => {
+  const clickPromises = $rows().map((row) => {
     let nameRecord = $.trim(row.children[1].innerText);
     let $firstCell = $('.object-list-view-helper-column-cell', row);
     let checkboxInRow = $('.flexberry-checkbox', $firstCell)[0];
     if (nameRecord.indexOf(uuid) >= 0) {
-      run(()=> promises.pushObject(click(checkboxInRow)));
+      return click(checkboxInRow);
     }
+    return Promise.resolve();
   });

-  await all(promises);
+  await all(clickPromises);
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  let checkRecords = async function() {
    const clickPromises = $rows().map((row) => {
      let nameRecord = $.trim(row.children[1].innerText);
      let $firstCell = $('.object-list-view-helper-column-cell', row);
      let checkboxInRow = $('.flexberry-checkbox', $firstCell)[0];
      if (nameRecord.indexOf(uuid) >= 0) {
        return click(checkboxInRow);
      }
      return Promise.resolve();
    });

    await all(clickPromises);
  };
tests/acceptance/components/flexberry-objectlistview/folv-paging-navigation-test.js (3)

22-32: 🛠️ Refactor suggestion

Consider using data-test- attributes for more robust selectors.*

The current jQuery selectors (.ui.button, .ui.basic.buttons) are coupled to styling classes which could change. Consider using dedicated test attributes for more reliable test selectors.

- let $basicButtons = $('.ui.button', '.ui.basic.buttons');
+ let $basicButtons = $('[data-test-pagination-button]', '[data-test-pagination-container]');

This would require updating your component template with corresponding attributes:

<div data-test-pagination-container class="ui basic buttons">
  <button data-test-pagination-button class="ui button">
    {{page}}
  </button>
</div>

51-67: 🛠️ Refactor suggestion

Reduce code duplication in pagination assertions.

Consider extracting the repeated assertion patterns into helper functions to improve maintainability and readability.

// Helper function to verify page button states
const assertPageButtonStates = (buttons, {activePage, isFirstPage, isLastPage}) => {
  if (isFirstPage) {
    assert.equal($(buttons[0]).hasClass('disabled'), true, 'prev button is disabled');
  }
  if (isLastPage) {
    assert.equal($(buttons[buttons.length-1]).hasClass('disabled'), true, 'next button is disabled');
  }
  buttons.forEach((button, index) => {
    assert.equal($(button).hasClass('active'), index === activePage, 
      `page ${index} ${index === activePage ? 'is' : 'is not'} active`);
  });
};

34-49: 🛠️ Refactor suggestion

Simplify the refresh function implementation.

The current implementation creates a new function for each navigation action. Consider extracting this to a reusable helper function.

- let refreshFunction =  async function() {
-   let refreshButton = $basicButtons[4];
-   await click( refreshButton);
- };
+ const createPageClickFunction = (buttonIndex) => async () => {
+   await click($basicButtons[buttonIndex]);
+ };
+ 
+ await refreshListByFunction(createPageClickFunction(4), controller);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  const createPageClickFunction = (buttonIndex) => async () => {
    await click($basicButtons[buttonIndex]);
  };

  await refreshListByFunction(createPageClickFunction(4), controller);
  $basicButtons = $('.ui.button', '.ui.basic.buttons');
  assert.equal($($basicButtons[1]).hasClass('active'), false, 'page 1 is not active');
  assert.equal($($basicButtons[4]).hasClass('active'), true, 'page 4 is active');
  assert.equal($($basicButtons[1])[0].innerText, 1, '1st page is depicted');
  assert.equal($($basicButtons[2])[0].innerText, '...', '... page is depicted');
  assert.equal($($basicButtons[3])[0].innerText, 3, '3rd page is depicted');
  assert.equal($($basicButtons[4])[0].innerText, 4, '4th page is depicted');
  assert.equal($($basicButtons[5])[0].innerText, 5, '5th page is depicted');
  assert.equal($($basicButtons[6])[0].innerText, '...', '... page is depicted');
  assert.equal($($basicButtons[7])[0].innerText, last, 'last page is depicted');
tests/acceptance/components/flexberry-objectlistview/folv-user-settings-test.js (2)

116-128: ⚠️ Potential issue

Fix indentation and consider adding error handling.

The async conversion is good, but there are some formatting issues to address.

Apply this diff to fix indentation and add error handling:

 async function deleteUserSetting(assert) {
-  let foundRecords = await userService._getExistingSettings('FOLVPagingObjectListView', 'DEFAULT');
-
-        if (foundRecords && foundRecords.length > 0) {
-          assert.equal(foundRecords.length, 1, "Найдена настройка пользователя.");
-          foundRecords[0].deleteRecord();
-          await foundRecords[0].save();
-          assert.ok(true, "Настройки пользователя удалены из БД.");
-        }
-        else {
-          assert.ok(true, "Настройки пользователя не найдены в БД.");
-      }
-    }
+  try {
+    const foundRecords = await userService._getExistingSettings('FOLVPagingObjectListView', 'DEFAULT');
+    
+    if (foundRecords && foundRecords.length > 0) {
+      assert.equal(foundRecords.length, 1, "Найдена настройка пользователя.");
+      foundRecords[0].deleteRecord();
+      await foundRecords[0].save();
+      assert.ok(true, "Настройки пользователя удалены из БД.");
+    } else {
+      assert.ok(true, "Настройки пользователя не найдены в БД.");
+    }
+  } catch (error) {
+    assert.ok(false, `Failed to delete user setting: ${error.message}`);
+  }
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

async function deleteUserSetting(assert) {
  try {
    const foundRecords = await userService._getExistingSettings('FOLVPagingObjectListView', 'DEFAULT');
    
    if (foundRecords && foundRecords.length > 0) {
      assert.equal(foundRecords.length, 1, "Найдена настройка пользователя.");
      foundRecords[0].deleteRecord();
      await foundRecords[0].save();
      assert.ok(true, "Настройки пользователя удалены из БД.");
    } else {
      assert.ok(true, "Настройки пользователя не найдены в БД.");
    }
  } catch (error) {
    assert.ok(false, `Failed to delete user setting: ${error.message}`);
  }
}

27-28: 💡 Codebase verification

Based on the analysis of the files, I can now generate the final response:

Modernization needed: Legacy Ember.set and Ember.run usage found

Several test files still use the legacy Ember.set and Ember.run syntax, while the file under review has been modernized to use imported functions. Specific files requiring similar modernization:

  • tests/acceptance/components/flexberry-objectlistview/folv-delete-with-details-test.js: Uses Ember.run()
  • tests/acceptance/components/flexberry-toggler/flexberry-toggler-with-inner-toggler-test.js: Uses Ember.run()
  • tests/acceptance/components/flexberry-lookup/flexberry-lookup-custom-window-test.js: Uses both Ember.set and Ember.run
  • tests/acceptance/components/flexberry-groupedit/flexberry-groupedit-delete-with-details-test.js: Uses Ember.run()

These files should be updated to use the modern syntax:

  • Replace Ember.set with imported set from @ember/object
  • Replace Ember.run with imported run from @ember/runloop
🔗 Analysis chain

LGTM! Test lifecycle hooks properly configured.

The hooks correctly handle:

  • Application controller test mode setup
  • User settings service configuration
  • Proper cleanup in afterEach

Also applies to: 32-32, 37-38


Let me check the specific usage of Ember.set and Ember.run in these files to determine if there's an inconsistency pattern.


Let me check if these files have already been modernized in other PRs or if there are any imports at the top of these files that might indicate partial modernization.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify consistent usage of modern imports across test files
rg -l "Ember\.(set|run)" "tests/acceptance/"

Length of output: 401


Script:

#!/bin/bash
# Check the actual usage of Ember.set and Ember.run in the identified files
echo "=== folv-delete-with-details-test.js ==="
rg "Ember\.(set|run)" tests/acceptance/components/flexberry-objectlistview/folv-delete-with-details-test.js -B 1 -A 1

echo -e "\n=== flexberry-toggler-with-inner-toggler-test.js ==="
rg "Ember\.(set|run)" tests/acceptance/components/flexberry-toggler/flexberry-toggler-with-inner-toggler-test.js -B 1 -A 1

echo -e "\n=== flexberry-lookup-custom-window-test.js ==="
rg "Ember\.(set|run)" tests/acceptance/components/flexberry-lookup/flexberry-lookup-custom-window-test.js -B 1 -A 1

echo -e "\n=== flexberry-groupedit-delete-with-details-test.js ==="
rg "Ember\.(set|run)" tests/acceptance/components/flexberry-groupedit/flexberry-groupedit-delete-with-details-test.js -B 1 -A 1

Length of output: 3991


Script:

#!/bin/bash
# Check imports and the first few lines of the files to understand the current state
for file in tests/acceptance/components/flexberry-objectlistview/folv-delete-with-details-test.js \
           tests/acceptance/components/flexberry-toggler/flexberry-toggler-with-inner-toggler-test.js \
           tests/acceptance/components/flexberry-lookup/flexberry-lookup-custom-window-test.js \
           tests/acceptance/components/flexberry-groupedit/flexberry-groupedit-delete-with-details-test.js; do
  echo "=== $file ==="
  head -n 20 "$file"
  echo -e "\n"
done

Length of output: 6351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants