Merge pull request #291 from Safelite/feature/CSR-319

CSR-319: expand Alert component to allow for multiple paragraphs
This commit is contained in:
AdamCaouetteSafelite 2022-03-16 08:59:42 -04:00 committed by GitHub
commit 2883bdc4d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 5 deletions

View file

@ -1129,6 +1129,16 @@
/>
</div>
</div>
<div class="row my-2">
<div class="col">
<alert
alertClass="alert-success"
alertHeadline="Multi-Paragraph Alert"
:alertCopy="['This is an example of a MULTI-PARAGRAPH alert, which takes an array of strings instead of a single string value for alertCopy.', 'This is the second item in the array of strings.']"
v-bind:isDismissible="false"
/>
</div>
</div>
</div>
</template>

View file

@ -26,7 +26,7 @@
v-show="hasRepairReplaceConflict"
alertClass="alert-danger"
alertHeadline="You'll need to schedule separate appointments"
alertCopy="Vehicle service requiring both glass repair and replacement must be scheduled separately, as they're performed by different technicians. Continue scheduling your first service now, and then come back to schedule the second service."
:alertCopy="['Vehicle service requiring both glass repair and replacement must be scheduled separately, as they\'re performed by different technicians.', 'Continue scheduling your first service now, and then come back to schedule the second service.']"
:isDismissible="false"
/>
<sideDoorOptions

View file

@ -12,7 +12,7 @@
v-show="showNoReplacementAvailableError"
alertClass="alert-danger"
alertHeadline="Service not available"
alertCopy="We're sorry, but we currently offer only repair service for your vehicle type. Need help with next steps? Call us at 800-394-0288."
:alertCopy="['We\'re sorry, but we currently offer only repair service for your vehicle type.', 'Need help with next steps? Call us at 800-394-0288.']"
:isDismissible="false"
/>
<windshieldChipCountQuestion ref="windshieldChipCountQuestion"

View file

@ -1 +1,30 @@
test.todo("some test to be written in the future");
import { shallowMount } from "@vue/test-utils";
import alert from "./alert";
describe("alert.vue", () => {
it("Should set isMultiParagraph to true if alertCopy is an array of strings", async () => {
// Arrange
const wrapper = shallowMount(alert, {
propsData: {
alertCopy: ["one", "two"]
},
});
// Assert
expect(wrapper.vm.isMultiParagraph).toBe(true);
});
it("Should set isMultiParagraph to false if alertCopy is a single string", async () => {
// Arrange
const wrapper = shallowMount(alert, {
propsData: {
alertCopy: "three"
},
});
// Assert
expect(wrapper.vm.isMultiParagraph).toBe(false);
});
});

View file

@ -5,7 +5,12 @@
:class="[isDismissible ? 'alert-dismissible' : '', this.alertClass]"
>
<p class="m-0 fw-bold small alert-heading">{{ alertHeadline }}</p>
<p class="m-0 text-body small">{{ alertCopy }}</p>
<span v-if="isMultiParagraph">
<p class="m-1 text-body small" v-for="(para, index) in alertCopy" :key="index">
{{ para }}
</p>
</span>
<p class="m-0 text-body small" v-else>{{ alertCopy }}</p>
<button
type="button"
class="btn-close p-2"
@ -30,7 +35,7 @@ export default {
name: "alert",
props: {
alertHeadline: String,
alertCopy: String,
alertCopy: [Array, String],
isDismissible: Boolean,
/*
alertClass class names:
@ -41,6 +46,14 @@ export default {
*/
alertClass: String,
},
computed: {
isMultiParagraph() {
if (typeof this.alertCopy == "string") {
return false;
}
return true;
}
},
};
</script>