Files
threshold-ui/ui/admin/tests/acceptance/scopes/list-test.js
T
3dded0a7bc Llb/side nav refactor (#2763)
* feat: 🎸 scope picker component (#2646)

* feat: 🎸 scope picker component
---------

Co-authored-by: lisbet-alvarez <lisbet-alvarez@users.noreply.github.com>
Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>

* refactor: 💡 use hds side nav w/ hds frame instead of rose (#2688)

* refactor: 💡 use hds side nav w/ hds frame instead of rose

* test: 💍 clean up selectors

* fix: 🐛 specificity of style override

* refactor: 💡 use hds side nav list instead of target and portal

* refactor: 💡 revert to using portal component & update scss

* docs: ✏️ update comment

* refactor: 💡 use custom class names for containers

* refactor: 💡 pr feedback (use @hasSidebar arg)

* refactor: 💡 fix onboarding page & fix settings title

* refactor: 💡 remove unneeded template file (pr feedback)

* test: 💍 fix tests due to merge conflicts

* test: 💍 add missing test selector due to merge conflict

* test: 💍 fix more broken tests due to merge conflicts

* chore: 🤖 update yarn.lock & update hds version to 4.18.1

* chore: 🤖 fix e2e test cases due to side nav refactor (#2751)

* chore: 🤖 fix e2e test cases due to side nav refactor

* test: 💍 fix e2e test for desktop

---------

Co-authored-by: lisbet-alvarez <lisbet-alvarez@users.noreply.github.com>
Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
2025-04-14 14:27:02 -07:00

164 lines
4.7 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { currentURL, visit, fillIn, waitFor } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
import { authenticateSession } from 'ember-simple-auth/test-support';
import * as commonSelectors from 'admin/tests/helpers/selectors';
import * as selectors from './selectors';
module('Acceptance | scopes | list', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupIndexedDb(hooks);
const instances = {
scopes: {
global: null,
org1: null,
org2: null,
project1: null,
project2: null,
},
};
const urls = {
scopes: null,
globalScope: null,
orgScope: null,
};
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org1 = this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
});
instances.scopes.org2 = this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
});
instances.scopes.project1 = this.server.create('scope', {
type: 'project',
scope: { id: instances.scopes.org1.id, type: 'org' },
});
instances.scopes.project2 = this.server.create('scope', {
type: 'project',
scope: { id: instances.scopes.org1.id, type: 'org' },
});
urls.scopes = '/scopes';
urls.globalScope = '/scopes/global/scopes';
urls.orgScope = `/scopes/${instances.scopes.org1.id}/scopes`;
await authenticateSession({});
});
test('user gets redirected to scopes list view', async function (assert) {
await visit(urls.scopes);
assert.strictEqual(currentURL(), urls.globalScope);
});
test('user can search for a specific org scope by id', async function (assert) {
await visit(urls.globalScope);
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org1.id))
.exists();
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org2.id))
.exists();
await fillIn(commonSelectors.SEARCH_INPUT, instances.scopes.org1.id);
await waitFor(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org2.id), {
count: 0,
});
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org1.id))
.exists();
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org2.id))
.doesNotExist();
});
test('user can search for org scopes and get no results', async function (assert) {
await visit(urls.globalScope);
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org1.id))
.exists();
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org2.id))
.exists();
await fillIn(
commonSelectors.SEARCH_INPUT,
'fake org scope that does not exist',
);
await waitFor(selectors.NO_SCOPE_RESULTS_MSG, { count: 1 });
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org1.id))
.doesNotExist();
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.org2.id))
.doesNotExist();
});
test('user can search for a specific project scope by id', async function (assert) {
await visit(urls.orgScope);
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project1.id))
.exists();
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project2.id))
.exists();
await fillIn(commonSelectors.SEARCH_INPUT, instances.scopes.project1.id);
await waitFor(
selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project2.id),
{
count: 0,
},
);
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project1.id))
.exists();
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project2.id))
.doesNotExist();
});
test('user can search for project scopes and get no results', async function (assert) {
await visit(urls.orgScope);
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project1.id))
.exists();
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project2.id))
.exists();
await fillIn(
commonSelectors.SEARCH_INPUT,
'fake org scope that does not exist',
);
await waitFor(selectors.NO_SCOPE_RESULTS_MSG, { count: 1 });
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project1.id))
.doesNotExist();
assert
.dom(selectors.TABLE_ROW_SCOPE_LINK(instances.scopes.project2.id))
.doesNotExist();
});
});