refactor: 💡 Remove targets/target-id/hosts route and tests (#1810)

* refactor: 💡 Remove targets/target-id/hosts route and tests

✅ Closes: ICU-10316

* refactor: 💡 Remove targets/target-id/sessions route and tests (#1811)

* refactor: 💡 Remove targets/target-id/sessions route and tests

✅ Closes: ICU-10317

* refactor: 💡 remove targets/target-id/sessions controller
This commit is contained in:
Cameron Perera authored and Zhihe Li committed 2023-09-22 18:58:13 -04:00
1 parent 3af58204ba
commit 55eca5037e
14 files changed
+1 -979

No files matched your search

+1 -4
View File
@@ -21,10 +21,7 @@ Router.map(function () {
});
this.route('projects', function () {
this.route('targets', function () {
this.route('target', { path: ':target_id' }, function () {
this.route('hosts');
this.route('sessions');
});
this.route('target', { path: ':target_id' }, function () {});
});
this.route('sessions', function () {});
});
@@ -1,49 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
import { all, hash } from 'rsvp';
import { inject as service } from '@ember/service';
export default class ScopesScopeProjectsTargetsTargetHostsRoute extends Route {
// =services
@service store;
@service ipc;
@service session;
@service clusterUrl;
@service confirm;
// =methods
/**
* Loads all host-sets and associated hosts under the current target.
* @return {Promise{[HostModel]}}
*/
async model() {
const target = this.modelFor('scopes.scope.projects.targets.target');
// Load all host-sets
const hostSets = await all(
target.host_sources.map(({ host_source_id }) =>
this.store.findRecord('host-set', host_source_id)
)
);
// Extract host ids from all host sets
const hostIds = hostSets.map(({ host_ids }) => host_ids);
// Load unique hosts
const uniqueHostIds = new Set(hostIds.flat());
return hash({
target,
hosts: all(
[...uniqueHostIds].map((hostId) =>
this.store.findRecord('host', hostId)
)
),
});
}
}
@@ -12,11 +12,4 @@ export default class ScopesScopeProjectsTargetsTargetIndexRoute extends Route {
@service router;
// =methods
/**
* Navigate to hosts within a target.
*/
afterModel() {
this.router.transitionTo('scopes.scope.projects.targets.target.sessions');
}
}
@@ -1,29 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class ScopesScopeProjectsTargetsTargetSessionsRoute extends Route {
// =services
@service ipc;
// =actions
/**
* Cancels the specified session and notifies user of success or error.
* @param {SessionModel}
*/
@action
@notifyError(({ message }) => message, { catch: true })
@notifySuccess('notifications.canceled-success')
async cancelSession(session) {
await session.cancelSession();
await this.ipc.invoke('stop', { session_id: session.id });
}
}
@@ -32,17 +32,6 @@
</Rose::Button>
</page.actions>
<page.navigation>
<Rose::Nav::Tabs as |nav|>
<nav.link @route='scopes.scope.projects.targets.target.sessions'>
{{t 'resources.session.active_plural'}}
</nav.link>
<nav.link @route='scopes.scope.projects.targets.target.hosts'>
{{t 'resources.host.title_plural'}}
</nav.link>
</Rose::Nav::Tabs>
</page.navigation>
<page.body>
{{outlet}}
</page.body>
@@ -1,66 +0,0 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
{{page-title (t 'resources.host-set.title_plural')}}
{{#if @model.hosts}}
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>
<row.headerCell>{{t 'form.name.label'}}</row.headerCell>
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
<row.headerCell>{{t 'form.address.label'}}</row.headerCell>
<row.headerCell />
</header.row>
</table.header>
<table.body as |body|>
{{#each @model.hosts as |host|}}
<body.row as |row|>
<row.cell>
{{host.displayName}}
<p>{{host.description}}</p>
</row.cell>
<row.cell>
<Copyable
@text={{host.id}}
@buttonText={{t 'actions.copy-to-clipboard'}}
@acknowledgeText={{t 'states.copied'}}
>
<code>{{host.id}}</code>
</Copyable>
</row.cell>
<row.cell>
{{#if host.isStatic}}
{{host.address}}
{{else}}
<Hds::Badge @text={{t 'resources.host-catalog.types.plugin'}} />
{{/if}}
</row.cell>
<row.cell>
<Rose::Button
@style='secondary'
{{on 'click' (route-action 'connect' @model.target host)}}
>
{{t 'resources.session.actions.connect'}}
</Rose::Button>
</row.cell>
</body.row>
{{/each}}
</table.body>
</Rose::Table>
{{else}}
<Rose::Layout::Centered>
<Rose::Message
@title={{t 'resources.host.messages.none-friendly.title'}}
as |message|
>
<message.description>
{{t 'resources.host.messages.none-friendly.description'}}
</message.description>
</Rose::Message>
</Rose::Layout::Centered>
{{/if}}
@@ -1,86 +0,0 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
{{#if this.cancelableUserSessions}}
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
<row.headerCell>{{t 'form.proxy.label'}}</row.headerCell>
<row.headerCell>{{t 'form.started.label'}}</row.headerCell>
<row.headerCell />
</header.row>
</table.header>
<table.body as |body|>
{{#each this.cancelableUserSessions as |session|}}
<body.row as |row|>
<row.cell class='nowrap'>
<Rose::Icon
class={{concat 'session-status-' session.status}}
@name='flight-icons/svg/entry-point-16'
@size='medium'
/>
<Copyable
@text={{session.id}}
@buttonText={{t 'actions.copy-to-clipboard'}}
@acknowledgeText={{t 'states.copied'}}
>
<code>{{session.id}}</code>
</Copyable>
<SessionStatus @model={{session}} />
</row.cell>
<row.cell>
{{#if session.proxy}}
<Copyable
@text={{session.proxy}}
@buttonText={{t 'actions.copy-to-clipboard'}}
@acknowledgeText={{t 'states.copied'}}
>
<code>{{session.proxy}}</code>
</Copyable>
{{/if}}
</row.cell>
<row.cell>
<time datetime={{format-date-iso session.created_time}}>
{{format-date-iso-human session.created_time}}
</time>
</row.cell>
<row.cell>
{{#if session.isCancelable}}
<Rose::Button
@style='secondary'
{{on 'click' (route-action 'cancelSession' session)}}
>
{{t 'actions.cancel'}}
</Rose::Button>
{{/if}}
</row.cell>
</body.row>
{{/each}}
</table.body>
</Rose::Table>
{{else}}
<Rose::Layout::Centered>
<Rose::Message
@title={{t 'resources.session.messages.none-active-friendly.title'}}
as |message|
>
<message.description>
{{t 'resources.session.messages.none-active-friendly.description'}}
</message.description>
</Rose::Message>
</Rose::Layout::Centered>
{{/if}}
@@ -34,7 +34,6 @@ module('Acceptance | projects | targets', function (hooks) {
global: null,
},
target: null,
session: null,
};
const stubs = {
@@ -118,7 +117,6 @@ module('Acceptance | projects | targets', function (hooks) {
urls.projects = `${urls.scopes.org}/projects`;
urls.targets = `${urls.projects}/targets`;
urls.target = `${urls.targets}/${instances.target.id}`;
urls.sessions = `${urls.target}/sessions`;
class MockIPC {
clusterUrl = null;
@@ -1,284 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { visit, currentURL, click, find, findAll } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
import sinon from 'sinon';
import {
currentSession,
authenticateSession,
invalidateSession,
} from 'ember-simple-auth/test-support';
module('Acceptance | projects | targets | hosts', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let mockIPC;
let messageHandler;
const instances = {
scopes: {
global: null,
org: null,
project: null,
},
authMethods: {
global: null,
},
user: null,
target: null,
session: null,
};
const stubs = {
global: null,
org: null,
ipcService: null,
};
const urls = {
index: '/',
clusterUrl: '/cluster-url',
scopes: {
global: null,
org: null,
},
authenticate: {
global: null,
methods: {
global: null,
},
},
projects: null,
targets: null,
target: null,
hosts: null,
};
const setDefaultClusterUrl = (test) => {
const windowOrigin = window.location.origin;
const clusterUrl = test.owner.lookup('service:clusterUrl');
clusterUrl.rendererClusterUrl = windowOrigin;
};
hooks.beforeEach(function () {
instances.user = this.server.create('user', {
scope: instances.scopes.global,
});
authenticateSession({ user_id: instances.user.id });
// create scopes
instances.scopes.global = this.server.create('scope', { id: 'global' });
stubs.global = { id: 'global', type: 'global' };
instances.scopes.org = this.server.create('scope', {
type: 'org',
scope: stubs.global,
});
stubs.org = { id: instances.scopes.org.id, type: 'org' };
instances.scopes.project = this.server.create('scope', {
type: 'project',
scope: stubs.org,
});
stubs.project = { id: instances.scopes.project.id, type: 'project' };
instances.authMethods.global = this.server.create('auth-method', {
scope: instances.scopes.global,
});
instances.hostCatalog = this.server.create(
'host-catalog',
{ scope: instances.scopes.project },
'withChildren'
);
instances.target = this.server.create('target', {
scope: instances.scopes.project,
hostSets: instances.hostCatalog.hostSets,
});
instances.session = this.server.create(
'session',
{
scope: instances.scopes.project,
status: 'active',
},
'withAssociations'
);
urls.scopes.global = `/scopes/${instances.scopes.global.id}`;
urls.scopes.org = `/scopes/${instances.scopes.org.id}`;
urls.authenticate.global = `${urls.scopes.global}/authenticate`;
urls.authenticate.methods.global = `${urls.authenticate.global}/${instances.authMethods.global.id}`;
urls.projects = `${urls.scopes.org}/projects`;
urls.targets = `${urls.projects}/targets`;
urls.target = `${urls.targets}/${instances.target.id}`;
urls.hosts = `${urls.target}/hosts`;
class MockIPC {
clusterUrl = null;
invoke(method, payload) {
return this[method](payload);
}
getClusterUrl() {
return this.clusterUrl;
}
setClusterUrl(clusterUrl) {
this.clusterUrl = clusterUrl;
return this.clusterUrl;
}
}
mockIPC = new MockIPC();
messageHandler = async function (event) {
if (event.origin !== window.location.origin) return;
const { method, payload } = event.data;
if (method) {
const response = await mockIPC.invoke(method, payload);
event.ports[0].postMessage(response);
}
};
window.addEventListener('message', messageHandler);
setDefaultClusterUrl(this);
const ipcService = this.owner.lookup('service:ipc');
stubs.ipcService = sinon.stub(ipcService, 'invoke');
});
hooks.afterEach(function () {
window.removeEventListener('message', messageHandler);
});
test('visiting index while unauthenticated redirects to global authenticate method', async function (assert) {
invalidateSession();
assert.expect(2);
await visit(urls.hosts);
await a11yAudit();
assert.notOk(currentSession().isAuthenticated);
assert.strictEqual(currentURL(), urls.authenticate.methods.global);
});
test('visiting index', async function (assert) {
assert.expect(2);
const hostsCount = this.server.schema.hosts.all().models.length;
await visit(urls.hosts);
assert.strictEqual(currentURL(), urls.hosts);
assert.strictEqual(findAll('tbody tr').length, hostsCount);
});
test('visiting empty hosts', async function (assert) {
assert.expect(1);
instances.target.update({ hostSets: [] });
await visit(urls.hosts);
assert.ok(
find('.rose-message-title').textContent.trim(),
'No Hosts Available'
);
});
test('connecting to a host', async function (assert) {
assert.expect(3);
stubs.ipcService.withArgs('cliExists').returns(true);
stubs.ipcService.withArgs('connect').returns({
session_id: instances.session.id,
address: 'a_123',
port: 'p_123',
protocol: 'tcp',
});
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.hosts);
await click(
'tbody tr:first-child td:last-child button',
'Activate connect mode'
);
assert.ok(find('.dialog-detail'), 'Success dialog');
assert.strictEqual(
find('.rose-dialog-footer .rose-button-secondary').textContent.trim(),
'Close',
'Cannot retry'
);
assert.strictEqual(
find('.rose-dialog-body .copyable-content').textContent.trim(),
'a_123:p_123'
);
});
test('handles cli error on connect', async function (assert) {
assert.expect(4);
stubs.ipcService.withArgs('cliExists').returns(false);
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.hosts);
await click(
'tbody tr:first-child td:last-child button',
'Activate connect mode'
);
assert.ok(find('.rose-dialog-error'), 'Error dialog');
const dialogButtons = findAll('.rose-dialog-footer button');
assert.strictEqual(dialogButtons.length, 2);
assert.strictEqual(
dialogButtons[0].textContent.trim(),
'Retry',
'Can retry'
);
assert.strictEqual(
dialogButtons[1].textContent.trim(),
'Cancel',
'Can cancel'
);
});
test('handles connect error', async function (assert) {
assert.expect(4);
stubs.ipcService.withArgs('cliExists').returns(true);
stubs.ipcService.withArgs('connect').rejects();
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.hosts);
await click(
'tbody tr:first-child td:last-child button',
'Activate connect mode'
);
assert.ok(find('.rose-dialog-error'), 'Error dialog');
const dialogButtons = findAll('.rose-dialog-footer button');
assert.strictEqual(dialogButtons.length, 2);
assert.strictEqual(
dialogButtons[0].textContent.trim(),
'Retry',
'Can retry'
);
assert.strictEqual(
dialogButtons[1].textContent.trim(),
'Cancel',
'Can cancel'
);
});
test('can retry on error', async function (assert) {
assert.expect(1);
stubs.ipcService.withArgs('cliExists').rejects();
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.hosts);
await click(
'tbody tr:first-child td:last-child button',
'Activate connect mode'
);
const firstErrorDialog = find('.rose-dialog');
await click('.rose-dialog footer .rose-button-primary', 'Retry');
const secondErrorDialog = find('.rose-dialog');
assert.notEqual(secondErrorDialog.id, firstErrorDialog.id);
});
});
@@ -1,375 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { visit, currentURL, click, find, findAll } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { Response } from 'miragejs';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
import sinon from 'sinon';
import {
currentSession,
authenticateSession,
invalidateSession,
} from 'ember-simple-auth/test-support';
module('Acceptance | projects | targets | sessions', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let mockIPC;
let messageHandler;
const instances = {
scopes: {
global: null,
org: null,
project: null,
},
authMethods: {
global: null,
},
user: null,
target: null,
session: null,
};
const stubs = {
global: null,
org: null,
ipcService: null,
};
const urls = {
index: '/',
clusterUrl: '/cluster-url',
scopes: {
global: null,
org: null,
},
authenticate: {
global: null,
methods: {
global: null,
},
},
projects: null,
targets: null,
target: null,
sessions: null,
};
const setDefaultClusterUrl = (test) => {
const windowOrigin = window.location.origin;
const clusterUrl = test.owner.lookup('service:clusterUrl');
clusterUrl.rendererClusterUrl = windowOrigin;
};
hooks.beforeEach(function () {
instances.user = this.server.create('user', {
scope: instances.scopes.global,
});
authenticateSession({ user_id: instances.user.id });
// create scopes
instances.scopes.global = this.server.create('scope', { id: 'global' });
stubs.global = { id: 'global', type: 'global' };
instances.scopes.org = this.server.create('scope', {
type: 'org',
scope: stubs.global,
});
stubs.org = { id: instances.scopes.org.id, type: 'org' };
instances.scopes.project = this.server.create('scope', {
type: 'project',
scope: stubs.org,
});
stubs.project = { id: instances.scopes.project.id, type: 'project' };
instances.authMethods.global = this.server.create('auth-method', {
scope: instances.scopes.global,
});
instances.hostCatalog = this.server.create(
'host-catalog',
{ scope: instances.scopes.project },
'withChildren'
);
instances.target = this.server.create(
'target',
{ scope: instances.scopes.project },
'withAssociations'
);
instances.session = this.server.create(
'session',
{
scope: instances.scopes.project,
target: instances.target,
status: 'active',
user: instances.user,
},
'withAssociations'
);
urls.scopes.global = `/scopes/${instances.scopes.global.id}`;
urls.scopes.org = `/scopes/${instances.scopes.org.id}`;
urls.authenticate.global = `${urls.scopes.global}/authenticate`;
urls.authenticate.methods.global = `${urls.authenticate.global}/${instances.authMethods.global.id}`;
urls.projects = `${urls.scopes.org}/projects`;
urls.targets = `${urls.projects}/targets`;
urls.target = `${urls.targets}/${instances.target.id}`;
urls.sessions = `${urls.target}/sessions`;
class MockIPC {
clusterUrl = null;
invoke(method, payload) {
return this[method](payload);
}
getClusterUrl() {
return this.clusterUrl;
}
setClusterUrl(clusterUrl) {
this.clusterUrl = clusterUrl;
return this.clusterUrl;
}
}
mockIPC = new MockIPC();
messageHandler = async function (event) {
if (event.origin !== window.location.origin) return;
const { method, payload } = event.data;
if (method) {
const response = await mockIPC.invoke(method, payload);
event.ports[0].postMessage(response);
}
};
window.addEventListener('message', messageHandler);
setDefaultClusterUrl(this);
const ipcService = this.owner.lookup('service:ipc');
stubs.ipcService = sinon.stub(ipcService, 'invoke');
});
hooks.afterEach(function () {
window.removeEventListener('message', messageHandler);
});
test('visiting index while unauthenticated redirects to global authenticate method', async function (assert) {
invalidateSession();
assert.expect(2);
await visit(urls.sessions);
await a11yAudit();
assert.notOk(currentSession().isAuthenticated);
assert.strictEqual(currentURL(), urls.authenticate.methods.global);
});
test('visiting index', async function (assert) {
assert.expect(1);
await visit(urls.sessions);
assert.strictEqual(currentURL(), urls.sessions);
});
test('visiting index redirects to sessions', async function (assert) {
assert.expect(1);
await visit(urls.target);
assert.strictEqual(currentURL(), urls.sessions);
});
test('visiting empty sessions', async function (assert) {
assert.expect(1);
this.server.get('/sessions', () => new Response(200));
await visit(urls.sessions);
assert.ok(
find('.rose-message-title').textContent.trim(),
'No Sessions Available'
);
});
test('cancelling a session', async function (assert) {
assert.expect(2);
stubs.ipcService.withArgs('cliExists').returns(true);
stubs.ipcService.withArgs('connect').returns({
session_id: instances.session.id,
address: 'a_123',
port: 'p_123',
protocol: 'tcp',
});
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.sessions);
await click('.rose-layout-page-actions button', 'Activate connect mode');
await click('.rose-dialog-footer .rose-button-secondary');
const sessionsCount = findAll(
'tbody tr:first-child td:last-child button'
).length;
await click('tbody tr:first-child td:last-child button');
assert.ok(find('[role="alert"].is-success'));
assert.strictEqual(findAll('tbody tr').length, sessionsCount - 1);
});
test('cancelling a session with error shows notification', async function (assert) {
assert.expect(1);
stubs.ipcService.withArgs('cliExists').returns(true);
stubs.ipcService.withArgs('connect').returns({
session_id: instances.session.id,
address: 'a_123',
port: 'p_123',
protocol: 'tcp',
});
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
this.server.post('/sessions/:id_method', () => new Response(400));
await visit(urls.sessions);
await click('.rose-layout-page-actions button', 'Activate connect mode');
await click('.rose-dialog-footer .rose-button-secondary');
await click('tbody tr:first-child td:last-child button');
assert.ok(find('[role="alert"].is-error'));
});
test('cancelling a session with ipc error shows notification', async function (assert) {
assert.expect(1);
stubs.ipcService.withArgs('cliExists').returns(true);
stubs.ipcService.withArgs('connect').returns({
session_id: instances.session.id,
address: 'a_123',
port: 'p_123',
protocol: 'tcp',
});
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
stubs.ipcService.withArgs('stop').throws();
await visit(urls.sessions);
await click('.rose-layout-page-actions button', 'Activate connect mode');
await click('.rose-dialog-footer .rose-button-secondary');
await click('tbody tr:first-child td:last-child button');
assert.ok(find('[role="alert"].is-error'));
});
test('connecting to a target', async function (assert) {
assert.expect(3);
stubs.ipcService.withArgs('cliExists').returns(true);
stubs.ipcService.withArgs('connect').returns({
session_id: instances.session.id,
address: 'a_123',
port: 'p_123',
protocol: 'tcp',
});
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.sessions);
await click('.rose-layout-page-actions button', 'Activate connect mode');
assert.ok(find('.dialog-detail'), 'Success dialog');
assert.strictEqual(
find('.rose-dialog-footer .rose-button-secondary').textContent.trim(),
'Close',
'Cannot retry'
);
assert.strictEqual(
find('.rose-dialog-body .copyable-content').textContent.trim(),
'a_123:p_123'
);
});
test('connect details in session', async function (assert) {
assert.expect(2);
stubs.ipcService.withArgs('cliExists').returns(true);
stubs.ipcService.withArgs('connect').returns({
session_id: instances.session.id,
address: 'a_123',
port: 'p_123',
protocol: 'tcp',
});
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.sessions);
instances.session.update('status', 'active');
await click('.rose-layout-page-actions button', 'Activate connect mode');
assert.ok(find('.dialog-detail'), 'Success dialog');
await click('.rose-dialog-dismiss');
assert.strictEqual(
find(
'tbody tr:first-child td:nth-child(2) .copyable-content'
).textContent.trim(),
'a_123:p_123'
);
});
test('handles cli error on connect', async function (assert) {
assert.expect(4);
stubs.ipcService.withArgs('cliExists').returns(false);
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.sessions);
await click('.rose-layout-page-actions button', 'Activate connect mode');
assert.ok(find('.rose-dialog-error'), 'Error dialog');
const dialogButtons = findAll('.rose-dialog-footer button');
assert.strictEqual(dialogButtons.length, 2);
assert.strictEqual(
dialogButtons[0].textContent.trim(),
'Retry',
'Can retry'
);
assert.strictEqual(
dialogButtons[1].textContent.trim(),
'Cancel',
'Can cancel'
);
});
test('handles connect error', async function (assert) {
assert.expect(4);
stubs.ipcService.withArgs('cliExists').returns(true);
stubs.ipcService.withArgs('connect').rejects();
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.sessions);
await click('.rose-layout-page-actions button', 'Activate connect mode');
assert.ok(find('.rose-dialog-error'), 'Error dialog');
const dialogButtons = findAll('.rose-dialog-footer button');
assert.strictEqual(dialogButtons.length, 2);
assert.strictEqual(
dialogButtons[0].textContent.trim(),
'Retry',
'Can retry'
);
assert.strictEqual(
dialogButtons[1].textContent.trim(),
'Cancel',
'Can cancel'
);
});
test('can retry on error', async function (assert) {
assert.expect(1);
stubs.ipcService.withArgs('cliExists').rejects();
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
await visit(urls.sessions);
await click('.rose-layout-page-actions button', 'Activate connect mode');
const firstErrorDialog = find('.rose-dialog');
await click('.rose-dialog footer .rose-button-primary', 'Retry');
const secondErrorDialog = find('.rose-dialog');
assert.notEqual(secondErrorDialog.id, firstErrorDialog.id);
});
});
@@ -63,7 +63,6 @@ module('Acceptance | scopes', function (hooks) {
org2Targets: null,
globalTargets: null,
target: null,
targetSessions: null,
};
const setDefaultClusterUrl = (test) => {
@@ -129,7 +128,6 @@ module('Acceptance | scopes', function (hooks) {
urls.org2Targets = `${urls.org2Projects}/targets`;
urls.globalTargets = `${urls.globalProjects}/targets`;
urls.target = `${urls.targets}/${instances.target.id}`;
urls.targetSessions = `${urls.target}/sessions`;
class MockIPC {
clusterUrl = null;
@@ -1,22 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module(
'Unit | Controller | scopes/scope/projects/targets/target/sessions',
function (hooks) {
setupTest(hooks);
// TODO: Replace this with your real tests.
test('it exists', function (assert) {
let controller = this.owner.lookup(
'controller:scopes/scope/projects/targets/target/sessions'
);
assert.ok(controller);
});
}
);
@@ -1,21 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module(
'Unit | Route | scopes/scope/projects/targets/target/hosts',
function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup(
'route:scopes/scope/projects/targets/target/hosts'
);
assert.ok(route);
});
}
);
@@ -1,21 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module(
'Unit | Route | scopes/scope/projects/targets/target/sessions',
function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup(
'route:scopes/scope/projects/targets/target/sessions'
);
assert.ok(route);
});
}
);