Skip to content

Commit

Permalink
Merge pull request #207 from upfluence/jv/vel-2977/replace-twitter-by-x
Browse files Browse the repository at this point in the history
Update twitter clustering_key for x for manage columns
  • Loading branch information
JulienVannier66 authored Jun 27, 2024
2 parents 2cf72b9 + 290f6ff commit 9aa8ee9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions addon/components/hyper-table-v2/manage-columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ export default class HyperTableV2ManageColumns extends Component<HyperTableV2Man
if (this.args.handler.columns.length > 0 && columnDefinition.position?.sticky) {
return;
}
const cluster = map.get(columnDefinition.clustering_key);
const key = columnDefinition.clustering_key === 'twitter' ? 'x' : columnDefinition.clustering_key;
const cluster = map.get(key);
const manageColumn: ManagedColumn = {
definition: columnDefinition,
visible: !isEmpty(this.args.handler.columns.find((column) => column?.definition.key === columnDefinition.key)),
isLoading: false
};

if (!cluster) {
map.set(columnDefinition.clustering_key, [manageColumn]);
map.set(key, [manageColumn]);
} else {
cluster.push(manageColumn);
}
Expand Down
14 changes: 11 additions & 3 deletions tests/integration/components/hyper-table-v2/manage-columns-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const COLUMN_DEFINITIONS = [
{ key: 'alone', extra: { category: '', clustering_key: '', position: { sticky: true } } },
{ key: 'code', extra: { category: 'affiliation', clustering_key: '' } },
{ key: 'foo', extra: { category: 'influencer', clustering_key: 'instagram' } },
{ key: 'doe', extra: { category: 'influencer', clustering_key: 'twitter' } },
{ key: 'bar', extra: { category: 'influencer', clustering_key: 'youtube' } }
];

Expand Down Expand Up @@ -97,6 +98,7 @@ module('Integration | Component | hyper-table-v2/manage-columns', function (hook
test('it displays all the column definitions for default category', async function (assert) {
await render(hbs`<HyperTableV2::ManageColumns @handler={{this.handler}} />`);
await click('.upf-btn.upf-btn--default');
// await this.pauseTest();

document.querySelectorAll('.fields-list .field').forEach((element, index) => {
// index + 1 because the first column is not visible
Expand All @@ -109,8 +111,9 @@ module('Integration | Component | hyper-table-v2/manage-columns', function (hook
const clusterNames = document.querySelectorAll('.fields-list .cluster-name');

assert.equal(clusterNames[0].textContent?.trim(), 'instagram');
assert.equal(clusterNames[1].textContent?.trim(), 'youtube');
assert.expect(5);
assert.equal(clusterNames[1].textContent?.trim(), 'x');
assert.equal(clusterNames[2].textContent?.trim(), 'youtube');
assert.expect(7);
});

test('it sets the category. as active when user select a category', async function (assert) {
Expand All @@ -134,9 +137,14 @@ module('Integration | Component | hyper-table-v2/manage-columns', function (hook
columnDefinitionsVisible[1].firstElementChild?.getAttribute('data-control-name'),
'column_definition_toggle_checkbox_foo'
);
assert.equal(columnDefinitionsVisible[2].textContent?.trim(), 'youtube');
assert.equal(columnDefinitionsVisible[2].textContent?.trim(), 'x');
assert.equal(
columnDefinitionsVisible[3].firstElementChild?.getAttribute('data-control-name'),
'column_definition_toggle_checkbox_doe'
);
assert.equal(columnDefinitionsVisible[4].textContent?.trim(), 'youtube');
assert.equal(
columnDefinitionsVisible[5].firstElementChild?.getAttribute('data-control-name'),
'column_definition_toggle_checkbox_bar'
);
});
Expand Down

0 comments on commit 9aa8ee9

Please sign in to comment.