@wikala/spmkt 2.31.1 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/MIGRATION_GUIDE.md +310 -0
  2. package/api/product.js +1 -0
  3. package/api/request.js +12 -6
  4. package/api/user.js +1 -1
  5. package/components/Account/AccountDashboard.vue +101 -101
  6. package/components/Account/AccountStore.js +57 -31
  7. package/components/Account/AffiliateReport.vue +56 -60
  8. package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
  9. package/components/Account/Orders/Orders.vue +124 -0
  10. package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
  11. package/components/Account/Settings/ChangeEmail.vue +136 -0
  12. package/components/Account/Settings/ChangeName.vue +82 -0
  13. package/components/Account/Settings/ChangePassword.vue +91 -0
  14. package/components/Address/Address.vue +38 -57
  15. package/components/Address/AddressBook.vue +77 -57
  16. package/components/Address/AddressSelect.vue +94 -87
  17. package/components/Address/Edit.vue +253 -265
  18. package/components/Address/PostalCode.vue +22 -21
  19. package/components/AgeGate.vue +11 -5
  20. package/components/Auth/Login.vue +62 -44
  21. package/components/Auth/Register.vue +82 -60
  22. package/components/Auth/ResetPassword.vue +45 -30
  23. package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
  24. package/components/Cart/CartBadge.vue +15 -4
  25. package/components/Cart/CartBox.vue +19 -11
  26. package/components/Cart/CartItem.vue +3 -3
  27. package/components/Cart/CartMode.vue +6 -5
  28. package/components/Cart/CartPreview.vue +24 -18
  29. package/components/Cart/CreditCard/Everyware.vue +10 -10
  30. package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
  31. package/components/Cart/CreditCard/SquarePay.vue +18 -16
  32. package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
  33. package/components/Cart/Delivery/Delivery.vue +16 -12
  34. package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
  35. package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
  36. package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
  37. package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
  38. package/components/Cart/Delivery/ReservationSlots.vue +14 -8
  39. package/components/Cart/Disclaimer.vue +1 -1
  40. package/components/Cart/OrderConfirmation.vue +1 -1
  41. package/components/Cart/Payment/Payment.vue +37 -33
  42. package/components/Cart/Payment/PaymentMethods.vue +6 -4
  43. package/components/Cart/ReviewAndSubmit.vue +9 -7
  44. package/components/Cart/ShoppingCart.vue +42 -31
  45. package/components/Cart/Store/actions.js +1 -1
  46. package/components/Cart/Store/getters.js +2 -1
  47. package/components/Cart/Store/index.js +1 -1
  48. package/components/Cart/Store/mutations.js +9 -7
  49. package/components/Cart/Store/state.js +2 -2
  50. package/components/Cart/UserIdentity.vue +1 -1
  51. package/components/Category/CategoryFilter.vue +128 -114
  52. package/components/Category/CategorySort.vue +44 -32
  53. package/components/Category/LoadMore.vue +39 -23
  54. package/components/DeliverTo.vue +10 -15
  55. package/components/DeliveryNotice.vue +72 -68
  56. package/components/DobInput.vue +24 -24
  57. package/components/Gmaps/GmapsAutocomplete.vue +139 -78
  58. package/components/Gmaps/GmapsLocations.vue +1 -1
  59. package/components/Gmaps/GmapsSingleLocation.vue +121 -87
  60. package/components/MobileMenu/icons/LeftArrowIcon.vue +1 -1
  61. package/components/MobileMenu/icons/MenuIcon.vue +1 -1
  62. package/components/MobileMenu/icons/RightArrowIcon.vue +1 -1
  63. package/components/ModalContainer/ModalContainer.vue +20 -13
  64. package/components/ModalContainer/index.js +62 -18
  65. package/components/Product/AddToCart.vue +237 -221
  66. package/components/Product/BoxAddToCart.vue +114 -86
  67. package/components/Product/Compare.vue +91 -49
  68. package/components/Product/CompareBox.vue +128 -123
  69. package/components/Product/Lookup.vue +92 -65
  70. package/components/Product/Photo.vue +105 -66
  71. package/components/Product/Price.vue +64 -43
  72. package/components/Product/ProductAutocomplete.vue +52 -57
  73. package/components/Product/ProductBox.vue +61 -38
  74. package/components/Product/ProductImages.vue +83 -86
  75. package/components/Product/Quantity.vue +115 -53
  76. package/components/Product/QuickView.vue +52 -45
  77. package/components/Product/RelatedProducts.vue +88 -23
  78. package/components/Product/SKU.vue +27 -8
  79. package/components/Product/Variants.vue +336 -342
  80. package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
  81. package/components/Product/reviews-questions/ProductReviews.vue +122 -107
  82. package/components/Product/reviews-questions/Review.vue +54 -59
  83. package/components/Product/reviews-questions/ReviewForm.vue +222 -170
  84. package/components/Product/reviews-questions/ReviewImages.vue +197 -216
  85. package/components/Product/reviews-questions/Vote.vue +83 -57
  86. package/components/QuantityInput.vue +18 -8
  87. package/components/RangeInput.vue +15 -8
  88. package/components/Recaptcha.vue +8 -1
  89. package/components/SelectShippingCountry.vue +81 -62
  90. package/components/TimedOffer.vue +59 -74
  91. package/composables/globals.js +53 -0
  92. package/config.js +5 -2
  93. package/index.js +41 -10
  94. package/install.js +88 -0
  95. package/locales/en.json +2 -1
  96. package/locales/sr.json +2 -1
  97. package/package.json +49 -37
  98. package/utils/animate.css +50 -0
  99. package/utils/animate.js +1 -1
  100. package/utils/buefy.js +62 -0
  101. package/utils/directives.js +28 -45
  102. package/utils/event-bus.js +56 -0
  103. package/utils/filters.js +24 -7
  104. package/utils/format-date.js +17 -0
  105. package/utils/{gmaps.js → google/gmaps.js} +43 -10
  106. package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
  107. package/utils/random-id.js +10 -0
  108. package/babel.config.js +0 -5
  109. package/components/Account/ChangeEmail.vue +0 -133
  110. package/components/Account/ChangeName.vue +0 -92
  111. package/components/Account/ChangePassword.vue +0 -94
  112. package/components/Account/CreditCards.vue +0 -18
  113. package/components/Account/Orders.vue +0 -110
  114. package/components/Account/Settings.vue +0 -18
  115. package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
  116. package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
  117. package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
  118. package/components/Instagram.vue +0 -49
  119. package/components/ProductImageModal.vue +0 -41
  120. package/jest.config.js +0 -16
  121. package/test/e2e/.babelrc.js +0 -8
  122. package/test/e2e/.eslintrc.js +0 -11
  123. package/test/e2e/accAuth.spec.js +0 -64
  124. package/test/e2e/ageGate.spec.js +0 -26
  125. package/test/e2e/checkout.spec.js +0 -106
  126. package/test/e2e/compare.spec.js +0 -52
  127. package/test/e2e/config/data.js +0 -21
  128. package/test/e2e/config/routes.js +0 -11
  129. package/test/e2e/region.spec.js +0 -46
  130. package/test/e2e/search.spec.js +0 -32
  131. package/tests/vueBuefy.js +0 -4
  132. package/tsconfig.json +0 -8
@@ -1,133 +0,0 @@
1
- <template>
2
- <div class="email-wrapper column-wrapper">
3
- <div class="email-header">
4
- <p>{{ $t('global.email') }}</p>
5
- </div>
6
- <div class="columns is-gapless email">
7
- <div class="column is-one-third">
8
- <div class="current-email">
9
- <p>{{ $t('account.currentEmail') }}</p>
10
- <p class="email-address">{{ userData.email }}</p>
11
- </div>
12
- <div class="email-status">
13
- <p class="status">{{ $t('global.status') }}</p>
14
- <p class="confirmed" v-if="userData.email_confirmed">{{ $t('global.confirmed') }}</p>
15
- <p class="not-confirmed" v-if="!userData.email_confirmed">{{ $t('global.unconfirmed') }}</p>
16
- <div v-if="!userData.email_confirmed">
17
- <button @click="resendConfirmation" :class="['button', {'is-loading': resendLoading}]" type="button">{{ $t('account.resendConfirmation') }}</button>
18
- </div>
19
- </div>
20
- </div>
21
- </div>
22
- <div class="columns-wrapper">
23
- <div class="columns is-gapless">
24
- <div class="column is-one-third">
25
- <p class="email-headline">{{ $t('account.changeEmailTitle') }}</p>
26
-
27
- <b-field
28
- :label="$t('account.lYourPassword')"
29
- label-position="inside"
30
- :type="{ 'is-danger': errors.current_password }"
31
- :message="errors.current_password"
32
- >
33
- <b-input native-value="inside" type="password" @input="clearError('current_password')" v-model="userData.current_password"></b-input>
34
- </b-field>
35
-
36
- <b-field :label="$t('account.lNewEmail')" label-position="inside" :type="{ 'is-danger': errors.email }" :message="errors.email">
37
- <b-input native-value="inside" @input="clearError('email')" v-model="userData.email"></b-input>
38
- </b-field>
39
-
40
- <b-field :label="$t('account.lConfirmNewEmail')" label-position="inside" :type="{ 'is-danger': errors.email }" :message="errors.email">
41
- <b-input native-value="inside" label-position="inside" @input="clearError('email')" v-model="userData.email_confirmation"></b-input>
42
- </b-field>
43
- </div>
44
-
45
- <div class="column"></div>
46
- </div>
47
-
48
- <button type="button" @click="warningMessage" class="button is-primary change-email">{{ $t('account.changeEmail') }}</button>
49
- </div>
50
- </div>
51
- </template>
52
-
53
- <script>
54
-
55
- import config from '../../config'
56
- import { request, User} from '../../api'
57
-
58
- export default {
59
- name: 'ChangeEmail',
60
-
61
- props: {
62
- userData: Object
63
- },
64
-
65
- data() {
66
- return {
67
- errors: {},
68
- resendLoading: false
69
- }
70
- },
71
-
72
- methods: {
73
- submit() {
74
- User.updateEmail(this.userData)
75
- .then((response) => {
76
- if (response.status === 200 || response.status === 201) {
77
- this.$buefy.toast.open({
78
- message: this.$t('account.emailUpdatedNotification'),
79
- type: 'is-success'
80
- })
81
- } else {
82
- this.$buefy.dialog.alert({
83
- title: this.$t('account.emailUpdateDialogTitle'),
84
- message: this.$t('account.emailUpdateErrorNotification'),
85
- confirmText: 'OK',
86
- type: 'is-info'
87
- })
88
- }
89
- })
90
- .catch((error) => {
91
- if (error.errors !== undefined) {
92
- this.errors = error.errors
93
- }
94
- })
95
- },
96
-
97
- async resendConfirmation() {
98
- this.resendLoading = true
99
- await request({
100
- baseURL: config.BASE_URL,
101
- url: '/account/resend-verification',
102
- method: 'post',
103
- data: {}
104
- })
105
- this.$buefy.dialog.alert({
106
- title: 'Success',
107
- message: 'Check your email for confirmation link.',
108
- confirmText: 'OK',
109
- type: 'is-info'
110
- })
111
- this.resendLoading = false
112
- },
113
-
114
- clearError(field) {
115
- if (this.errors[field]) {
116
- this.errors[field] = ''
117
- }
118
- },
119
-
120
- warningMessage() {
121
- this.$buefy.dialog.confirm({
122
- title: this.$t('account.emailUpdateDialogTitle'),
123
- message: this.$t('account.emailUpdateConfirm'),
124
- confirmText: 'Ok',
125
- type: 'is-success',
126
- onConfirm: () => {
127
- this.submit()
128
- }
129
- })
130
- }
131
- }
132
- }
133
- </script>
@@ -1,92 +0,0 @@
1
- <template>
2
- <div class="name-wrapper">
3
- <div class="name-header">
4
- <p>{{ $t('account.memberSince') }}</p>
5
- <p>{{ userData.member_since }}</p>
6
- </div>
7
-
8
- <div class="columns is-gapless">
9
- <div class="column is-one-third">
10
- <b-field :label="$t('address.firstName')" label-position="inside" :type="{ 'is-danger': errors.first_name }" :message="errors.first_name">
11
- <b-input native-value="inside" @input="clearError('first_name')" v-model="userData.first_name"></b-input>
12
- </b-field>
13
-
14
- <b-field :label="$t('address.lastName')" label-position="inside" :type="{ 'is-danger': errors.last_name }" :message="errors.last_name">
15
- <b-input native-value="inside" @input="clearError('last_name')" v-model="userData.last_name"></b-input>
16
- </b-field>
17
-
18
- <dob-input
19
- v-if="parseInt(initialState.age_verification.enabled)"
20
- :value="userData.date_of_birth"
21
- :error="errors.date_of_birth"
22
- @input="onDobInput"
23
- ></dob-input>
24
- </div>
25
- </div>
26
-
27
- <button type="button" @click="warningMessage" class="button is-primary change-name">{{ $t('global.save') }}</button>
28
- </div>
29
- </template>
30
-
31
- <script>
32
- import { User } from '../../api'
33
-
34
- import DobInput from '../../components/DobInput'
35
-
36
- export default {
37
- name: 'ChangeName',
38
- components: { DobInput },
39
- props: {
40
- userData: Object
41
- },
42
-
43
- data() {
44
- return {
45
- errors: {}
46
- }
47
- },
48
-
49
- methods: {
50
- onDobInput(val) {
51
- this.userData.date_of_birth = val
52
- },
53
-
54
- submit() {
55
- User.updateName(this.userData)
56
- .then(() => {
57
- this.$buefy.toast.open({
58
- message: this.$t('account.savedNotification'),
59
- type: 'is-success'
60
- })
61
- })
62
- .catch((error) => {
63
- if (error.errors !== undefined) {
64
- this.errors = error.errors
65
- }
66
- })
67
-
68
- User.updateDateOfBirth(this.userData).catch((error) => {
69
- this.errors = error.errors
70
- })
71
- },
72
-
73
- clearError(field) {
74
- if (this.errors[field]) {
75
- this.errors[field] = ''
76
- }
77
- },
78
-
79
- warningMessage() {
80
- this.$buefy.dialog.confirm({
81
- title: this.$t('account.dialogTitle'),
82
- message: this.$t('account.confirm'),
83
- confirmText: 'Ok',
84
- type: 'is-info',
85
- onConfirm: () => {
86
- this.submit()
87
- }
88
- })
89
- }
90
- }
91
- }
92
- </script>
@@ -1,94 +0,0 @@
1
- <template>
2
- <div class="password-wrapper column-wrapper">
3
- <div class="password-header">
4
- <p>Password</p>
5
- </div>
6
- <div class="columns-wrapper">
7
- <div class="columns is-gapless">
8
- <div class="column is-one-third">
9
- <b-field
10
- :label="$t('account.lCurrentPassword')"
11
- label-position="inside"
12
- :type="{ 'is-danger': errors.current_password }"
13
- :message="errors.current_password"
14
- >
15
- <b-input type="password" native-value="inside" @input="clearError('current_password')" v-model="user.current_password"></b-input>
16
- </b-field>
17
-
18
- <b-field :label="$t('account.lNewPassword')" label-position="inside" :type="{ 'is-danger': errors.new_password }" :message="errors.new_password">
19
- <b-input type="password" native-value="inside" @input="clearError('new_password')" v-model="user.new_password"></b-input>
20
- </b-field>
21
-
22
- <b-field :label="$t('account.lConfirmNewPassword')" label-position="inside">
23
- <b-input type="password" native-value="inside" @input="clearError('new_password')" v-model="user.new_password_confirmation"></b-input>
24
- </b-field>
25
- </div>
26
-
27
- <div class="column"></div>
28
- </div>
29
-
30
- <button type="button" @click="warningMessage" class="button is-primary change-password">{{ $t('account.changePassword') }}</button>
31
- </div>
32
- </div>
33
- </template>
34
-
35
- <script>
36
- import { User } from '../../api'
37
-
38
- export default {
39
- name: 'ChangePassword',
40
- data() {
41
- return {
42
- errors: {},
43
- user: {
44
- current_password: '',
45
- new_password: '',
46
- new_password_confirmation: ''
47
- }
48
- }
49
- },
50
- methods: {
51
- submit() {
52
- User.updatePassword(this.user)
53
- .then((response) => {
54
- if (response.status === 200 || response.status === 201) {
55
- this.$buefy.toast.open({
56
- message: this.$t('account.passwordChangedNotification'),
57
- type: 'is-success'
58
- })
59
- } else {
60
- this.$buefy.dialog.alert({
61
- title: this.$t('account.dialogTitle'),
62
- message: this.$t('account.passwordChangeErrorNotification'),
63
- confirmText: 'OK',
64
- type: 'is-info'
65
- })
66
- }
67
- })
68
- .catch((error) => {
69
- if (error.errors !== undefined) {
70
- this.errors = error.errors
71
- }
72
- })
73
- },
74
-
75
- clearError(field) {
76
- if (this.errors[field]) {
77
- this.errors[field] = ''
78
- }
79
- },
80
-
81
- warningMessage() {
82
- this.$buefy.dialog.confirm({
83
- title: this.$t('account.dialogTitle'),
84
- message: this.$t('account.passwordChangeConfirm'),
85
- confirmText: 'Ok',
86
- type: 'is-info',
87
- onConfirm: () => {
88
- this.submit()
89
- }
90
- })
91
- }
92
- }
93
- }
94
- </script>
@@ -1,18 +0,0 @@
1
- <template>
2
- <div>
3
- <p>Credit Cards</p>
4
- </div>
5
- </template>
6
-
7
-
8
- <script>
9
- export default {
10
- name:'CreditCards',
11
- data() {
12
- return {
13
-
14
- }
15
- },
16
- }
17
-
18
- </script>
@@ -1,110 +0,0 @@
1
- <template>
2
- <div>
3
- <b-table v-if="!showOrderDetail && orders.length !== 0" :data="orders" :selected.sync="selected" :hoverable="true" @select="select" class="orders-table">
4
- <b-table-column v-slot="props" field="id" label="ID" width="40" numeric sortable>
5
- {{ props.row.id }}
6
- </b-table-column>
7
-
8
- <b-table-column v-slot="props" field="date" label="Date" width="60" sortable>
9
- <span class="tag">
10
- {{ new Date(props.row.date).toLocaleDateString() }}
11
- </span>
12
- </b-table-column>
13
-
14
- <b-table-column v-slot="props" field="total" label="Total" width="200" numeric sortable>
15
- {{ props.row.total }}
16
- </b-table-column>
17
-
18
- <b-table-column v-slot="props" field="order_status.name" label="Status">
19
- {{ props.row.order_status.name }}
20
- </b-table-column>
21
- </b-table>
22
-
23
- <div v-if="!orders.length">{{ noOrdersNotification }}</div>
24
-
25
- <div v-if="showOrderDetail">
26
- <OrderDetail :title="$t('global.order') + ' #' + selected.id" :id="selected.id"></OrderDetail>
27
- </div>
28
- </div>
29
- </template>
30
-
31
- <script>
32
- import { Order } from '../../api'
33
- import OrderDetail from './OrderDetail'
34
-
35
- export default {
36
- name: 'Orders',
37
- components: { OrderDetail },
38
- props: {
39
- noOrdersNotification: {
40
- type: String,
41
- default: function () {
42
- return this.$t('account.ordersEmpty')
43
- }
44
- },
45
- },
46
- data() {
47
- return {
48
- selected: {},
49
- orders: [],
50
- orderItems: [],
51
- orderTotal: 0,
52
- openedDetailed: [],
53
- showOrderDetail: false,
54
- loadingOrders: null
55
- }
56
- },
57
- methods: {
58
- getOrders() {
59
- Order.getList()
60
- .then((response) => {
61
- this.orders = response.data.data
62
- //console.log('orders ', this.orders)
63
- this.loadingOrders.close()
64
- })
65
- .catch((error) => {
66
- console.log('Order loading error', error)
67
- })
68
- },
69
-
70
- select(row, oldRow) {
71
- this.showOrderDetail = true
72
- history.pushState(
73
- null,
74
- this.initialState.site_name + ' ' + this.$t('account.orders') + ' > ' + this.$t('global.order') + ' #' + row.id,
75
- '/account?tab=orders&id=' + row.id
76
- )
77
- },
78
-
79
- orderDetailClose() {
80
- this.selected = {}
81
- this.showOrderDetail = false
82
- },
83
-
84
- init() {
85
- this.loadingOrders = this.$buefy.loading.open()
86
- let urlOrderId = parseInt(new URL(document.location).searchParams.get('id'))
87
- if (urlOrderId) {
88
- this.selected = { id: urlOrderId }
89
- this.showOrderDetail = true
90
- if (this.orders.length === 0) {
91
- this.getOrders()
92
- }
93
- } else {
94
- this.getOrders()
95
- }
96
- }
97
- },
98
-
99
- mounted() {
100
- this.init()
101
-
102
- this.$bus.$on('orderDetailClose', this.orderDetailClose)
103
-
104
- window.addEventListener('popstate', () => {
105
- console.log('popstate orders', window.location.href, this.$parent)
106
- this.showOrderDetail = false
107
- })
108
- }
109
- }
110
- </script>
@@ -1,18 +0,0 @@
1
- <template>
2
- <div>
3
- <p>Settings</p>
4
- </div>
5
- </template>
6
-
7
-
8
- <script>
9
- export default {
10
- name:'Settings',
11
- data() {
12
- return {
13
-
14
- }
15
- },
16
- }
17
-
18
- </script>
@@ -1,128 +0,0 @@
1
- import { shallowMount, createLocalVue } from '@vue/test-utils'
2
- import DeliveryAddressGuest from './DeliveryAddressGuest.vue'
3
-
4
- fdescribe('DeliveryAddressGuest', () => {
5
- let wrapper
6
-
7
- beforeEach(() => {
8
- const localVue = createLocalVue()
9
- wrapper = shallowMount(DeliveryAddressGuest, {
10
- localVue,
11
- mocks: {
12
- $t: jest.fn(),
13
- $buefy: {
14
- loading: {
15
- open: jest.fn(),
16
- close: jest.fn()
17
- },
18
- dialog: {
19
- alert: jest.fn()
20
- },
21
- toast: {
22
- open: jest.fn()
23
- }
24
- }
25
- },
26
- stubs: {
27
- Address: true,
28
- EditAddress: true,
29
- DeliveryMethods: true
30
- }
31
- })
32
- })
33
-
34
- afterEach(() => {
35
- wrapper.destroy()
36
- })
37
-
38
- it('renders the component', () => {
39
- expect(wrapper.exists()).toBe(true)
40
- })
41
-
42
- it('initializes with correct data', () => {
43
- expect(wrapper.vm.addressValid).toBe(false)
44
- expect(wrapper.vm.validationErrors).toEqual({})
45
- expect(wrapper.vm.editAutocompleteAddress).toBe(false)
46
- })
47
-
48
- it('calls onGmapsPlaceInput method correctly', () => {
49
- const pl = {
50
- street: '123 Main St',
51
- city: 'New York',
52
- state: 'NY',
53
- country: 'USA'
54
- }
55
- wrapper.vm.checkoutRequestData.shipping_address = {
56
- street: '',
57
- city: '',
58
- state: '',
59
- country: ''
60
- }
61
- wrapper.vm.onGmapsPlaceInput(pl)
62
- expect(wrapper.vm.validationErrors).toEqual({})
63
- expect(wrapper.vm.editAutocompleteAddress).toBe(false)
64
- expect(wrapper.vm.checkoutRequestData.shipping_address).toEqual(pl)
65
- })
66
-
67
- it('calls onAddressContinue method correctly', async () => {
68
- const geocodeResult = 'OK'
69
- const validateAddressResult = {
70
- valid: true
71
- }
72
- const getAvailableDeliveryMethodsResult = [
73
- { id: 1, name: 'Standard Delivery' },
74
- { id: 2, name: 'Express Delivery' }
75
- ]
76
- wrapper.vm.geocodeAddress = jest.fn().mockResolvedValue(geocodeResult)
77
- wrapper.vm.validateAddress = jest.fn().mockResolvedValue(validateAddressResult)
78
- wrapper.vm.getAvailableDeliveryMethods = jest.fn().mockResolvedValue(getAvailableDeliveryMethodsResult)
79
-
80
- await wrapper.vm.onAddressContinue()
81
-
82
- expect(wrapper.vm.addressValid).toBe(true)
83
- expect(wrapper.emitted('addressValidation')[0]).toEqual([true])
84
- expect(wrapper.vm.setBillingAddress).toHaveBeenCalledWith(wrapper.vm.checkoutRequestData.shipping_address)
85
- expect(wrapper.vm.getAvailableDeliveryMethods).toHaveBeenCalledWith(wrapper.vm.checkoutRequestData.shipping_address)
86
- expect(wrapper.vm.scrollToElement).toHaveBeenCalledWith('.delivery-method')
87
- })
88
-
89
- it('calls onChangeDeliveryAddress method correctly', () => {
90
- wrapper.vm.onChangeDeliveryAddress()
91
- expect(wrapper.vm.addressValid).toBe(false)
92
- expect(wrapper.vm.editAutocompleteAddress).toBe(true)
93
- expect(wrapper.emitted('addressValidation')[0]).toEqual([false])
94
- })
95
-
96
- it('calls deliveryMethodSelected method correctly', () => {
97
- const deliveryCost = { id: 1, name: 'Standard Delivery' }
98
- wrapper.vm.deliveryMethodSelected(deliveryCost)
99
- expect(wrapper.vm.getSummary).toHaveBeenCalledWith({
100
- country_id: wrapper.vm.checkoutRequestData.shipping_address.country_id,
101
- state_id: wrapper.vm.checkoutRequestData.shipping_address.state_id,
102
- delivery_cost_id: deliveryCost.id
103
- })
104
- expect(wrapper.emitted('deliveryMethodSelected')[0]).toEqual([deliveryCost])
105
- })
106
-
107
- it('calls setDeliveryAddressUserIdentity method correctly', () => {
108
- const initialState = {
109
- orderAsBusiness: '0'
110
- }
111
- const userIdentity = {
112
- first_name: 'John',
113
- last_name: 'Doe',
114
- phone: '1234567890'
115
- }
116
- const countryList = ['USA', 'Canada']
117
- wrapper.vm.initialState = initialState
118
- wrapper.vm.userIdentity = userIdentity
119
- wrapper.vm.countryList = countryList
120
-
121
- wrapper.vm.setDeliveryAddressUserIdentity()
122
-
123
- expect(wrapper.vm.setDeliveryAddress).toHaveBeenCalledWith(expect.any(Object))
124
- expect(wrapper.vm.checkoutRequestData.shipping_address.first_name).toBe(userIdentity.first_name)
125
- expect(wrapper.vm.checkoutRequestData.shipping_address.last_name).toBe(userIdentity.last_name)
126
- expect(wrapper.vm.checkoutRequestData.shipping_address.phone).toBe(userIdentity.phone)
127
- })
128
- })
@@ -1,83 +0,0 @@
1
-
2
- import { mount } from '@vue/test-utils'
3
- import DeliveryTypes from '@/components/Cart/Delivery/DeliveryTypes.vue'
4
-
5
- describe('DeliveryTypes', () => {
6
- let wrapper
7
- const deliveryTypesMock = [
8
- { type: 'pickup', name: 'Pickup', description: 'Pick up your order from the store' },
9
- { type: 'delivery', name: 'Delivery', description: 'Get your order delivered to your address' }
10
- ]
11
-
12
- beforeEach(() => {
13
- wrapper = mount(DeliveryTypes, {
14
- propsData: {
15
- value: 'pickup',
16
- error: false
17
- },
18
- computed: {
19
- deliveryTypes: () => deliveryTypesMock
20
- },
21
-
22
- })
23
- })
24
-
25
- it('renders the delivery types', () => {
26
- const deliveryMethods = wrapper.findAll('.delivery-methods .b-radio')
27
- expect(deliveryMethods.length).toBe(2)
28
-
29
- const firstDeliveryMethod = deliveryMethods.at(0)
30
- expect(firstDeliveryMethod.find('div').text()).toBe('Pickup')
31
-
32
- const secondDeliveryMethod = deliveryMethods.at(1)
33
- expect(secondDeliveryMethod.find('div').text()).toBe('Delivery')
34
- })
35
-
36
- it('emits the selected delivery type on input', async () => {
37
- const deliveryMethodInputs = wrapper.findAll('.delivery-methods .b-radio input')
38
- const secondDeliveryMethodInput = deliveryMethodInputs.at(1)
39
-
40
- await secondDeliveryMethodInput.setChecked(true)
41
-
42
- expect(wrapper.emitted().input).toBeTruthy()
43
- expect(wrapper.emitted().input[1]).toEqual(['delivery'])
44
- })
45
-
46
- it('sets the default delivery type if deliveryTypes is not empty', () => {
47
- expect(wrapper.emitted().input).toBeTruthy()
48
- expect(wrapper.emitted().input[0]).toEqual(['pickup'])
49
- })
50
-
51
- it('does not set the default delivery type if deliveryTypes is empty', () => {
52
- wrapper = mount(DeliveryTypes, {
53
- propsData: {
54
- value: 'pickup',
55
- error: false
56
- },
57
- computed: {
58
- deliveryTypes: () => []
59
- }
60
- })
61
-
62
- expect(wrapper.emitted().input).toBeFalsy()
63
- })
64
-
65
- it('renders the error message if error is true', () => {
66
- wrapper = mount(DeliveryTypes, {
67
- propsData: {
68
- value: 'pickup',
69
- error: true
70
- },
71
- computed: {
72
- deliveryTypes: () => deliveryTypesMock
73
- }
74
- })
75
-
76
- expect(wrapper.find('.help.is-danger').text()).toBe('Please choose delivery method')
77
- })
78
-
79
- it('does not render the error message if error is false', () => {
80
- expect(wrapper.find('.help.is-danger').exists()).toBe(false)
81
- })
82
-
83
- })
@@ -1,11 +0,0 @@
1
- <template functional>
2
- <div>
3
- <a href="//www.securitymetrics.com/site_certificate?id=1676708&tk=b0f62300a408dbdf054377c74eaddaec" target="_blank" rel="noopener noreferrer">
4
- <img
5
- class="security-metrics-badge"
6
- src="https://www.securitymetrics.com/static/apps/super/assets/img/Credit_Card_Safe_light.png"
7
- alt="SecurityMetrics Credit Card Safe"
8
- />
9
- </a>
10
- </div>
11
- </template>