Skip to content

Commit 50b0ecc

Browse files
committed
🐛(frontend) use feature flags for LTI video/webinar buttons
The existing feature flags were not used when displaying buttons for creating a new Marsha video or webinar. Adding them.
1 parent b32c583 commit 50b0ecc

File tree

5 files changed

+90
-32
lines changed

5 files changed

+90
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
1010

1111
### Fixed
1212

13+
- Use feature flags to control visibility of LTI video/webinar buttons
1314
- Fix storage location field for existing files stored on AWS S3:
1415
- markdown images
1516
- deposited files

src/backend/marsha/e2e/test_lti.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _preview_video(live_server, page, video_uploaded=False):
9999
page.click('#lti_resource_page input[type="submit"]')
100100

101101
if not video_uploaded:
102-
page.wait_for_selector("text=What are you willing to do ?")
102+
page.wait_for_selector("text=What would you like to do?")
103103
return page, video
104104

105105

@@ -716,7 +716,7 @@ def test_lti_nav_video(page: Page, live_server: LiveServer):
716716
"""
717717
page, _ = _preview_video(live_server, page, video_uploaded=True)
718718

719-
page.wait_for_selector("text=What are you willing to do ?", state="detached")
719+
page.wait_for_selector("text=What would you like to do?", state="detached")
720720
assert page.is_enabled('button:has-text("Play Video")')
721721

722722

@@ -730,7 +730,7 @@ def test_lti_nav_no_video(page: Page, live_server: LiveServer):
730730
"""
731731
page, _ = _preview_video(live_server, page)
732732

733-
page.wait_for_selector("text=What are you willing to do ?")
733+
page.wait_for_selector("text=What would you like to do?")
734734
page.wait_for_selector("text=Preview", state="detached")
735735

736736

src/frontend/apps/lti_site/components/LTIRoutes/index.spec.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
uploadState,
77
useAppConfig,
88
useCurrentResourceContext,
9+
useFlags,
910
} from 'lib-components';
1011
import {
1112
ltiInstructorTokenMockFactory,
@@ -70,6 +71,14 @@ jest.mock('components/SelectContent', () => ({
7071

7172
jest.setTimeout(15000);
7273

74+
useFlags.getState().setFlags({
75+
video: true,
76+
document: true,
77+
webinar: true,
78+
classroom: true,
79+
deposit: true,
80+
});
81+
7382
describe('<LTIRoutes />', () => {
7483
beforeEach(() => {
7584
mockedUseAppConfig.mockReturnValue({

src/frontend/apps/lti_site/components/VideoWizard/index.spec.tsx

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
builderDashboardRoute,
77
liveState,
88
modelName,
9+
useFlags,
910
} from 'lib-components';
1011
import { videoMockFactory } from 'lib-components/tests';
1112
import { render } from 'lib-tests';
@@ -34,6 +35,14 @@ jest.mock('lib-components', () => ({
3435
}),
3536
}));
3637

38+
useFlags.getState().setFlags({
39+
video: true,
40+
document: true,
41+
webinar: true,
42+
classroom: true,
43+
deposit: true,
44+
});
45+
3746
describe('<VideoWizard />', () => {
3847
beforeEach(() => {
3948
jest.resetAllMocks();
@@ -60,9 +69,9 @@ describe('<VideoWizard />', () => {
6069
});
6170

6271
await screen.findByText(
63-
'You can choose between creating a video and uploading one, or creating a live, that you will be able to schedule if needed.',
72+
'You can choose how you want to share your content using the options below.',
6473
);
65-
screen.getByText('What are you willing to do ?');
74+
screen.getByText('What would you like to do?');
6675
const createVODButton = screen.getByRole('button', {
6776
name: 'Create a video',
6877
});
@@ -102,9 +111,9 @@ describe('<VideoWizard />', () => {
102111
});
103112

104113
await screen.findByText(
105-
'You can choose between creating a video and uploading one, or creating a live, that you will be able to schedule if needed.',
114+
'You can choose how you want to share your content using the options below.',
106115
);
107-
screen.getByText('What are you willing to do ?');
116+
screen.getByText('What would you like to do?');
108117
screen.getByRole('button', { name: 'Create a video' });
109118
const configureLiveButton = screen.getByRole('button', {
110119
name: 'Start a live',
@@ -114,4 +123,33 @@ describe('<VideoWizard />', () => {
114123

115124
expect(await screen.findByText('live dashboard')).toBeInTheDocument();
116125
});
126+
it('renders VideoWizard with the CreateVODButton only', async () => {
127+
useFlags.getState().setFlags({
128+
webinar: false,
129+
});
130+
render(<VideoWizard />, {
131+
routerOptions: {
132+
componentPath: `/${VIDEO_WIZARD_ROUTE.all}`,
133+
history: [builderVideoWizzardRoute()],
134+
},
135+
});
136+
await screen.findByText(
137+
'You can choose how you want to share your content using the options below.',
138+
);
139+
screen.getByText('What would you like to do?');
140+
screen.getByRole('button', {
141+
name: 'Create a video',
142+
});
143+
expect(
144+
screen.queryByRole('button', { name: 'Start a live' }),
145+
).not.toBeInTheDocument();
146+
});
147+
});
148+
149+
useFlags.getState().setFlags({
150+
video: true,
151+
document: true,
152+
webinar: true,
153+
classroom: true,
154+
deposit: true,
117155
});

src/frontend/apps/lti_site/components/VideoWizard/index.tsx

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import {
88
WizardLayout,
99
builderDashboardRoute,
1010
builderFullScreenErrorRoute,
11+
flags,
1112
modelName,
1213
useAppConfig,
14+
useFlags,
1315
useResponsive,
1416
withLink,
1517
} from 'lib-components';
@@ -25,14 +27,14 @@ import {
2527

2628
const messages = defineMessages({
2729
chooseActionTitle: {
28-
defaultMessage: 'What are you willing to do ?',
30+
defaultMessage: 'What would you like to do?',
2931
description: 'Title asking what actions the user wants to do.',
3032
id: 'component.VideoWizard.chooseActionTitle',
3133
},
3234
descriptionText: {
3335
defaultMessage:
34-
'You can choose between creating a video and uploading one, or creating a live, that you will be able to schedule if needed.',
35-
description: 'A paragraph presenting the actions below.',
36+
'You can choose how you want to share your content using the options below.',
37+
description: 'A generic paragraph presenting the available actions.',
3638
id: 'component.VideoWizard.descriptionText',
3739
},
3840
createVideoButtonLabel: {
@@ -49,6 +51,7 @@ const VideoWizard = () => {
4951
const navigate = useNavigate();
5052
const { breakpoint, isSmallerBreakpoint } = useResponsive();
5153
const { video } = useAppConfig();
54+
const isFlagEnabled = useFlags((state) => state.isFlagEnabled);
5255

5356
if (!video) {
5457
return (
@@ -96,28 +99,35 @@ const VideoWizard = () => {
9699
{intl.formatMessage(messages.descriptionText)}
97100
</Text>
98101

99-
<CreateVODButton
100-
aria-label={intl.formatMessage(
101-
messages.createVideoButtonLabel,
102-
)}
103-
fullWidth
104-
title={intl.formatMessage(messages.createVideoButtonLabel)}
105-
to={builderVideoWizzardRoute(VideoWizzardSubPage.createVideo)}
106-
>
107-
{intl.formatMessage(messages.createVideoButtonLabel)}
108-
</CreateVODButton>
109-
110-
<ConfigureLiveButton
111-
video={video}
112-
RenderOnSuccess={
113-
<Navigate to={builderDashboardRoute(modelName.VIDEOS)} />
114-
}
115-
RenderOnError={
116-
<Navigate
117-
to={builderFullScreenErrorRoute(ErrorComponents.liveInit)}
118-
/>
119-
}
120-
/>
102+
{isFlagEnabled(flags.VIDEO) && (
103+
<CreateVODButton
104+
aria-label={intl.formatMessage(
105+
messages.createVideoButtonLabel,
106+
)}
107+
fullWidth
108+
title={intl.formatMessage(messages.createVideoButtonLabel)}
109+
to={builderVideoWizzardRoute(
110+
VideoWizzardSubPage.createVideo,
111+
)}
112+
>
113+
{intl.formatMessage(messages.createVideoButtonLabel)}
114+
</CreateVODButton>
115+
)}
116+
{isFlagEnabled(flags.WEBINAR) && (
117+
<ConfigureLiveButton
118+
video={video}
119+
RenderOnSuccess={
120+
<Navigate to={builderDashboardRoute(modelName.VIDEOS)} />
121+
}
122+
RenderOnError={
123+
<Navigate
124+
to={builderFullScreenErrorRoute(
125+
ErrorComponents.liveInit,
126+
)}
127+
/>
128+
}
129+
/>
130+
)}
121131
</Box>
122132
</WhiteCard>
123133
}

0 commit comments

Comments
 (0)