Commit c9ba63ee authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Kushal Pandya

Fix shared component dynamic slot names

- source
- tests
parent 9cbbfab1
...@@ -54,15 +54,15 @@ export default { ...@@ -54,15 +54,15 @@ export default {
</gl-sprintf> </gl-sprintf>
</template> </template>
<template v-if="packageTypeDisplay" #metadata_type> <template v-if="packageTypeDisplay" #metadata-type>
<metadata-item data-testid="package-type" icon="package" :text="packageTypeDisplay" /> <metadata-item data-testid="package-type" icon="package" :text="packageTypeDisplay" />
</template> </template>
<template #metadata_size> <template #metadata-size>
<metadata-item data-testid="package-size" icon="disk" :text="totalSize" /> <metadata-item data-testid="package-size" icon="disk" :text="totalSize" />
</template> </template>
<template v-if="packagePipeline" #metadata_pipeline> <template v-if="packagePipeline" #metadata-pipeline>
<metadata-item <metadata-item
data-testid="pipeline-project" data-testid="pipeline-project"
icon="review-list" icon="review-list"
...@@ -71,11 +71,11 @@ export default { ...@@ -71,11 +71,11 @@ export default {
/> />
</template> </template>
<template v-if="packagePipeline" #metadata_ref> <template v-if="packagePipeline" #metadata-ref>
<metadata-item data-testid="package-ref" icon="branch" :text="packagePipeline.ref" /> <metadata-item data-testid="package-ref" icon="branch" :text="packagePipeline.ref" />
</template> </template>
<template v-if="hasTagsToDisplay" #metadata_tags> <template v-if="hasTagsToDisplay" #metadata-tags>
<package-tags :tag-display-limit="2" :tags="packageEntity.tags" hide-label /> <package-tags :tag-display-limit="2" :tags="packageEntity.tags" hide-label />
</template> </template>
......
...@@ -40,7 +40,7 @@ export default { ...@@ -40,7 +40,7 @@ export default {
<template> <template>
<title-area :title="$options.i18n.LIST_TITLE_TEXT" :info-messages="infoMessages"> <title-area :title="$options.i18n.LIST_TITLE_TEXT" :info-messages="infoMessages">
<template #metadata_amount> <template #metadata-amount>
<metadata-item v-if="showPackageCount" icon="package" :text="packageAmountText" /> <metadata-item v-if="showPackageCount" icon="package" :text="packageAmountText" />
</template> </template>
</title-area> </title-area>
......
...@@ -171,7 +171,7 @@ export default { ...@@ -171,7 +171,7 @@ export default {
/> />
</template> </template>
<template v-if="!invalidTag" #details_published> <template v-if="!invalidTag" #details-published>
<details-row icon="clock" data-testid="published-date-detail"> <details-row icon="clock" data-testid="published-date-detail">
<gl-sprintf :message="$options.i18n.PUBLISHED_DETAILS_ROW_TEXT"> <gl-sprintf :message="$options.i18n.PUBLISHED_DETAILS_ROW_TEXT">
<template #repositoryPath> <template #repositoryPath>
...@@ -186,7 +186,7 @@ export default { ...@@ -186,7 +186,7 @@ export default {
</gl-sprintf> </gl-sprintf>
</details-row> </details-row>
</template> </template>
<template v-if="!invalidTag" #details_manifest_digest> <template v-if="!invalidTag" #details-manifest-digest>
<details-row icon="log" data-testid="manifest-detail"> <details-row icon="log" data-testid="manifest-detail">
<gl-sprintf :message="$options.i18n.MANIFEST_DETAILS_ROW_TEST"> <gl-sprintf :message="$options.i18n.MANIFEST_DETAILS_ROW_TEST">
<template #digest> <template #digest>
...@@ -202,7 +202,7 @@ export default { ...@@ -202,7 +202,7 @@ export default {
/> />
</details-row> </details-row>
</template> </template>
<template v-if="!invalidTag" #details_configuration_digest> <template v-if="!invalidTag" #details-configuration-digest>
<details-row icon="cloud-gear" data-testid="configuration-detail"> <details-row icon="cloud-gear" data-testid="configuration-detail">
<gl-sprintf :message="$options.i18n.CONFIGURATION_DETAILS_ROW_TEST"> <gl-sprintf :message="$options.i18n.CONFIGURATION_DETAILS_ROW_TEST">
<template #digest> <template #digest>
......
...@@ -96,7 +96,7 @@ export default { ...@@ -96,7 +96,7 @@ export default {
<template #right-actions> <template #right-actions>
<slot name="commands"></slot> <slot name="commands"></slot>
</template> </template>
<template #metadata_count> <template #metadata-count>
<metadata-item <metadata-item
v-if="imagesCount" v-if="imagesCount"
data-testid="images-count" data-testid="images-count"
...@@ -104,7 +104,7 @@ export default { ...@@ -104,7 +104,7 @@ export default {
:text="imagesCountText" :text="imagesCountText"
/> />
</template> </template>
<template #metadata_exp_policies> <template #metadata-exp-policies>
<metadata-item <metadata-item
v-if="!hideExpirationPolicyData" v-if="!hideExpirationPolicyData"
data-testid="expiration-policy" data-testid="expiration-policy"
......
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
}, },
}, },
mounted() { mounted() {
this.detailsSlots = Object.keys(this.$slots).filter(k => k.startsWith('details_')); this.detailsSlots = Object.keys(this.$slots).filter(k => k.startsWith('details-'));
}, },
methods: { methods: {
toggleDetails() { toggleDetails() {
......
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
}; };
}, },
mounted() { mounted() {
this.metadataSlots = Object.keys(this.$slots).filter(k => k.startsWith('metadata_')); this.metadataSlots = Object.keys(this.$slots).filter(k => k.startsWith('metadata-'));
}, },
}; };
</script> </script>
......
...@@ -58,9 +58,9 @@ describe('list item', () => { ...@@ -58,9 +58,9 @@ describe('list item', () => {
describe.each` describe.each`
slotNames slotNames
${['details_foo']} ${['details-foo']}
${['details_foo', 'details_bar']} ${['details-foo', 'details-bar']}
${['details_foo', 'details_bar', 'details_baz']} ${['details-foo', 'details-bar', 'details-baz']}
`('$slotNames details slots', ({ slotNames }) => { `('$slotNames details slots', ({ slotNames }) => {
const slotMocks = slotNames.reduce((acc, current) => { const slotMocks = slotNames.reduce((acc, current) => {
acc[current] = `<div data-testid="${current}" />`; acc[current] = `<div data-testid="${current}" />`;
...@@ -89,7 +89,7 @@ describe('list item', () => { ...@@ -89,7 +89,7 @@ describe('list item', () => {
describe('details toggle button', () => { describe('details toggle button', () => {
it('is visible when at least one details slot exists', async () => { it('is visible when at least one details slot exists', async () => {
mountComponent({}, { details_foo: '<span></span>' }); mountComponent({}, { 'details-foo': '<span></span>' });
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(findToggleDetailsButton().exists()).toBe(true); expect(findToggleDetailsButton().exists()).toBe(true);
}); });
......
...@@ -79,9 +79,9 @@ describe('title area', () => { ...@@ -79,9 +79,9 @@ describe('title area', () => {
describe.each` describe.each`
slotNames slotNames
${['metadata_foo']} ${['metadata-foo']}
${['metadata_foo', 'metadata_bar']} ${['metadata-foo', 'metadata-bar']}
${['metadata_foo', 'metadata_bar', 'metadata_baz']} ${['metadata-foo', 'metadata-bar', 'metadata-baz']}
`('$slotNames metadata slots', ({ slotNames }) => { `('$slotNames metadata slots', ({ slotNames }) => {
const slotMocks = slotNames.reduce((acc, current) => { const slotMocks = slotNames.reduce((acc, current) => {
acc[current] = `<div data-testid="${current}" />`; acc[current] = `<div data-testid="${current}" />`;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment