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

The reorder test helper does not work correctly when a direction is explicitly set #498

Open
andreisebastianc-ccc opened this issue Nov 1, 2022 · 0 comments

Comments

@andreisebastianc-ccc
Copy link

Describe the bug
The reorder test helper does not work correctly when a direction is explicitly set.

To Reproduce
Steps to reproduce the behavior:

  1. Use {{sortable-group groupName="closableTabs" direction='x' onChange=@onReorder}} on a List Element2.
  2. Use the reorder helper in the test file

Expected behavior
The new order of the items in the list is the one provided to the reorder helper.

Additional context

The Template File

<ol
  data-test-closable-tabs
  {{sortable-group groupName="closableTabs" direction='x' onChange=@onReorder}}
>
  {{#each @views as |exploration|}}
    <li
      {{sortable-item model=exploration groupName="closableTabs"}}
      data-test-tabs
      data-test-id="{{exploration.id}}"
    >
...

Inside the test logic

import { reorder } from 'ember-sortable/test-support/helpers';

...

    await reorder(
      'mouse',
      '[data-test-tabs]',
      `[data-test-id="${explorations[1].explorationId}"]`,
      `[data-test-id="${explorations[0].explorationId}"]`,
      `[data-test-id="${explorations[3].explorationId}"]`,
      `[data-test-id="${explorations[2].explorationId}"]`
    );

Workaround

  get direction() {
    if (ENV.environment === 'test') {
      return;
    }
    return 'x';
  }
+ {{sortable-group groupName="closableTabs" direction=this.direction onChange=@onReorder}}
- {{sortable-group groupName="closableTabs" direction='x' onChange=@onReorder}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant