diff --git a/src/delivery-options/DeliveryOptions.vue b/src/delivery-options/DeliveryOptions.vue index 9603e320..4ec3429f 100644 --- a/src/delivery-options/DeliveryOptions.vue +++ b/src/delivery-options/DeliveryOptions.vue @@ -79,6 +79,13 @@ export default { */ fakeShowDeliveryOptions: true, + /** + * Whether the delivery options are initialized. + * + * @type {boolean} + */ + initialized: false, + /** * Whether the delivery options are loading or not. * @@ -140,12 +147,12 @@ export default { computed: { /** - * False if address or address.cc is missing. + * False if `address`, `address.cc` or `address.street` is missing. * * @returns {boolean} */ hasValidAddress() { - return Boolean(this.$configBus.address && this.$configBus.address.cc); + return Boolean(this.$configBus.address && this.$configBus.address.cc && this.$configBus.address.street); }, /** @@ -238,6 +245,8 @@ export default { }, ], }; + + this.initialized = true; }, /** @@ -282,8 +291,11 @@ export default { this.showSelf(); if (!this.hasValidAddress) { - this.showAddressErrors(); + if (this.initialized) { + this.showAddressErrors(); + } + this.loading = false; return; } diff --git a/tests/unit/delivery-options/components/DeliveryOptions.spec.js b/tests/unit/delivery-options/components/DeliveryOptions.spec.js index a527f2ff..3feff1f0 100644 --- a/tests/unit/delivery-options/components/DeliveryOptions.spec.js +++ b/tests/unit/delivery-options/components/DeliveryOptions.spec.js @@ -68,31 +68,6 @@ describe('DeliveryOptions.vue', () => { expect(wrapper.vm.hasValidAddress).toBe(true); }); - it('shows retry button on missing cc', async() => { - expect.assertions(2); - - const wrapper = mockDeliveryOptions({ - [ADDRESS.KEY]: {}, - [CONFIG.KEY]: { - [CONFIG.FEATURE_ALLOW_RETRY]: true, - }, - }); - wrapper.vm.showAddressErrors = createWaitableMock(wrapper.vm.showAddressErrors); - - await wrapper.vm.showAddressErrors.waitToHaveBeenCalled(1); - expect(wrapper.findByTestId('button--retry').exists()).toBe(true); - - // Change address to a valid address. - document.dispatchEvent( - new CustomEvent(UPDATE_DELIVERY_OPTIONS, { - detail: configWithValidAddress, - }), - ); - - await waitForEvent(UPDATED_DELIVERY_OPTIONS); - expect(wrapper.findByTestId('button--retry').exists()).toBe(false); - }); - it('shows errors on invalid address response from api', async() => { expect.assertions(2); fakeDeliveryOptionsResponse.mockImplementation(deliveryOptionsResponseInvalidPostalCode);