5c2a08de6d
* Update browserslist * Add browserslistrc * ember-cli-update --to 3.26, fix conflicts * Run codemodes that start with ember-* * More codemods - before cp* * More codemods (curly data-test-*) * WIP ember-basic-dropdown template errors * updates ember-basic-dropdown and related deps to fix build issues * updates basic dropdown instances to new version API * updates more deps -- ember-template-lint is working again * runs no-implicit-this codemod * creates and runs no-quoteless-attributes codemod * runs angle brackets codemod * updates lint:hbs globs to only touch hbs files * removes yield only templates * creates and runs deprecated args transform * supresses lint error for invokeAction on LinkTo component * resolves remaining ambiguous path lint errors * resolves simple-unless lint errors * adds warnings for deprecated tagName arg on LinkTo components * adds warnings for remaining curly component invocation * updates global template lint rules * resolves remaining template lint errors * disables some ember specfic lint rules that target pre octane patterns * js lint fix run * resolves remaining js lint errors * fixes test run * adds npm-run-all dep * fixes test attribute issues * fixes console acceptance tests * fixes tests * adds yield only wizard/tutorial-active template * fixes more tests * attempts to fix more flaky tests * removes commented out settled in transit test * updates deprecations workflow and adds initializer to filter by version * updates flaky policies acl old test * updates to flaky transit test * bumps ember deps down to LTS version * runs linters after main merge * fixes client count tests after bad merge conflict fixes * fixes client count history test * more updates to lint config * another round of hbs lint fixes after extending stylistic rule * updates lint-staged commands * removes indent eslint rule since it seems to break things * fixes bad attribute in transform-edit-form template * test fixes * fixes enterprise tests * adds changelog * removes deprecated ember-concurrency-test-waiters dep and adds @ember/test-waiters * flaky test fix Co-authored-by: hashishaw <cshaw@hashicorp.com>
127 lines
4 KiB
JavaScript
127 lines
4 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import Service from '@ember/service';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import { run } from '@ember/runloop';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
const DISPLAY_ARRAY = ['role-1', 'role-2', 'role-3', 'role-4', 'role-5'];
|
|
|
|
const storeService = Service.extend({
|
|
query() {
|
|
return new Promise((resolve) => {
|
|
resolve([
|
|
{ id: 'role-1' },
|
|
{ id: 'role-2' },
|
|
{ id: 'role-3' },
|
|
{ id: 'role-4' },
|
|
{ id: 'role-5' },
|
|
{ id: 'role-6' },
|
|
]);
|
|
});
|
|
},
|
|
});
|
|
|
|
module('Integration | Component | InfoTableItemArray', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.set('displayArray', DISPLAY_ARRAY);
|
|
this.set('isLink', true);
|
|
this.set('modelType', 'transform/role');
|
|
this.set('queryParam', 'role');
|
|
this.set('backend', 'transform');
|
|
this.set('wildcardLabel', 'role');
|
|
this.set('viewAll', 'roles');
|
|
run(() => {
|
|
this.owner.unregister('service:store');
|
|
this.owner.register('service:store', storeService);
|
|
});
|
|
});
|
|
|
|
hooks.afterEach(function () {
|
|
this.owner.unregister('service:store');
|
|
});
|
|
|
|
test('it renders', async function (assert) {
|
|
await render(hbs`<InfoTableItemArray
|
|
@displayArray={{this.displayArray}}
|
|
/>`);
|
|
|
|
assert.dom('[data-test-info-table-item-array]').exists();
|
|
let noLinkString = document.querySelector('code').textContent.trim();
|
|
assert.equal(
|
|
noLinkString.length,
|
|
DISPLAY_ARRAY.toString().length,
|
|
'renders a string of the array if isLink is not provided'
|
|
);
|
|
});
|
|
|
|
test('it renders links if isLink is true', async function (assert) {
|
|
await render(hbs`<InfoTableItemArray
|
|
@displayArray={{this.displayArray}}
|
|
@isLink={{this.isLink}}
|
|
@modelType={{this.modelType}}
|
|
@queryParam={{this.queryParam}}
|
|
@backend={{this.backend}}
|
|
/>`);
|
|
assert.equal(
|
|
document.querySelectorAll('a > span').length,
|
|
DISPLAY_ARRAY.length,
|
|
'renders each item in array with link'
|
|
);
|
|
});
|
|
|
|
test('it renders a badge and view all if wildcard in display array && < 10', async function (assert) {
|
|
const displayArrayWithWildcard = ['role-1', 'role-2', 'role-3', 'r*'];
|
|
this.set('displayArrayWithWildcard', displayArrayWithWildcard);
|
|
await render(hbs`<InfoTableItemArray
|
|
@displayArray={{this.displayArrayWithWildcard}}
|
|
@isLink={{this.isLink}}
|
|
@modelType={{this.modelType}}
|
|
@queryParam={{this.queryParam}}
|
|
@backend={{this.backend}}
|
|
@viewAll={{this.viewAll}}
|
|
/>`);
|
|
|
|
assert.equal(
|
|
document.querySelectorAll('a > span').length,
|
|
DISPLAY_ARRAY.length - 1,
|
|
'renders each item in array with link'
|
|
);
|
|
// 6 here comes from the six roles setup in the store service.
|
|
assert.dom('[data-test-count="6"]').exists('correctly counts with wildcard filter and shows the count');
|
|
assert.dom('[data-test-view-all="roles"]').exists({ count: 1 }, 'renders 1 view all roles');
|
|
});
|
|
|
|
test('it renders a badge and view all if wildcard in display array && >= 10', async function (assert) {
|
|
const displayArrayWithWildcard = [
|
|
'role-1',
|
|
'role-2',
|
|
'role-3',
|
|
'r*',
|
|
'role-4',
|
|
'role-5',
|
|
'role-6',
|
|
'role-7',
|
|
'role-8',
|
|
'role-9',
|
|
'role-10',
|
|
];
|
|
this.set('displayArrayWithWildcard', displayArrayWithWildcard);
|
|
await render(hbs`<InfoTableItemArray
|
|
@displayArray={{this.displayArrayWithWildcard}}
|
|
@isLink={{this.isLink}}
|
|
@modelType={{this.modelType}}
|
|
@queryParam={{this.queryParam}}
|
|
@backend={{this.backend}}
|
|
@viewAll={{this.viewAll}}
|
|
/>`);
|
|
const numberCutOffTruncatedArray = displayArrayWithWildcard.length - 5;
|
|
assert.equal(document.querySelectorAll('a > span').length, 5, 'renders truncated array of five');
|
|
assert
|
|
.dom(`[data-test-and="${numberCutOffTruncatedArray}"]`)
|
|
.exists('correctly counts with wildcard filter and shows the count');
|
|
});
|
|
});
|