diff --git a/src/components/EditProfile.vue b/src/components/EditProfile.vue index 2bba2582cf84e73bd70db91d16128476c35b6b87..8725cfe22726c81985687fb8185ed436f4f12b77 100644 --- a/src/components/EditProfile.vue +++ b/src/components/EditProfile.vue @@ -124,13 +124,10 @@ export default { }).catch(error=> { console.log(error) if (error.message === '400') { - if(newRestricted){ - this.alertMsg = '‼ï¸Det oppsto en feil: Sørg for at det finnes mist en standard profil pÃ¥ kontoenâ€¼ï¸ ' } else if(this.updatedProfile.name !== this.initialName || this.updatedProfile.name) { this.alertMsg = '‼ï¸Det oppsto en feil: Det finnes allerede en bruker med samme navn‼ï¸' - } }else{ this.alertMsg = "‼ï¸Det oppsto en feil.‼ï¸" diff --git a/src/components/__tests__/EditProfile.spec.js b/src/components/__tests__/EditProfile.spec.js index ac7c84b89dac0f269fef64d8405726b8f16c768f..f78db12586fa2a935f9067aba276d8dbfa1e8cf3 100644 --- a/src/components/__tests__/EditProfile.spec.js +++ b/src/components/__tests__/EditProfile.spec.js @@ -20,7 +20,7 @@ describe('EditProfile', () => { const store = useAuthStore(pinia) store.profile = { name:"Ola", - restricted:false, + restricted:true, profileImageUrl:"some/valid/image.png" } @@ -29,4 +29,36 @@ describe('EditProfile', () => { const unameInput = wrapper.find('#brukernavn'); expect(unameInput.element.value).to.contain('Ola'); }) + + it('If profile.restricted is true, then radio input with value false is not selected', () => { + const radioInput = wrapper.find('input[type=radio][value="false"]') + expect(radioInput.element.checked).toBe(false) + }) + + it('If profile.restricted is true, then radio input with valuetrue *is* selected', () => { + const radioInput = wrapper.find('input[type=radio][value="true"]') + expect(radioInput.element.checked).toBe(true) + }) + + //update the value from restricted true -> false + it('After changing restricted radio, the values are updated too', async () => { + const notRestrictedRadioInput = wrapper.find('#normal') + const restrictedRadioInput = wrapper.find('#restricted') + + expect(notRestrictedRadioInput.element.checked).toBe(false) + expect(restrictedRadioInput.element.checked).toBe(true) + + await notRestrictedRadioInput.trigger('click') + + expect(notRestrictedRadioInput.element.checked).toBe(true) + expect(restrictedRadioInput.element.checked).toBe(false) + + await wrapper.vm.$nextTick() + + setTimeout(() => { + expect(wrapper.vm.updatedProfile.upRestricted).toBe(false) + }, 1000); + }) + + }) \ No newline at end of file