Skip to content

Commit

Permalink
Merge pull request #557 from molgenis/bug/test-on-host-port-combo
Browse files Browse the repository at this point in the history
Test on port and host.
  • Loading branch information
marikaris authored Nov 23, 2023
2 parents 4ad5b8d + fae5646 commit 201b843
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions ui/src/views/Profiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,15 @@ export default defineComponent({
return profile.name;
});
const portAlreadyUsed = this.profiles.some((prof) => {
return prof !== profile && prof.port == profile.port;
});
if (portAlreadyUsed) {
this.errorMessage = `Save failed: port number [${profile.port}] already used.`;
const hostPortCombo = `${profile.host}:${profile.port}`;
const hasDuplicates = this.profiles.some(
(prof) =>
prof !== profile && `${prof.host}:${prof.port}` === hostPortCombo
);
if (hasDuplicates) {
this.errorMessage = `Save failed: [${hostPortCombo}] already used.`;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/tests/unit/views/Profiles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe("Profiles", () => {
wrapper.vm.profiles.unshift(p);
wrapper.vm.profileToEditIndex = 0;
wrapper.vm.saveEditedProfile();
expect(wrapper.vm.errorMessage).toBe("Save failed: port number [6313] already used.");
expect(wrapper.vm.errorMessage).toBe("Save failed: [localhost:6313] already used.");
});

test("fail to save a unnamed profile", () => {
Expand Down

0 comments on commit 201b843

Please sign in to comment.