feat: 🎸 redirect to targets list when canceling (#1866)
from the sessions detail screen
✅ Closes: ICU-10760
This commit is contained in:
1 parent
4dcf1675ba
commit
9ce79b3d14
3 files changed
+31
-3
No files matched your search
@@ -95,6 +95,12 @@ export default class ScopesScopeProjectsSessionsRoute extends Route {
|
||||
async cancelSession(session) {
|
||||
await session.cancelSession();
|
||||
await this.ipc.invoke('stop', { session_id: session.id });
|
||||
if (
|
||||
this.router.currentRoute.name ===
|
||||
'scopes.scope.projects.sessions.session.index'
|
||||
) {
|
||||
await this.router.replaceWith('scopes.scope.projects.targets');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -269,7 +269,7 @@ module('Acceptance | projects | sessions', function (hooks) {
|
||||
.isVisible();
|
||||
});
|
||||
|
||||
test('cancelling a session', async function (assert) {
|
||||
test('cancelling a session shows success alert', async function (assert) {
|
||||
assert.expect(1);
|
||||
stubs.ipcService.withArgs('stop');
|
||||
|
||||
@@ -279,6 +279,16 @@ module('Acceptance | projects | sessions', function (hooks) {
|
||||
assert.dom('[role="alert"].is-success').isVisible();
|
||||
});
|
||||
|
||||
test('cancelling a session keeps you on the sessions list screen', async function (assert) {
|
||||
assert.expect(1);
|
||||
stubs.ipcService.withArgs('stop');
|
||||
|
||||
await visit(urls.sessions);
|
||||
await click('tbody tr:first-child td:last-child button');
|
||||
|
||||
assert.strictEqual(currentURL(), urls.sessions);
|
||||
});
|
||||
|
||||
test('cancelling a session with error shows notification', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/sessions/:id_method', () => new Response(400));
|
||||
|
||||
@@ -53,6 +53,7 @@ module('Acceptance | projects | sessions | session', function (hooks) {
|
||||
},
|
||||
},
|
||||
projects: null,
|
||||
targets: null,
|
||||
target: null,
|
||||
sessions: null,
|
||||
session: null,
|
||||
@@ -109,7 +110,8 @@ module('Acceptance | projects | sessions | session', function (hooks) {
|
||||
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.target = `${urls.projects}/targets/${instances.target.id}`;
|
||||
urls.targets = `${urls.projects}/targets`;
|
||||
urls.target = `${urls.targets}/${instances.target.id}`;
|
||||
urls.sessions = `${urls.projects}/sessions`;
|
||||
urls.session = `${urls.projects}/sessions/${instances.session.id}`;
|
||||
|
||||
@@ -181,7 +183,7 @@ module('Acceptance | projects | sessions | session', function (hooks) {
|
||||
.hasText(`Connected You can now access ${instances.target.name}`);
|
||||
});
|
||||
|
||||
test('cancelling a session', async function (assert) {
|
||||
test('cancelling a session shows success alert', async function (assert) {
|
||||
assert.expect(1);
|
||||
stubs.ipcService.withArgs('stop');
|
||||
|
||||
@@ -191,6 +193,16 @@ module('Acceptance | projects | sessions | session', function (hooks) {
|
||||
assert.dom('[role="alert"].is-success').isVisible();
|
||||
});
|
||||
|
||||
test('cancelling a session takes you to the targets list screen', async function (assert) {
|
||||
assert.expect(1);
|
||||
stubs.ipcService.withArgs('stop');
|
||||
|
||||
await visit(urls.session);
|
||||
await click('[data-test-session-detail-cancel-button]');
|
||||
|
||||
assert.strictEqual(currentURL(), urls.targets);
|
||||
});
|
||||
|
||||
test('cancelling a session with error shows notification', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/sessions/:id_method', () => new Response(400));
|
||||
|
||||
Reference in new issue
Block a user