Skip to content

Commit

Permalink
bump ember-test-selectors to v6 with fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanMonroe committed Feb 9, 2022
1 parent cf1413c commit be406a4
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 72 deletions.
2 changes: 2 additions & 0 deletions addon/components/-private/simple-checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default Component.extend({
'indeterminate',
'type',
'value',
'dataTestSelectRow:data-test-select-row',
'dataTestCollapseRow:data-test-collapse-row',
],

ariaLabel: undefined,
Expand Down
3 changes: 2 additions & 1 deletion addon/components/ember-table-loading-more/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import { next, run, schedule, scheduleOnce } from '@ember/runloop';
export default Component.extend({
classNames: ['ember-table-loading-more'],

'data-test-ember-table-loading-more': true,
attributeBindings: ['dataTestEmberTableLoadingMore:data-test-ember-table-loading-more'],
dataTestEmberTableLoadingMore: true,

unwrappedApi: or('api.api', 'api'),
scrollElement: readOnly('unwrappedApi.columnTree.container'),
Expand Down
4 changes: 2 additions & 2 deletions addon/components/ember-table/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import layout from './template';
export default Component.extend({
layout,
classNames: ['ember-table'],

'data-test-ember-table': true,
attributeBindings: ['dataTestEmberTable:data-test-ember-table'],
dataTestEmberTable: true,

didInsertElement() {
this._super(...arguments);
Expand Down
7 changes: 5 additions & 2 deletions addon/components/ember-tbody/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default Component.extend({

dataTestRowCount: null,

'data-test-row-count': readOnly('dataTestRowCount'),
attributeBindings: ['dataTestRowCount:data-test-row-count'],

init() {
this._super(...arguments);
Expand Down Expand Up @@ -281,7 +281,10 @@ export default Component.extend({
* In an actual app build, `this.attributeBindings` may be undefined.
* Guard against it being `undefined` before checking for the attribute.
*/
if (this.attributeBindings && this.attributeBindings.includes('data-test-row-count')) {
if (
this.attributeBindings &&
this.attributeBindings.includes('dataTestRowCount:data-test-row-count')
) {
this._isObservingDebugRowCount = true;
let scheduleUpdate = (this._scheduleUpdate = () => {
run.scheduleOnce('actions', this, this._updateDataTestRowCount);
Expand Down
4 changes: 2 additions & 2 deletions addon/components/ember-td/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
data-test-select-row-container
>
{{-ember-table-private/simple-checkbox
data-test-select-row=true
dataTestSelectRow=true
checked=this.rowMeta.isGroupSelected
onClick=(action "onSelectionToggled")
ariaLabel="Select row"
Expand All @@ -18,7 +18,7 @@
{{#if this.canCollapse}}
<span class="et-toggle-collapse et-depth-indent {{this.depthClass}}">
{{-ember-table-private/simple-checkbox
data-test-collapse-row=true
dataTestCollapseRow=true
checked=this.rowMeta.isCollapsed
onChange=(action "onCollapseToggled")
ariaLabel="Collapse row"
Expand Down
2 changes: 2 additions & 0 deletions addon/components/ember-tfoot/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export default EmberTBody.extend({
layout,
tagName: 'tfoot',

attributeBindings: ['wrappedRowArray.length:data-test-row-count'],

wrappedRowArray: computed('wrappedRows.[]', function() {
let wrappedRows = this.get('wrappedRows');
let wrappedRowsLength = wrappedRows.get('length');
Expand Down
62 changes: 31 additions & 31 deletions addon/components/ember-tfoot/template.hbs
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{{#each this.wrappedRowArray as |rowValue|}}
{{#-ember-table-private/row-wrapper
rowValue=rowValue
columns=this.columns

columnMetaCache=this.columnMetaCache
rowMetaCache=this.rowMetaCache

canSelect=this.canSelect
rowSelectionMode=this.rowSelectionMode
checkboxSelectionMode=this.checkboxSelectionMode

rowsCount=this.wrappedRowArray.length

as |api|
}}
{{#if (has-block)}}
{{yield (hash
rowValue=api.rowValue
rowMeta=api.rowMeta
cells=api.cells
rowSelectionMode=api.rowSelectionMode
rowsCount=api.rowsCount

row=(component "ember-tr" api=api)
)}}
{{else}}
{{ember-tr api=api}}
{{/if}}
{{/-ember-table-private/row-wrapper}}
{{/each}}
{{#each this.wrappedRowArray as |rowValue|}}
{{#-ember-table-private/row-wrapper
rowValue=rowValue
columns=this.columns
columnMetaCache=this.columnMetaCache
rowMetaCache=this.rowMetaCache
canSelect=this.canSelect
rowSelectionMode=this.rowSelectionMode
checkboxSelectionMode=this.checkboxSelectionMode
rowsCount=this.wrappedRowArray.length
as |api|
}}
{{#if (has-block)}}
{{yield (hash
rowValue=api.rowValue
rowMeta=api.rowMeta
cells=api.cells
rowSelectionMode=api.rowSelectionMode
rowsCount=api.rowsCount
row=(component "ember-tr" api=api)
)}}
{{else}}
{{ember-tr api=api}}
{{/if}}
{{/-ember-table-private/row-wrapper}}
{{/each}}
17 changes: 9 additions & 8 deletions addon/components/ember-th/template.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{{#if (has-block)}}
{{yield this.columnValue this.columnMeta this.rowMeta}}
{{else}}
{{this.columnValue.name}}

{{ember-th/sort-indicator columnMeta=this.columnMeta}}

{{ember-th/resize-handle columnMeta=this.columnMeta}}
{{/if}}
{{#if (has-block)}}
{{yield this.columnValue this.columnMeta this.rowMeta}}
{{else}}
{{this.columnValue.name}}

{{ember-th/sort-indicator columnMeta=this.columnMeta}}

{{ember-th/resize-handle columnMeta=this.columnMeta}}
{{/if}}
3 changes: 2 additions & 1 deletion addon/components/ember-thead/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ export default Component.extend({
*/
onResize: null,

'data-test-row-count': readOnly('wrappedRows.length'),
attributeBindings: ['dataTestRowCount:data-test-row-count'],
dataTestRowCount: readOnly('wrappedRows.length'),

init() {
this._super(...arguments);
Expand Down
25 changes: 13 additions & 12 deletions addon/components/ember-thead/template.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{{#each this.wrappedRows as |api|}}
{{#if (has-block)}}
{{yield (hash
cells=api.cells
isHeader=api.isHeader
rowsCount=api.rowsCount

row=(component "ember-tr" api=api)
)}}
{{else}}
{{ember-tr api=api}}
{{/if}}
{{/each}}
{{#each this.wrappedRows as |api|}}
{{#if (has-block)}}
{{yield (hash
cells=api.cells
isHeader=api.isHeader
rowsCount=api.rowsCount

row=(component "ember-tr" api=api)
)}}
{{else}}
{{ember-tr api=api}}
{{/if}}
{{/each}}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"ember-cli-version-checker": "^5.1.2",
"ember-compatibility-helpers": "^1.2.0",
"ember-raf-scheduler": "^0.3.0",
"ember-test-selectors": "^5.0.0",
"ember-test-selectors": "^6.0.0",
"hammerjs": "^2.0.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/generate-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export { configureTableGeneration, resetTableGenerationConfig, generateColumns,

const fullTable = hbs`
<div style="height: 500px;">
{{#ember-table data-test-ember-table=true as |t|}}
{{#ember-table as |t|}}
{{#ember-thead
api=t
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/components/meta-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { componentModule } from '../../helpers/module';

import TablePage from 'ember-table/test-support/pages/ember-table';

let table = new TablePage('[data-test-main-table]');
let otherTable = new TablePage('[data-test-other-table]');
let table = new TablePage('.dataTestMainTable');
let otherTable = new TablePage('.dataTestOtherTable');

module('Integration | meta', function() {
componentModule('basic', function() {
Expand All @@ -25,7 +25,7 @@ module('Integration | meta', function() {

await render(hbs`
<div style="height: 500px;">
{{#ember-table data-test-main-table=true as |t|}}
{{#ember-table class="dataTestMainTable" as |t|}}
{{#ember-thead api=t columns=columns as |h|}}
{{#ember-tr api=h as |r|}}
{{#ember-th api=r as |column columnMeta|}}
Expand Down Expand Up @@ -121,7 +121,7 @@ module('Integration | meta', function() {

await render(hbs`
<div style="height: 500px;">
{{#ember-table data-test-main-table=true as |t|}}
{{#ember-table class="dataTestMainTable" as |t|}}
{{#ember-thead api=t columns=columns as |h|}}
{{#ember-tr api=h as |r|}}
{{#ember-th api=r as |column columnMeta|}}
Expand Down Expand Up @@ -159,7 +159,7 @@ module('Integration | meta', function() {
</div>
<div style="height: 500px;">
{{#ember-table data-test-other-table=true as |t|}}
{{#ember-table class="dataTestOtherTable" as |t|}}
{{#ember-thead api=t columns=columns as |h|}}
{{#ember-tr api=h as |r|}}
{{#ember-th api=r as |column columnMeta|}}
Expand Down Expand Up @@ -201,7 +201,7 @@ module('Integration | meta', function() {
await table.getCell(0, 0).click();

// ensure we trigger property updates by scrolling around a bit
let scrollSelector = '[data-test-other-table] [data-test-ember-table-overflow]';
let scrollSelector = '.dataTestOtherTable [data-test-ember-table-overflow]';
await scrollTo(scrollSelector, 0, 10000);
await scrollTo(scrollSelector, 0, 1000);
await scrollTo(scrollSelector, 0, 100);
Expand Down Expand Up @@ -243,7 +243,7 @@ module('Integration | meta', function() {
generateTableValues(this, { columnCount, columnOptions: { subcolumnCount } });

await render(hbs`
{{#ember-table data-test-main-table=true as |t|}}
{{#ember-table class="dataTestMainTable" as |t|}}
{{#ember-thead api=t columns=columns as |h|}}
{{#ember-tr api=h as |r|}}
{{#ember-th api=r as |column columnMeta rowMeta|}}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6203,10 +6203,10 @@ ember-source@~3.28.0:
semver "^7.3.4"
silent-error "^1.1.1"

ember-test-selectors@^5.0.0:
version "5.5.0"
resolved "https://registry.npmjs.org/ember-test-selectors/-/ember-test-selectors-5.5.0.tgz#114bd29c4a33eee3a328c9ce32a57a018c27f5f6"
integrity sha512-PiKhbPnidRYQ5ed/CTU3teJV3XmzkjYjsCGx1UTy7qEY/1dEqxezlZu1DtisoLJ9Y+BcjTVlE+596lo9cOXd3w==
ember-test-selectors@^6.0.0:
version "6.0.0"
resolved "https://registry.npmjs.org/ember-test-selectors/-/ember-test-selectors-6.0.0.tgz#ba9bb19550d9dec6e4037d86d2b13c2cfd329341"
integrity sha512-PgYcI9PeNvtKaF0QncxfbS68olMYM1idwuI8v/WxsjOGqUx5bmsu6V17vy/d9hX4mwmjgsBhEghrVasGSuaIgw==
dependencies:
calculate-cache-key-for-tree "^2.0.0"
ember-cli-babel "^7.26.4"
Expand Down

0 comments on commit be406a4

Please sign in to comment.