diff --git a/src/boot/dataCy.js b/src/boot/dataCy.js new file mode 100644 index 000000000..d26012a60 --- /dev/null +++ b/src/boot/dataCy.js @@ -0,0 +1,11 @@ +export default { + mounted: function (el, binding, { ctx }) { + const { innerText, localName } = el; + const { type, attrs } = ctx; + const name = ctx.parent.attrs?.name ?? ctx.parent.attrs?.label ?? innerText; + const value = `${attrs.dataCy ?? name}_${type.name + .replace('Q', '') + .toLowerCase()}`; + el.setAttribute('data-cy', value); + }, +}; diff --git a/src/boot/quasar.js b/src/boot/quasar.js index 01fe68d8b..f6c6c3331 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -3,12 +3,14 @@ import qFormMixin from './qformMixin'; import keyShortcut from './keyShortcut'; import useNotify from 'src/composables/useNotify.js'; import { CanceledError } from 'axios'; +import dataCy from './dataCy'; const { notify } = useNotify(); export default boot(({ app }) => { app.mixin(qFormMixin); app.directive('shortcut', keyShortcut); + app.directive('dataCy', dataCy); app.config.errorHandler = (error) => { let message; const response = error.response; diff --git a/src/components/common/VnAccountNumber.vue b/src/components/common/VnAccountNumber.vue index c4fa78674..b12e944c9 100644 --- a/src/components/common/VnAccountNumber.vue +++ b/src/components/common/VnAccountNumber.vue @@ -79,5 +79,5 @@ function accountShortToStandard() { diff --git a/src/components/common/VnChangePassword.vue b/src/components/common/VnChangePassword.vue index 79784f3c5..93473385a 100644 --- a/src/components/common/VnChangePassword.vue +++ b/src/components/common/VnChangePassword.vue @@ -64,6 +64,7 @@ defineExpose({ show: () => changePassDialog.value.show() }); size="xs" style="flex: 0" v-close-popup + v-data-cy /> @@ -113,6 +114,7 @@ defineExpose({ show: () => changePassDialog.value.show() }); flat type="reset" v-close-popup + data-cy /> changePassDialog.value.show() }); :label="t('globals.confirm')" color="primary" @click="validate" + data-cy /> diff --git a/src/components/common/VnDate.vue b/src/components/common/VnDate.vue index 761ac995e..6959ad754 100644 --- a/src/components/common/VnDate.vue +++ b/src/components/common/VnDate.vue @@ -2,7 +2,7 @@ const model = defineModel({ type: [String, Number], required: true });