Merge pull request #1012 from Safelite/feature/CSR-1214-release

Disable image uploading when input is disabled.
This commit is contained in:
chloeherdsafelite 2023-03-16 14:34:59 -04:00 committed by GitHub
commit 6bccaf6009
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 13 deletions

View file

@ -330,4 +330,33 @@ describe("textboxQuestion.vue", () => {
expect(wrapper.vm.handleChange).not.toHaveBeenCalled();
expect(wrapper.emitted()).toHaveProperty("imageLookupError");
});
it("Should not display camera or spinner icon when disabled", () => {
// Arrange
const inputId = "test";
const wrapper = shallowMount(textboxQuestion, {
global: {
directives: {
maska: maska,
},
},
propsData: {
modelValue: "",
includeCameraIcon: true,
inputId: inputId,
isDisabled: true,
},
mixins: [mockMixin],
attachTo: document.body,
});
// Act
const cameraIcon = wrapper.find('[data-test="image-upload"]');
const loadingIcon = wrapper.findComponent("loader");
// Assert
expect(cameraIcon.exists()).toBe(false);
expect(loadingIcon.exists()).toBe(false);
});
});

View file

@ -36,19 +36,21 @@
:maxlength="maxLength ? maxLength : '999'"
@focus="$emit('focus', $event.target.value)" />
<button v-if="includeSearchIcon" type="submit" aria-label="Search button" />
<label class="camera-icon-input" v-show="includeCameraIcon && !isLoading">
<input
type="file"
id="vin-input"
accept="image/jpeg,image/png"
aria-label="Camera icon/button"
data-test="image-upload"
@change="submitImage" />
</label>
<loader
v-show="includeCameraIcon && isLoading"
loaderColor="blue"
class="loading-icon"></loader>
<template v-if="!isDisabled">
<label class="camera-icon-input" v-show="includeCameraIcon && !isLoading">
<input
type="file"
id="vin-input"
accept="image/jpeg,image/png"
aria-label="Camera icon/button"
data-test="image-upload"
@change="submitImage" />
</label>
<loader
v-show="includeCameraIcon && isLoading"
loaderColor="blue"
class="loading-icon"></loader>
</template>
</div>
<div v-show="errorMessage" class="row my-2 form-test-error">
<span class="d-inline-flex mt-0" role="alert">{{ errorMessage }}</span>