diff --git a/frontend/app/components/folder/show.js b/frontend/app/components/folder/show.js index 1f91cf27d..ddcfbb3f4 100644 --- a/frontend/app/components/folder/show.js +++ b/frontend/app/components/folder/show.js @@ -37,6 +37,7 @@ export default class ShowComponent extends Component { @action toggleEncryptableCredentialCreating() { + this.navService.selectedFolder = this.args.folder; this.isNewEncryptableCredential = !this.isNewEncryptableCredential; } diff --git a/frontend/tests/integration/components/encryptable/form-test.js b/frontend/tests/integration/components/encryptable/form-test.js index 942d654b5..04267290f 100644 --- a/frontend/tests/integration/components/encryptable/form-test.js +++ b/frontend/tests/integration/components/encryptable/form-test.js @@ -28,8 +28,26 @@ const navServiceStub = Service.extend({ return 2; } } - ] + ], /* eslint-enable ember/avoid-leaking-state-in-ember-objects */ + selectedFolder: { + id: 1, + name: "bbt", + teamId: 1, + team: { + id: 1, + name: "bbteam", + get() { + return 1; + } + }, + get(property) { + if (property === "team") { + return this.team; + } + return this[property]; + } + } }); const userServiceStub = Service.extend({ @@ -115,7 +133,7 @@ module("Integration | Component | encryptable/form", function (hooks) { this.element .querySelector("#team-power-select") .innerText.replace(/\s+/g, " "), - "Team Select a Team" + "Team bbteam" ); await selectChoose( @@ -179,7 +197,7 @@ module("Integration | Component | encryptable/form", function (hooks) { this.element .querySelector("#team-power-select") .innerText.replace(/\s+/g, " "), - "Team Wähle ein Team aus" + "Team bbteam" ); await selectChoose( @@ -243,7 +261,7 @@ module("Integration | Component | encryptable/form", function (hooks) { this.element .querySelector("#team-power-select") .innerText.replace(/\s+/g, " "), - "Team Wähl äs Team us" + "Team bbteam" ); await selectChoose( @@ -314,7 +332,7 @@ module("Integration | Component | encryptable/form", function (hooks) { this.element .querySelector("#team-power-select") .innerText.replace(/\s+/g, " "), - "Équipe Choisissez une équipe" + "Équipe bbteam" ); await selectChoose( @@ -543,4 +561,25 @@ module("Integration | Component | encryptable/form", function (hooks) { assert.ok(this.element.textContent.trim().includes("Team")); assert.ok(this.element.textContent.trim().includes("bob")); }); + + + test("Check prefill of team and folder", async function (assert) { + setLocale("en"); + + await render(hbs``); + + assert.equal( + this.element + .querySelector("#team-power-select .ember-power-select-selected-item") + .innerText.replace(/\s+/g, " "), + "bbteam" + ); + + assert.equal( + this.element + .querySelector("#folder-power-select .ember-power-select-selected-item") + .innerText.replace(/\s+/g, " "), + "bbt" + ); + }); });