@saooti/octopus-sdk 42.0.0-beta → 42.0.0-beta2
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.
- package/eslint-config.d.ts +3 -0
- package/eslint-config.mjs +54 -0
- package/package.json +5 -2
- package/tests/api/podcastApi.spec.ts +43 -0
- package/tests/api/transcriptionApi.spec.ts +58 -0
- package/tests/components/composable/player/usePlayerTranscript.spec.ts +238 -0
- package/tests/components/composable/useAdvancedParamInit.spec.ts +91 -0
- package/tests/components/composable/usePresentationItem.spec.ts +164 -0
- package/tests/components/composable/useRights.spec.ts +838 -0
- package/tests/components/composable/useSeasonsManagement.spec.ts +35 -0
- package/tests/components/composable/useTranslation.spec.ts +209 -0
- package/tests/components/display/RightsIndicator.spec.ts +481 -0
- package/tests/components/display/comments/item/CommentMoreActions.spec.ts +75 -0
- package/tests/components/display/comments/modal/RecaptchaModal.spec.ts +43 -0
- package/tests/components/display/emission/EmissionItem.spec.ts +54 -0
- package/tests/components/display/emission/EmissionPresentationItem.spec.ts +46 -0
- package/tests/components/display/filter/AdvancedSearch.spec.ts +187 -0
- package/tests/components/display/podcasts/PodcastFilterList.spec.ts +34 -0
- package/tests/components/display/podcasts/PodcastInlineListTemplate.spec.ts +24 -0
- package/tests/components/display/podcasts/PodcastItemInfo.spec.ts +99 -0
- package/tests/components/display/podcasts/PodcastModuleBox.spec.ts +279 -0
- package/tests/components/display/podcasts/PodcastPresentationList.spec.ts +108 -0
- package/tests/components/display/podcasts/PodcastRawTranscript.spec.ts +254 -0
- package/tests/components/display/sharing/ShareNewsletter.spec.ts +68 -0
- package/tests/components/display/sharing/SharePlayer.spec.ts +59 -0
- package/tests/components/display/sharing/SharePlayerRadio.spec.ts +55 -0
- package/tests/components/form/ClassicButtonGroup.spec.ts +78 -0
- package/tests/components/form/ClassicInputText.spec.ts +24 -0
- package/tests/components/form/OctopusMultiselect.spec.ts +506 -0
- package/tests/components/form/OctopusSelect.spec.ts +240 -0
- package/tests/components/layouts/PresentationItem.spec.ts +37 -0
- package/tests/components/misc/ClassicAvatar.spec.ts +68 -0
- package/tests/components/misc/ClassicPopover.spec.ts +260 -0
- package/tests/components/misc/FooterSection.spec.ts +49 -0
- package/tests/components/misc/HomeDropdown.spec.ts +44 -0
- package/tests/components/misc/modal/ClipboardModal.spec.ts +51 -0
- package/tests/components/misc/player/PlayerLarge.spec.ts +72 -0
- package/tests/components/pages/EmissionPage.spec.ts +253 -0
- package/tests/components/pages/EmissionsPage.spec.ts +18 -0
- package/tests/components/pages/ParticipantPage.spec.ts +65 -0
- package/tests/components/pages/PlaylistPage.spec.ts +60 -0
- package/tests/components/pages/PodcastPage.spec.ts +89 -0
- package/tests/components/pages/PodcastsPage.spec.ts +18 -0
- package/tests/components/pages/RadioPage.spec.ts +65 -0
- package/tests/components/pages/SmartLinkPage.spec.ts +90 -0
- package/tests/helper/language.spec.ts +45 -0
- package/tests/index.ts +9 -0
- package/tests/localisation.ts +10 -0
- package/tests/mocks/i18n.ts +13 -0
- package/tests/mocks/index.ts +11 -0
- package/tests/mocks/rights.ts +17 -0
- package/tests/mocks/useAdvancedParamInit.ts +22 -0
- package/tests/mocks/useRouter.ts +11 -0
- package/tests/stores/CacheStore.spec.ts +110 -0
- package/tests/utils.ts +178 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { mockI18n } from '@tests/mocks';
|
|
2
|
+
vi.mock('vue-i18n', () => mockI18n());
|
|
3
|
+
|
|
4
|
+
const tagsFor = vi.fn();
|
|
5
|
+
const additionalInfoFor = vi.fn();
|
|
6
|
+
|
|
7
|
+
vi.mock('@/components/composable/usePresentationItem', () => ({
|
|
8
|
+
usePresentationItem: () => ({ tagsFor, additionalInfoFor }),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
import EmissionPresentationItem from '@/components/display/emission/EmissionPresentationItem.vue';
|
|
12
|
+
import { emptyEmissionData } from '@/stores/class/general/emission';
|
|
13
|
+
import { mount as testMount } from '@tests/utils';
|
|
14
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
15
|
+
import { nextTick } from 'vue';
|
|
16
|
+
|
|
17
|
+
const mount = (props: Record<string, unknown>) => testMount(EmissionPresentationItem, { shallow: true, props });
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
tagsFor.mockReset().mockResolvedValue([]);
|
|
21
|
+
additionalInfoFor.mockReset().mockReturnValue(undefined);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('EmissionPresentationItem', () => {
|
|
25
|
+
it('calls tagsFor with the emission prop', async () => {
|
|
26
|
+
const emission = { ...emptyEmissionData(), emissionId: 42 };
|
|
27
|
+
await mount({ emission });
|
|
28
|
+
expect(tagsFor).toHaveBeenCalledWith(emission);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('resolves tagsFor asynchronously and forwards the result as the tags prop', async () => {
|
|
32
|
+
tagsFor.mockResolvedValue(['News']);
|
|
33
|
+
const wrapper = await mount({ emission: emptyEmissionData() });
|
|
34
|
+
await nextTick();
|
|
35
|
+
await nextTick();
|
|
36
|
+
const presentationItem = wrapper.findComponent({ name: 'PresentationItem' });
|
|
37
|
+
expect(presentationItem.props('tags')).toEqual(['News']);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('forwards additionalInfoFor result as the additional-info prop', async () => {
|
|
41
|
+
additionalInfoFor.mockReturnValue(['Saooti']);
|
|
42
|
+
const wrapper = await mount({ emission: emptyEmissionData() });
|
|
43
|
+
const presentationItem = wrapper.findComponent({ name: 'PresentationItem' });
|
|
44
|
+
expect(presentationItem.props('additionalInfo')).toEqual(['Saooti']);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { mockUseRouter, mockAdvancedParamInit, mockI18n } from '@tests/mocks';
|
|
2
|
+
vi.mock('vue-router', () => mockUseRouter());
|
|
3
|
+
vi.mock('@/components/composable/route/useAdvancedParamInit', () => mockAdvancedParamInit());
|
|
4
|
+
vi.mock('vue-i18n', () => mockI18n());
|
|
5
|
+
|
|
6
|
+
import AdvancedSearch from '@/components/display/filter/AdvancedSearch.vue';
|
|
7
|
+
import { mount } from '@tests/utils';
|
|
8
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
9
|
+
import { useAuthStore } from '@/stores/AuthStore';
|
|
10
|
+
import { state } from '@/stores/ParamSdkStore';
|
|
11
|
+
import { useGeneralStore } from '@/stores/GeneralStore';
|
|
12
|
+
|
|
13
|
+
// Mock the useOrgaComputed composable
|
|
14
|
+
vi.mock('@/components/composable/useOrgaComputed', () => ({
|
|
15
|
+
useOrgaComputed: () => {
|
|
16
|
+
const { computed } = require('vue');
|
|
17
|
+
return {
|
|
18
|
+
isPodcastmaker: computed(() => state.generalParameters.podcastmaker as boolean),
|
|
19
|
+
isEditRights: (orgaId?: string) => {
|
|
20
|
+
const authStore = useAuthStore();
|
|
21
|
+
return authStore.authOrgaId === orgaId || authStore.isRoleAdmin;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
// Mock the groups API
|
|
28
|
+
vi.mock('@/api/groupsApi', () => {
|
|
29
|
+
return {
|
|
30
|
+
groupsApi: {
|
|
31
|
+
count: vi.fn().mockResolvedValue(0)
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('AdvancedSearch - isSelectValidity computed (fix for isPodcastmaker.value)', () => {
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
// Reset the podcastmaker state before each test
|
|
39
|
+
state.generalParameters.podcastmaker = false;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should correctly evaluate isSelectValidity when isPodcastmaker is false', async () => {
|
|
43
|
+
const wrapper = await mount(AdvancedSearch, {
|
|
44
|
+
props: {
|
|
45
|
+
organisationId: 'test-org-id',
|
|
46
|
+
isEmission: false,
|
|
47
|
+
includeHidden: true
|
|
48
|
+
},
|
|
49
|
+
beforeMount: async () => {
|
|
50
|
+
const authStore = useAuthStore();
|
|
51
|
+
authStore.$patch({
|
|
52
|
+
authOrgaId: 'test-org-id',
|
|
53
|
+
authRole: ['PODCAST_CRUD'],
|
|
54
|
+
authOrganisation: {
|
|
55
|
+
id: 'test-org-id',
|
|
56
|
+
name: 'Test Organisation',
|
|
57
|
+
imageUrl: '',
|
|
58
|
+
attributes: {}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const generalStore = useGeneralStore();
|
|
63
|
+
generalStore.$patch({
|
|
64
|
+
platformEducation: false
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Ensure isPodcastmaker is false
|
|
68
|
+
state.generalParameters.podcastmaker = false;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Access the component's computed property
|
|
73
|
+
const vm = wrapper.vm as any;
|
|
74
|
+
|
|
75
|
+
// When isPodcastmaker is false and other conditions are met,
|
|
76
|
+
// isSelectValidity should be true
|
|
77
|
+
expect(vm.isSelectValidity).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should correctly evaluate isSelectValidity when isPodcastmaker is true', async () => {
|
|
81
|
+
const wrapper = await mount(AdvancedSearch, {
|
|
82
|
+
props: {
|
|
83
|
+
organisationId: 'test-org-id',
|
|
84
|
+
isEmission: false,
|
|
85
|
+
includeHidden: true
|
|
86
|
+
},
|
|
87
|
+
beforeMount: async () => {
|
|
88
|
+
const authStore = useAuthStore();
|
|
89
|
+
authStore.$patch({
|
|
90
|
+
authOrgaId: 'test-org-id',
|
|
91
|
+
authRole: ['PODCAST_CRUD'],
|
|
92
|
+
authOrganisation: {
|
|
93
|
+
id: 'test-org-id',
|
|
94
|
+
name: 'Test Organisation',
|
|
95
|
+
imageUrl: '',
|
|
96
|
+
attributes: {}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const generalStore = useGeneralStore();
|
|
101
|
+
generalStore.$patch({
|
|
102
|
+
platformEducation: false
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Set isPodcastmaker to true
|
|
106
|
+
state.generalParameters.podcastmaker = true;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Access the component's computed property
|
|
111
|
+
const vm = wrapper.vm as any;
|
|
112
|
+
|
|
113
|
+
// When isPodcastmaker is true, isSelectValidity should be false
|
|
114
|
+
// (because the condition includes !isPodcastmaker.value)
|
|
115
|
+
expect(vm.isSelectValidity).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should correctly evaluate isSelectValidity when isEmission is true', async () => {
|
|
119
|
+
const wrapper = await mount(AdvancedSearch, {
|
|
120
|
+
props: {
|
|
121
|
+
organisationId: 'test-org-id',
|
|
122
|
+
isEmission: true, // This should make isSelectValidity false
|
|
123
|
+
includeHidden: true
|
|
124
|
+
},
|
|
125
|
+
beforeMount: async () => {
|
|
126
|
+
const authStore = useAuthStore();
|
|
127
|
+
authStore.$patch({
|
|
128
|
+
authOrgaId: 'test-org-id',
|
|
129
|
+
authRole: ['PODCAST_CRUD'],
|
|
130
|
+
authOrganisation: {
|
|
131
|
+
id: 'test-org-id',
|
|
132
|
+
name: 'Test Organisation',
|
|
133
|
+
imageUrl: '',
|
|
134
|
+
attributes: {}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const generalStore = useGeneralStore();
|
|
139
|
+
generalStore.$patch({
|
|
140
|
+
platformEducation: false
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
state.generalParameters.podcastmaker = false;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const vm = wrapper.vm as any;
|
|
148
|
+
|
|
149
|
+
// When isEmission is true, isSelectValidity should be false
|
|
150
|
+
expect(vm.isSelectValidity).toBe(false);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should correctly evaluate isSelectValidity when includeHidden is false', async () => {
|
|
154
|
+
const wrapper = await mount(AdvancedSearch, {
|
|
155
|
+
props: {
|
|
156
|
+
organisationId: 'test-org-id',
|
|
157
|
+
isEmission: false,
|
|
158
|
+
includeHidden: false // This should make isSelectValidity false
|
|
159
|
+
},
|
|
160
|
+
beforeMount: async () => {
|
|
161
|
+
const authStore = useAuthStore();
|
|
162
|
+
authStore.$patch({
|
|
163
|
+
authOrgaId: 'test-org-id',
|
|
164
|
+
authRole: ['PODCAST_CRUD'],
|
|
165
|
+
authOrganisation: {
|
|
166
|
+
id: 'test-org-id',
|
|
167
|
+
name: 'Test Organisation',
|
|
168
|
+
imageUrl: '',
|
|
169
|
+
attributes: {}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const generalStore = useGeneralStore();
|
|
174
|
+
generalStore.$patch({
|
|
175
|
+
platformEducation: false
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
state.generalParameters.podcastmaker = false;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const vm = wrapper.vm as any;
|
|
183
|
+
|
|
184
|
+
// When includeHidden is false, isSelectValidity should be false
|
|
185
|
+
expect(vm.isSelectValidity).toBe(false);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mockI18n } from '@tests/mocks';
|
|
2
|
+
vi.mock('vue-i18n', () => mockI18n());
|
|
3
|
+
|
|
4
|
+
import PodcastFilterList from '@/components/display/podcasts/PodcastFilterList.vue';
|
|
5
|
+
import { Emission, emptyEmissionData, SeasonMode } from '@/stores/class/general/emission';
|
|
6
|
+
import { mount as testMount } from '@tests/utils';
|
|
7
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
8
|
+
|
|
9
|
+
const mount = (props: Record<string, unknown> = {}) =>
|
|
10
|
+
testMount(PodcastFilterList, { shallow: true, props });
|
|
11
|
+
|
|
12
|
+
describe('PodcastFilterList', () => {
|
|
13
|
+
describe('season display', () => {
|
|
14
|
+
it.each([
|
|
15
|
+
{ desc: 'no emission provided', props: {} },
|
|
16
|
+
{ desc: 'emission has NO_SEASON mode', props: { emission: { ...emptyEmissionData(), seasonMode: SeasonMode.NO_SEASON, seasons: [1, 2, 3] } } },
|
|
17
|
+
{ desc: 'emission has seasons but seasonCount is 0', props: { emission: { ...emptyEmissionData(), seasonMode: SeasonMode.SEASON_WITH_PODCAST_NUMBERING, seasons: [] } } },
|
|
18
|
+
])('shows a plain list when $desc', async ({ props }) => {
|
|
19
|
+
const wrapper = await mount(props);
|
|
20
|
+
expect(wrapper.find('podcast-list-stub').exists()).toBe(true);
|
|
21
|
+
expect(wrapper.find('classic-nav-stub').exists()).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it.each([
|
|
25
|
+
SeasonMode.SEASON_WITH_PODCAST_NUMBERING,
|
|
26
|
+
SeasonMode.SEASON_WITHOUT_PODCAST_NUMBERING,
|
|
27
|
+
])('shows a season nav when seasonMode is %s', async (seasonMode) => {
|
|
28
|
+
const emission: Emission = { ...emptyEmissionData(), seasonMode, seasons: [1, 2, 3] };
|
|
29
|
+
const wrapper = await mount({ emission });
|
|
30
|
+
expect(wrapper.find('classic-nav-stub').exists()).toBe(true);
|
|
31
|
+
expect(wrapper.find('podcast-list-stub').exists()).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mockI18n, mockUseRouter } from '@tests/mocks';
|
|
2
|
+
vi.mock('vue-i18n', () => mockI18n());
|
|
3
|
+
vi.mock('vue-router', () => mockUseRouter());
|
|
4
|
+
|
|
5
|
+
import PodcastInlineListTemplate from '@/components/display/podcasts/PodcastInlineListTemplate.vue';
|
|
6
|
+
import { mount as testMount } from '@tests/utils';
|
|
7
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
8
|
+
|
|
9
|
+
const mount = (props: Record<string, unknown> = {}) =>
|
|
10
|
+
testMount(PodcastInlineListTemplate, { shallow: true, props });
|
|
11
|
+
|
|
12
|
+
describe('PodcastInlineListTemplate', () => {
|
|
13
|
+
describe('noSort prop', () => {
|
|
14
|
+
it('shows sort buttons by default', async () => {
|
|
15
|
+
const wrapper = await mount();
|
|
16
|
+
expect(wrapper.find('.btn-underline').exists()).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('hides sort buttons when noSort is true', async () => {
|
|
20
|
+
const wrapper = await mount({ noSort: true });
|
|
21
|
+
expect(wrapper.find('.btn-underline').exists()).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { mockI18n, mockUseRouter } from '@tests/mocks';
|
|
2
|
+
vi.mock('vue-i18n', () => mockI18n());
|
|
3
|
+
vi.mock('vue-router', () => mockUseRouter());
|
|
4
|
+
|
|
5
|
+
import PodcastItemInfo from '@/components/display/podcasts/PodcastItemInfo.vue';
|
|
6
|
+
import { useAuthStore } from '@/stores/AuthStore';
|
|
7
|
+
import { SeasonMode } from '@/stores/class/general/emission';
|
|
8
|
+
import { emptyPodcastData, Podcast, PodcastType } from '@/stores/class/general/podcast';
|
|
9
|
+
import { mount as testMount, setupAuthStore } from '@tests/utils';
|
|
10
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
11
|
+
|
|
12
|
+
const mount = (podcast: Partial<Podcast> = {}, auth?: { roles: string[], scope?: number[] }) => {
|
|
13
|
+
const base = emptyPodcastData();
|
|
14
|
+
return testMount(PodcastItemInfo, {
|
|
15
|
+
props: { podcast: { ...base, ...podcast } },
|
|
16
|
+
stubs: ['PodcastPlayBar', 'AnimatorsItem', 'BullhornIcon', 'GiftIcon'],
|
|
17
|
+
beforeMount: auth ? async () => {
|
|
18
|
+
await setupAuthStore({ roles: auth.roles, scope: auth.scope })();
|
|
19
|
+
useAuthStore().$patch({
|
|
20
|
+
authProfile: { userId: 'test-user-123', scope: auth.scope ?? [] },
|
|
21
|
+
authParam: { accessToken: 'test-token', refreshToken: undefined, expiration: undefined },
|
|
22
|
+
});
|
|
23
|
+
} : undefined
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe('PodcastItemInfo', () => {
|
|
28
|
+
describe('season display', () => {
|
|
29
|
+
it('shows nothing for NO_SEASON', async () => {
|
|
30
|
+
const podcast = emptyPodcastData();
|
|
31
|
+
podcast.emission.seasonMode = SeasonMode.NO_SEASON;
|
|
32
|
+
podcast.seasonNumber = 2;
|
|
33
|
+
const wrapper = await mount(podcast);
|
|
34
|
+
expect(wrapper.find('.podcast-item-season').text()).toBe('');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('shows season number for SEASON_WITHOUT_PODCAST_NUMBERING', async () => {
|
|
38
|
+
const podcast = emptyPodcastData();
|
|
39
|
+
podcast.emission.seasonMode = SeasonMode.SEASON_WITHOUT_PODCAST_NUMBERING;
|
|
40
|
+
podcast.seasonNumber = 3;
|
|
41
|
+
const wrapper = await mount(podcast);
|
|
42
|
+
expect(wrapper.find('.podcast-item-season').text()).toContain('S3');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('shows season and episode number for SEASON_WITH_PODCAST_NUMBERING', async () => {
|
|
46
|
+
const podcast = emptyPodcastData();
|
|
47
|
+
podcast.emission.seasonMode = SeasonMode.SEASON_WITH_PODCAST_NUMBERING;
|
|
48
|
+
podcast.seasonNumber = 2;
|
|
49
|
+
podcast.seasonEpisodeNumber = 5;
|
|
50
|
+
const wrapper = await mount(podcast);
|
|
51
|
+
expect(wrapper.find('.podcast-item-season').text()).toContain('S2·E5');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('episode type icons', () => {
|
|
56
|
+
it('shows BullhornIcon for TRAILER type', async () => {
|
|
57
|
+
const wrapper = await mount({ seasonEpisodeType: PodcastType.TRAILER });
|
|
58
|
+
expect(wrapper.findComponent({ name: 'BullhornIcon' }).exists()).toBe(true);
|
|
59
|
+
expect(wrapper.findComponent({ name: 'GiftIcon' }).exists()).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('shows GiftIcon for BONUS type', async () => {
|
|
63
|
+
const wrapper = await mount({ seasonEpisodeType: PodcastType.BONUS });
|
|
64
|
+
expect(wrapper.findComponent({ name: 'GiftIcon' }).exists()).toBe(true);
|
|
65
|
+
expect(wrapper.findComponent({ name: 'BullhornIcon' }).exists()).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('shows no type icon for FULL type', async () => {
|
|
69
|
+
const wrapper = await mount({ seasonEpisodeType: PodcastType.FULL });
|
|
70
|
+
expect(wrapper.findComponent({ name: 'BullhornIcon' }).exists()).toBe(false);
|
|
71
|
+
expect(wrapper.findComponent({ name: 'GiftIcon' }).exists()).toBe(false);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('RightsIndicator (scope)', () => {
|
|
76
|
+
it('shows RightsIndicator when the podcast is out of the user\'s scope', async () => {
|
|
77
|
+
const wrapper = await mount(
|
|
78
|
+
{ podcastId: 1, rubriqueIds: [10] },
|
|
79
|
+
{ roles: ['PRODUCTION'], scope: [999] }
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const icon = wrapper.find('.rights-indicator-icon');
|
|
83
|
+
expect(icon.exists()).toBe(true);
|
|
84
|
+
expect(icon.classes()).not.toContain('invisible');
|
|
85
|
+
expect(wrapper.text()).toContain('RightsIndicator - Podcast - Insufficient scope');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('hides RightsIndicator when the podcast is within the user\'s scope', async () => {
|
|
89
|
+
const wrapper = await mount(
|
|
90
|
+
{ podcastId: 1, rubriqueIds: [10] },
|
|
91
|
+
{ roles: ['PRODUCTION'], scope: [10] }
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const icon = wrapper.find('.rights-indicator-icon');
|
|
95
|
+
expect(icon.exists()).toBe(true);
|
|
96
|
+
expect(icon.classes()).toContain('invisible');
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { mockI18n, mockUseRouter } from '@tests/mocks';
|
|
2
|
+
vi.mock('vue-i18n', () => mockI18n());
|
|
3
|
+
vi.mock('vue-router', () => mockUseRouter());
|
|
4
|
+
|
|
5
|
+
import PodcastModuleBox from '@/components/display/podcasts/PodcastModuleBox.vue';
|
|
6
|
+
import { useAuthStore } from '@/stores/AuthStore';
|
|
7
|
+
import { Conference } from '@/stores/class/conference/conference';
|
|
8
|
+
import { SeasonMode } from '@/stores/class/general/emission';
|
|
9
|
+
import { emptyPodcastData, Podcast } from '@/stores/class/general/podcast';
|
|
10
|
+
import { mount as testMount, setupAuthStore } from '@tests/utils';
|
|
11
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
12
|
+
import { initialize } from '@/stores/ParamSdkStore';
|
|
13
|
+
|
|
14
|
+
const mount = (podcast: Podcast, options?: {
|
|
15
|
+
podcastConference?: Conference,
|
|
16
|
+
slots?: Record<string, unknown>,
|
|
17
|
+
roles?: string | string[],
|
|
18
|
+
scope?: number[],
|
|
19
|
+
}) => testMount(PodcastModuleBox, {
|
|
20
|
+
props: { podcast, podcastConference: options?.podcastConference },
|
|
21
|
+
stubs: ['ShareAnonymous', 'LikeSection', 'PodcastRubriqueList'],
|
|
22
|
+
slots: options?.slots,
|
|
23
|
+
beforeMount: async () => {
|
|
24
|
+
await setupAuthStore({ roles: options?.roles, organisationId: podcast.organisation?.id, scope: options?.scope })();
|
|
25
|
+
// Only patch authParam (which drives isAuthenticated / RightsIndicator visibility) when a
|
|
26
|
+
// scope is explicitly under test, to avoid changing the auth state for pre-existing tests.
|
|
27
|
+
if (options?.scope !== undefined) {
|
|
28
|
+
useAuthStore().$patch({
|
|
29
|
+
authProfile: { userId: 'test-user-123', scope: options.scope },
|
|
30
|
+
authParam: { accessToken: 'test-token', refreshToken: undefined, expiration: undefined },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('PodcastModuleBox', () => {
|
|
37
|
+
describe('date display', () => {
|
|
38
|
+
const podcast: Podcast = emptyPodcastData();
|
|
39
|
+
podcast.pubDate = '2025-12-01T10:21:31.000+00:00';
|
|
40
|
+
|
|
41
|
+
it('shows the date without time by default', async() => {
|
|
42
|
+
const wrapper = await mount(podcast);
|
|
43
|
+
expect(wrapper.text()).toContain('1 décembre 2025');
|
|
44
|
+
expect(wrapper.text()).not.toContain('11:21');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('shows the date with time when enabled in SdkParams', async() => {
|
|
48
|
+
initialize({ generalParameters: { showTimeWithDates: true } });
|
|
49
|
+
const wrapper = await mount(podcast);
|
|
50
|
+
expect(wrapper.text()).toContain('1 décembre 2025');
|
|
51
|
+
expect(wrapper.text()).toContain('11:21');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('subtitle', () => {
|
|
56
|
+
it('shows subtitle when annotation is set', async () => {
|
|
57
|
+
initialize({ podcastPage: { descriptionOrSummary: 'description' } });
|
|
58
|
+
const podcast = emptyPodcastData();
|
|
59
|
+
podcast.annotations = { subtitle: 'My subtitle' };
|
|
60
|
+
const wrapper = await mount(podcast);
|
|
61
|
+
expect(wrapper.text()).toContain('My subtitle');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('hides subtitle when annotation is not set', async () => {
|
|
65
|
+
initialize({ podcastPage: { descriptionOrSummary: 'description' } });
|
|
66
|
+
const wrapper = await mount(emptyPodcastData());
|
|
67
|
+
expect(wrapper.find('h3').exists()).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('hides subtitle when hideSubtitle is true', async () => {
|
|
71
|
+
initialize({ podcastPage: { hideSubtitle: true, descriptionOrSummary: 'description' } });
|
|
72
|
+
const podcast = emptyPodcastData();
|
|
73
|
+
podcast.annotations = { subtitle: 'My subtitle' };
|
|
74
|
+
const wrapper = await mount(podcast);
|
|
75
|
+
expect(wrapper.text()).not.toContain('My subtitle');
|
|
76
|
+
initialize({ podcastPage: { hideSubtitle: false, descriptionOrSummary: 'description' } });
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('description and summary', () => {
|
|
81
|
+
function makePodcastWithContent(): Podcast {
|
|
82
|
+
const podcast = emptyPodcastData();
|
|
83
|
+
podcast.description = 'The description';
|
|
84
|
+
podcast.summary = 'The summary';
|
|
85
|
+
return podcast;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
it('shows description and hides summary by default', async () => {
|
|
89
|
+
initialize({ podcastPage: { descriptionOrSummary: 'description' } });
|
|
90
|
+
const wrapper = await mount(makePodcastWithContent());
|
|
91
|
+
expect(wrapper.html()).toContain('The description');
|
|
92
|
+
expect(wrapper.html()).not.toContain('The summary');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('shows summary and hides description when descriptionOrSummary is summary', async () => {
|
|
96
|
+
initialize({ podcastPage: { descriptionOrSummary: 'summary' } });
|
|
97
|
+
const wrapper = await mount(makePodcastWithContent());
|
|
98
|
+
expect(wrapper.html()).toContain('The summary');
|
|
99
|
+
expect(wrapper.html()).not.toContain('The description');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('shows both description and summary when descriptionOrSummary is both', async () => {
|
|
103
|
+
initialize({ podcastPage: { descriptionOrSummary: 'both' } });
|
|
104
|
+
const wrapper = await mount(makePodcastWithContent());
|
|
105
|
+
expect(wrapper.html()).toContain('The description');
|
|
106
|
+
expect(wrapper.html()).toContain('The summary');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('hides summary when podcast has none', async () => {
|
|
110
|
+
initialize({ podcastPage: { descriptionOrSummary: 'both' } });
|
|
111
|
+
const podcast = emptyPodcastData();
|
|
112
|
+
podcast.description = 'The description';
|
|
113
|
+
const wrapper = await mount(podcast);
|
|
114
|
+
expect(wrapper.html()).toContain('The description');
|
|
115
|
+
expect(wrapper.html()).not.toContain('The summary');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('season info', () => {
|
|
120
|
+
function makePodcast(seasonMode = SeasonMode.NO_SEASON, overrides: Partial<Podcast> = {}) {
|
|
121
|
+
const podcast = emptyPodcastData();
|
|
122
|
+
podcast.emission.seasonMode = seasonMode;
|
|
123
|
+
return { ...podcast, ...overrides };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
describe('season number', () => {
|
|
127
|
+
it('hidden when seasonNumber is not set', async () => {
|
|
128
|
+
const wrapper = await mount(makePodcast(SeasonMode.SEASON_WITH_PODCAST_NUMBERING));
|
|
129
|
+
expect(wrapper.text()).not.toContain('Podcast - Season');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('hidden when emission has no season mode', async () => {
|
|
133
|
+
const wrapper = await mount(makePodcast(SeasonMode.NO_SEASON, { seasonNumber: 2 }));
|
|
134
|
+
expect(wrapper.text()).not.toContain('Podcast - Season');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it.each([
|
|
138
|
+
SeasonMode.SEASON_WITH_PODCAST_NUMBERING,
|
|
139
|
+
SeasonMode.SEASON_WITHOUT_PODCAST_NUMBERING,
|
|
140
|
+
])('shown for %s', async (seasonMode) => {
|
|
141
|
+
const wrapper = await mount(makePodcast(seasonMode, { seasonNumber: 2 }));
|
|
142
|
+
expect(wrapper.text()).toContain('Podcast - Season : 2');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('episode number', () => {
|
|
147
|
+
it('hidden for SEASON_WITHOUT_PODCAST_NUMBERING', async () => {
|
|
148
|
+
const wrapper = await mount(makePodcast(SeasonMode.SEASON_WITHOUT_PODCAST_NUMBERING, { seasonEpisodeNumber: 5 }));
|
|
149
|
+
expect(wrapper.text()).not.toContain('Podcast - Episode number');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('shown for SEASON_WITH_PODCAST_NUMBERING', async () => {
|
|
153
|
+
const wrapper = await mount(makePodcast(SeasonMode.SEASON_WITH_PODCAST_NUMBERING, { seasonEpisodeNumber: 5 }));
|
|
154
|
+
expect(wrapper.text()).toContain('Podcast - Episode number : 5');
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
describe('edit-box slot', () => {
|
|
160
|
+
it('passes the podcast, display-studio-access, and validate callback to the slot', async () => {
|
|
161
|
+
const podcast = emptyPodcastData();
|
|
162
|
+
podcast.organisation.id = 'org-1';
|
|
163
|
+
const wrapper = await mount(podcast, {
|
|
164
|
+
podcastConference: { conferenceId: 1, title: '', status: 'DEBRIEFING' },
|
|
165
|
+
slots: {
|
|
166
|
+
'edit-box': `<template #edit-box="{ podcast, displayStudioAccess, onValidatePodcast }">
|
|
167
|
+
<button
|
|
168
|
+
class="edit-box-slot"
|
|
169
|
+
:data-podcast-id="podcast?.podcastId"
|
|
170
|
+
:data-debriefing="displayStudioAccess"
|
|
171
|
+
@click="onValidatePodcast({ ...podcast, valid: true })"
|
|
172
|
+
/>
|
|
173
|
+
</template>`
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const button = wrapper.find('.edit-box-slot');
|
|
178
|
+
expect(button.exists()).toBe(true);
|
|
179
|
+
expect(button.attributes('data-podcast-id')).toBe(String(podcast.podcastId));
|
|
180
|
+
expect(button.attributes('data-debriefing')).toBe('true');
|
|
181
|
+
|
|
182
|
+
await button.trigger('click');
|
|
183
|
+
expect(wrapper.emitted('updatePodcast')?.[0]).toEqual([{ ...podcast, valid: true }]);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('is not rendered when the user has no edit rights', async () => {
|
|
187
|
+
const podcast = emptyPodcastData();
|
|
188
|
+
podcast.organisation.id = 'org-1';
|
|
189
|
+
const wrapper = await testMount(PodcastModuleBox, {
|
|
190
|
+
props: { podcast },
|
|
191
|
+
stubs: ['ShareAnonymous', 'LikeSection'],
|
|
192
|
+
slots: { 'edit-box': `<template #edit-box><button class="edit-box-slot" /></template>` },
|
|
193
|
+
beforeMount: setupAuthStore({ organisationId: 'org-2' })
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
expect(wrapper.find('.edit-box-slot').exists()).toBe(false);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('recording-item-button slot', () => {
|
|
201
|
+
function makeLiveReadyPodcast() {
|
|
202
|
+
const podcast = emptyPodcastData();
|
|
203
|
+
podcast.organisation.id = 'org-1';
|
|
204
|
+
podcast.conferenceId = 42;
|
|
205
|
+
podcast.processingStatus = 'READY_TO_RECORD';
|
|
206
|
+
return podcast;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
it('takes priority over edit-box and passes podcast/live/recording and callbacks to the slot', async () => {
|
|
210
|
+
const podcast = makeLiveReadyPodcast();
|
|
211
|
+
const podcastConference: Conference = { conferenceId: 42, title: '', status: 'PUBLISHING' };
|
|
212
|
+
const wrapper = await mount(podcast, {
|
|
213
|
+
podcastConference,
|
|
214
|
+
roles: 'LIVE',
|
|
215
|
+
slots: {
|
|
216
|
+
'recording-item-button': `<template #recording-item-button="{ podcast, live, recording, onDeleteItem, onValidatePodcast }">
|
|
217
|
+
<button
|
|
218
|
+
class="recording-slot"
|
|
219
|
+
:data-podcast-id="podcast?.podcastId"
|
|
220
|
+
:data-live="live"
|
|
221
|
+
:data-recording-status="recording?.status"
|
|
222
|
+
@click="onValidatePodcast({ ...podcast, valid: true })"
|
|
223
|
+
/>
|
|
224
|
+
<button class="recording-delete-slot" @click="onDeleteItem" />
|
|
225
|
+
</template>`,
|
|
226
|
+
'edit-box': `<template #edit-box><button class="edit-box-slot" /></template>`
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const button = wrapper.find('.recording-slot');
|
|
231
|
+
expect(button.exists()).toBe(true);
|
|
232
|
+
expect(button.attributes('data-podcast-id')).toBe(String(podcast.podcastId));
|
|
233
|
+
expect(button.attributes('data-live')).toBe('true');
|
|
234
|
+
expect(button.attributes('data-recording-status')).toBe('PUBLISHING');
|
|
235
|
+
expect(wrapper.find('.edit-box-slot').exists()).toBe(false);
|
|
236
|
+
|
|
237
|
+
await button.trigger('click');
|
|
238
|
+
expect(wrapper.emitted('updatePodcast')?.[0]).toEqual([{ ...podcast, valid: true }]);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('falls back to edit-box when there is no live conference', async () => {
|
|
242
|
+
const podcast = emptyPodcastData();
|
|
243
|
+
podcast.organisation.id = 'org-1';
|
|
244
|
+
const wrapper = await mount(podcast, {
|
|
245
|
+
roles: 'LIVE',
|
|
246
|
+
slots: {
|
|
247
|
+
'recording-item-button': `<template #recording-item-button><button class="recording-slot" /></template>`,
|
|
248
|
+
'edit-box': `<template #edit-box><button class="edit-box-slot" /></template>`
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
expect(wrapper.find('.recording-slot').exists()).toBe(false);
|
|
253
|
+
expect(wrapper.find('.edit-box-slot').exists()).toBe(true);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe('RightsIndicator (scope)', () => {
|
|
258
|
+
it('shows RightsIndicator when the podcast is out of the user\'s scope', async () => {
|
|
259
|
+
const podcast = emptyPodcastData();
|
|
260
|
+
podcast.rubriqueIds = [10];
|
|
261
|
+
const wrapper = await mount(podcast, { roles: 'PRODUCTION', scope: [999] });
|
|
262
|
+
|
|
263
|
+
const icon = wrapper.find('.rights-indicator-icon');
|
|
264
|
+
expect(icon.exists()).toBe(true);
|
|
265
|
+
expect(icon.classes()).not.toContain('invisible');
|
|
266
|
+
expect(wrapper.text()).toContain('RightsIndicator - Podcast - Insufficient scope');
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('hides RightsIndicator when the podcast is within the user\'s scope', async () => {
|
|
270
|
+
const podcast = emptyPodcastData();
|
|
271
|
+
podcast.rubriqueIds = [10];
|
|
272
|
+
const wrapper = await mount(podcast, { roles: 'PRODUCTION', scope: [10] });
|
|
273
|
+
|
|
274
|
+
const icon = wrapper.find('.rights-indicator-icon');
|
|
275
|
+
expect(icon.exists()).toBe(true);
|
|
276
|
+
expect(icon.classes()).toContain('invisible');
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
});
|