adopted-ember-addons / adopted-ember-addons/ember-light-table

Unique data-test-* row attributes for ember-test-selectors

Aberta
#500 3 comentários 4 reações 0 responsáveis Ver no GitHub
tip
Linguagem predominante
JavaScript
Estrelas
311
Forks
130
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

I'm using [ember-test-selectors](https://github.com/simplabs/ember-test-selectors/) and really prefer to select elements in my tests using those `data-test-*` selectors.

I was trying to figure out how best to get that same functionality in ember-light table. I realized that the data I was already passing to my tables already had a unique ID in all cases (globally unique ID of the data model for that row). I then realized I could just create a custom row component that automatically binds to that attribute:

`app/components/my-table/row.js`:

```js
import { readOnly } from "@ember/object/computed";
import Row from "ember-light-table/components/lt-row";

export default Row.extend({
"data-test-row-id": readOnly("row.id"),
});
```

Then when invoking the `light-table` component, I can just specify that row component:

```hbs
{{#t.body
rowComponent=(component "ac-table/row")
as |body|
}}
```

I'm posting this here not because there's an issue to resolve, but because others might find it useful. Feel free to just close this, or maybe there's something that can be added to the docs to make these sorts of customizations more discoverable.

Thanks for your work on this addon :v:

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.