diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6c580de24..bd9765421d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Changed
+
+- Replace grommet Select by Cunningham Select (#2400)
+
## [4.4.0] - 2023-09-08
### Added
diff --git a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.spec.tsx b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.spec.tsx
index 9bc81cb5be..b02aa9a90b 100644
--- a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.spec.tsx
+++ b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.spec.tsx
@@ -214,7 +214,7 @@ describe('', () => {
},
);
- const fileFilter = screen.getByRole('button', { name: /Filter files/i });
+ const fileFilter = screen.getByRole('combobox', { name: /Filter files/i });
await userEvent.click(fileFilter);
await userEvent.click(
await screen.findByRole('option', { name: 'Unread' }),
diff --git a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.tsx b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.tsx
index a2c5940ddf..5bd781f8b1 100644
--- a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.tsx
+++ b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.tsx
@@ -1,4 +1,5 @@
-import { Box, Heading, Pagination, Paragraph, Select, Text } from 'grommet';
+import { Select } from '@openfun/cunningham-react';
+import { Box, Heading, Pagination, Paragraph, Text } from 'grommet';
import { Maybe } from 'lib-common';
import { FileDepository, Loader } from 'lib-components';
import React, { FocusEvent, useState } from 'react';
@@ -10,6 +11,8 @@ import {
useUpdateFileDepository,
} from 'apps/deposit/data/queries';
+type SelectProps = React.ComponentPropsWithoutRef;
+
const PAGE_SIZE = 10;
const messages = defineMessages({
@@ -77,7 +80,7 @@ export const DashboardInstructor = ({
const [indices, setIndices] = useState([0, PAGE_SIZE]);
const [readFilter, setReadFilter] = useState>(undefined);
- const { data, isError, isLoading, refetch } = useDepositedFiles(
+ const { data, isError, isLoading } = useDepositedFiles(
fileDepository.id,
{
limit: `${PAGE_SIZE}`,
@@ -103,9 +106,8 @@ export const DashboardInstructor = ({
},
];
- const onReadFilterChange = (event: React.ChangeEvent) => {
- setReadFilter(event.target.value);
- refetch();
+ const onReadFilterChange: SelectProps['onChange'] = (event) => {
+ setReadFilter(event.target.value as Maybe);
};
const { mutate } = useUpdateFileDepository(fileDepository.id);
@@ -190,17 +192,11 @@ export const DashboardInstructor = ({
pad="medium"
>
{
'Mon titre',
);
await userEvent.click(
- screen.getByRole('button', { name: /Select language/i }),
+ screen.getByRole('combobox', { name: /Select language/i }),
);
await userEvent.click(
await screen.findByRole('option', { name: /French/i }),
diff --git a/src/frontend/apps/lti_site/apps/markdown/components/MarkdownWizard/index.tsx b/src/frontend/apps/lti_site/apps/markdown/components/MarkdownWizard/index.tsx
index 7611331e82..d579da2a72 100644
--- a/src/frontend/apps/lti_site/apps/markdown/components/MarkdownWizard/index.tsx
+++ b/src/frontend/apps/lti_site/apps/markdown/components/MarkdownWizard/index.tsx
@@ -100,12 +100,14 @@ export const MarkdownWizard = ({ markdownDocumentId }: MarkdownWizardProps) => {
maxLength={255}
onChange={(event) => setLocalTitle(event.target.value)}
value={localTitle}
+ fullWidth
/>
', () => {
screen.getByText('Add a video or drag & drop it'),
).toBeInTheDocument();
expect(
- await screen.findByRole('button', {
- name: 'Select the license under which you want to publish your video; Selected: CC_BY',
+ await screen.findByRole('combobox', {
+ name: 'Select the license',
}),
).toBeInTheDocument();
+ expect(
+ await screen.findByText('Creative Common By Attribution'),
+ ).toBeInTheDocument();
expect(
screen.getByRole('button', { name: /Add Video/i }),
).toBeInTheDocument();
@@ -147,10 +150,13 @@ describe('', () => {
screen.getByText('Add a video or drag & drop it'),
).toBeInTheDocument();
expect(
- await screen.findByRole('button', {
- name: 'Select the license under which you want to publish your video; Selected: CC_BY',
+ await screen.findByRole('combobox', {
+ name: 'Select the license',
}),
).toBeInTheDocument();
+ expect(
+ await screen.findByText('Creative Common By Attribution'),
+ ).toBeInTheDocument();
expect(
screen.getByRole('button', { name: /Add Video/i }),
).toBeInTheDocument();
@@ -254,11 +260,15 @@ describe('', () => {
).toBeInTheDocument();
expect(
- await screen.findByRole('button', {
- name: 'Select the license under which you want to publish your video; Selected: CC_BY',
+ await screen.findByRole('combobox', {
+ name: 'Select the license',
}),
).toBeInTheDocument();
+ expect(
+ screen.getByText('Creative Common By Attribution'),
+ ).toBeInTheDocument();
+
const hiddenInput = screen.getByTestId('input-video-test-id');
await userEvent.upload(hiddenInput, file);
@@ -334,11 +344,15 @@ describe('', () => {
).toBeInTheDocument();
expect(
- await screen.findByRole('button', {
- name: 'Select the license under which you want to publish your video; Selected: CC_BY',
+ await screen.findByRole('combobox', {
+ name: 'Select the license',
}),
).toBeInTheDocument();
+ expect(
+ screen.getByText('Creative Common By Attribution'),
+ ).toBeInTheDocument();
+
const hiddenInput = screen.getByTestId('input-video-test-id');
await userEvent.upload(hiddenInput, file);
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/components/CreatePlaylistForm.spec.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/components/CreatePlaylistForm.spec.tsx
index c63f90c096..9fc09a32c5 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/components/CreatePlaylistForm.spec.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/components/CreatePlaylistForm.spec.tsx
@@ -91,21 +91,17 @@ describe('', () => {
expect(await screen.findByText('Create a playlist')).toBeInTheDocument();
- await userEvent.click(
- await screen.findByRole('button', { name: 'Open Drop; Selected: id' }),
- );
+ expect(screen.getByText('org')).toBeInTheDocument();
await userEvent.click(
- await screen.findByRole('option', { name: 'other-org' }),
+ screen.getByRole('combobox', {
+ name: 'Organization',
+ }),
);
+ await userEvent.click(screen.getByRole('option', { name: 'other-org' }));
- expect(
- await screen.findByRole('button', {
- name: 'Open Drop; Selected: other-id',
- }),
- ).toBeInTheDocument();
- expect(screen.getByDisplayValue('other-org')).toBeInTheDocument();
- expect(screen.queryByDisplayValue('org')).not.toBeInTheDocument();
+ expect(screen.getByText('other-org')).toBeInTheDocument();
+ expect(screen.queryByText('org')).not.toBeInTheDocument();
await userEvent.type(
screen.getByRole('textbox', { name: 'Name' }),
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistForm.spec.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistForm.spec.tsx
index 8f4e32bc60..bb40032960 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistForm.spec.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistForm.spec.tsx
@@ -56,7 +56,11 @@ describe('', () => {
deferred.resolve({ count: 0, results: [] });
await waitForElementToBeRemoved(loader);
- expect(screen.getByLabelText('Organization*required')).toBeInTheDocument();
+ expect(
+ await screen.findByRole('combobox', {
+ name: 'Organization',
+ }),
+ ).toBeInTheDocument();
expect(screen.getByLabelText('Name')).toBeInTheDocument();
const submitButton = screen.getByRole('button', { name: 'Save' });
@@ -86,13 +90,11 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: first id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('first organization')).toBeInTheDocument();
expect(screen.getByLabelText('Name')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument();
@@ -132,13 +134,11 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: second id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('second organization')).toBeInTheDocument();
expect(screen.getByDisplayValue('some initial name')).toBeInTheDocument();
expect(fetchMock.calls().length).toEqual(1);
@@ -178,13 +178,11 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: third id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('third organization')).toBeInTheDocument();
expect(screen.getByDisplayValue('some initial name')).toBeInTheDocument();
expect(fetchMock.calls().length).toEqual(2);
@@ -225,11 +223,8 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
expect(screen.getByDisplayValue('some initial name')).toBeInTheDocument();
@@ -276,7 +271,9 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
+ await screen.findByRole('combobox', {
+ name: 'Organization',
+ }),
).toBeInTheDocument();
await userEvent.click(screen.getByRole('button', { name: 'Save' }));
@@ -285,7 +282,7 @@ describe('', () => {
expect(mockedOnSubmit).toHaveBeenCalledWith({
name: 'some initial name',
organizationId: 'third id',
- retention_duration: 365,
+ retention_duration: '365',
});
await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
@@ -328,7 +325,9 @@ describe('', () => {
);
await userEvent.click(screen.getByRole('button', { name: 'Retry' }));
expect(
- await screen.findByLabelText('Organization*required'),
+ await screen.findByRole('combobox', {
+ name: 'Organization',
+ }),
).toBeInTheDocument();
});
@@ -358,13 +357,11 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: first id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('first organization')).toBeInTheDocument();
expect(screen.getByLabelText('Name')).toBeInTheDocument();
expect(screen.getByDisplayValue('some initial name')).toBeInTheDocument();
@@ -374,11 +371,7 @@ describe('', () => {
screen.queryByRole('button', { name: 'Delete playlist' }),
).not.toBeInTheDocument();
- await userEvent.click(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: first id',
- }),
- );
+ await userEvent.click(screen.getByText('first organization'));
await userEvent.click(
await screen.findByRole('option', { name: 'second organization' }),
);
@@ -389,11 +382,7 @@ describe('', () => {
'an other awesome name',
);
- expect(
- await screen.findByRole('button', {
- name: 'Open Drop; Selected: second id',
- }),
- ).toBeInTheDocument();
+ expect(screen.getByText('second organization')).toBeInTheDocument();
expect(
await screen.findByDisplayValue('an other awesome name'),
).toBeInTheDocument();
@@ -403,13 +392,11 @@ describe('', () => {
await waitFor(() => expect(mockedOnCancel).toHaveBeenCalled());
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: first id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('first organization')).toBeInTheDocument();
expect(screen.getByLabelText('Name')).toBeInTheDocument();
expect(screen.getByDisplayValue('some initial name')).toBeInTheDocument();
});
@@ -433,13 +420,11 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: first id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('first organization')).toBeInTheDocument();
expect(screen.getByLabelText('Name')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument();
@@ -470,13 +455,11 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: first id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('first organization')).toBeInTheDocument();
expect(screen.getByLabelText('Name')).toBeInTheDocument();
const deleteButton = screen.getByRole('button', {
@@ -517,13 +500,11 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: first id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('first organization')).toBeInTheDocument();
expect(screen.getByLabelText('Name')).toBeInTheDocument();
const deleteButton = screen.getByRole('button', {
@@ -561,13 +542,11 @@ describe('', () => {
);
expect(
- await screen.findByLabelText('Organization*required'),
- ).toBeInTheDocument();
- expect(
- screen.getByRole('button', {
- name: 'Open Drop; Selected: first id',
+ await screen.findByRole('combobox', {
+ name: 'Organization',
}),
).toBeInTheDocument();
+ expect(screen.getByText('first organization')).toBeInTheDocument();
expect(screen.getByLabelText('Name')).toBeInTheDocument();
const deleteButton = screen.getByRole('button', {
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistForm.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistForm.tsx
index b856088ef5..c080a6e97c 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistForm.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistForm.tsx
@@ -1,12 +1,10 @@
-import { Input } from '@openfun/cunningham-react';
-import { Box, Button, Heading, Select, Text, ThemeContext } from 'grommet';
+import { Input, Select } from '@openfun/cunningham-react';
+import { Box, Button, Heading, Text, ThemeContext } from 'grommet';
import { Nullable } from 'lib-common';
import {
ButtonLoaderStyle,
FetchResponseError,
Form,
- FormField,
- FormHelpText,
Modal,
ModalButton,
Organization,
@@ -80,7 +78,7 @@ const messages = defineMessages({
},
playlistRetentionDurationHelper: {
defaultMessage:
- 'This retention duration is use to know how long related resources will be kept.',
+ 'This retention duration is used to know how long related resources will be kept.',
description: 'Playlist retention duration helper in create playlist form .',
id: 'feature.Playlist.PlaylistForm.playlistRetentionDurationHelper',
},
@@ -179,7 +177,7 @@ export const PlaylistForm = ({
const [formValues, setFormValues] = useState>({
organizationId: initialValues?.organizationId,
name: initialValues?.name || '',
- retention_duration: initialValues?.retention_duration || null,
+ retention_duration: initialValues?.retention_duration,
});
const [isModalOpen, setIsModalOpen] = useState(false);
const [currentOrganizationPage, setCurrentOrganizationPage] = useState(0);
@@ -268,25 +266,24 @@ export const PlaylistForm = ({
label: intl.formatMessage(
messages.playlistRetentionDurationChoiceNoDuration,
),
- value: null,
},
{
label: intl.formatMessage(
messages.playlistRetentionDurationChoice30Days,
),
- value: 30,
+ value: '30',
},
{
label: intl.formatMessage(
messages.playlistRetentionDurationChoice1Year,
),
- value: 365,
+ value: '365',
},
{
label: intl.formatMessage(
messages.playlistRetentionDurationChoice5years,
),
- value: 365 * 5,
+ value: `${365 * 5}`,
},
],
[intl],
@@ -365,37 +362,24 @@ export const PlaylistForm = ({
)}
-
-
-
- {intl.formatMessage(messages.organizationHelper)}
-
+ disabled={!isEditable}
+ options={organizations.map((organization) => ({
+ label: organization.name,
+ value: organization.id,
+ }))}
+ onChange={(e) => {
+ setFormValues((value) => ({
+ ...value,
+ organizationId: e.target.value as string,
+ }));
+ }}
+ fullWidth
+ text={intl.formatMessage(messages.organizationHelper)}
+ value={formValues.organizationId}
+ />
-
-
-
-
- {intl.formatMessage(messages.playlistRetentionDurationHelper)}
-
+ disabled={!isEditable}
+ options={retentionDurationChoices}
+ onChange={(e) => {
+ setFormValues((value) => ({
+ ...value,
+ retention_duration: e.target.value as number,
+ }));
+ }}
+ fullWidth
+ text={intl.formatMessage(
+ messages.playlistRetentionDurationHelper,
+ )}
+ value={
+ formValues.retention_duration
+ ? `${formValues.retention_duration}`
+ : undefined
+ }
+ />
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistPage.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistPage.tsx
index 5504b88f59..fd1bf4b1ea 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistPage.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/components/PlaylistPage.tsx
@@ -10,6 +10,7 @@ import { Modal, Playlist, useResponsive } from 'lib-components';
import { Fragment, useEffect, useMemo, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { Route, Routes, useNavigate } from 'react-router-dom';
+import styled from 'styled-components';
import { WhiteCard } from 'components/Cards';
import { ITEM_PER_PAGE } from 'conf/global';
@@ -67,6 +68,18 @@ const messages = defineMessages({
},
});
+export const BoxDatagrid = styled(Box)`
+ .c__datagrid {
+ display: block;
+ overflow: auto;
+ }
+ .c__datagrid td {
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ }
+`;
+
/**
* Clean the data to be displayed in the table
*/
@@ -217,51 +230,57 @@ export const PlaylistPage = () => {
)}
{!shouldDisplayNoPlaylistYetMessage && (
- (
- {
- navigate(`${routes.PLAYLIST.path}/${row.id}/update`);
- }}
- icon={settings}
- />
- ),
- },
- ]}
- rows={rows}
- pagination={pagination}
- sortModel={sortModel}
- onSortModelChange={setSortModel}
- isLoading={isLoading}
- />
+
+ (
+ {
+ navigate(
+ `${routes.PLAYLIST.path}/${row.id}/update`,
+ );
+ }}
+ icon={
+ settings
+ }
+ />
+ ),
+ },
+ ]}
+ rows={rows}
+ pagination={pagination}
+ sortModel={sortModel}
+ onSortModelChange={setSortModel}
+ isLoading={isLoading}
+ />
+
)}
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/api/useUpdatePlaylistAccess/index.ts b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/api/useUpdatePlaylistAccess/index.ts
index 1bd7759210..b79a50cf9b 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/api/useUpdatePlaylistAccess/index.ts
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/api/useUpdatePlaylistAccess/index.ts
@@ -1,8 +1,4 @@
-import {
- UseMutationOptions,
- useMutation,
- useQueryClient,
-} from '@tanstack/react-query';
+import { UseMutationOptions, useMutation } from '@tanstack/react-query';
import { updateOne } from 'lib-components';
import { PlaylistAccess, PlaylistRole } from '../../types/playlistAccess';
@@ -17,7 +13,7 @@ type UseUpdatePlaylistAccessError =
errors: { [key in keyof UseUpdatePlaylistAccessData]?: string[] };
}[];
-export const useUpdatePlaylistAcess = (
+export const useUpdatePlaylistAccess = (
id: string,
options?: UseMutationOptions<
PlaylistAccess,
@@ -25,7 +21,6 @@ export const useUpdatePlaylistAcess = (
UseUpdatePlaylistAccessData
>,
) => {
- const queryClient = useQueryClient();
return useMutation<
PlaylistAccess,
UseUpdatePlaylistAccessError,
@@ -39,7 +34,6 @@ export const useUpdatePlaylistAcess = (
}),
...options,
onSuccess: (data, variables, context) => {
- queryClient.invalidateQueries(['playlist-accesses']);
options?.onSuccess?.(data, variables, context);
},
});
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/AddUserAccessForm.spec.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/AddUserAccessForm.spec.tsx
index 631ef2e6b9..e36e398a6e 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/AddUserAccessForm.spec.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/AddUserAccessForm.spec.tsx
@@ -72,7 +72,9 @@ describe('AddUserAccessForm', () => {
await userEvent.click(
screen.getByRole('button', { name: 'Add user User 1 in playlist' }),
);
- await userEvent.click(screen.getByRole('button', { name: /Select role/i }));
+ await userEvent.click(
+ screen.getByRole('combobox', { name: /Select role/i }),
+ );
await userEvent.click(
await screen.findByRole('option', { name: /Instructor/i }),
);
@@ -153,7 +155,9 @@ describe('AddUserAccessForm', () => {
await userEvent.click(
screen.getByRole('button', { name: 'Add user User 1 in playlist' }),
);
- await userEvent.click(screen.getByRole('button', { name: /Select role/i }));
+ await userEvent.click(
+ screen.getByRole('combobox', { name: /Select role/i }),
+ );
await userEvent.click(
await screen.findByRole('option', { name: /Instructor/i }),
);
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/AddUserAccessForm.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/AddUserAccessForm.tsx
index f5ef56dca5..8c602bb2cc 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/AddUserAccessForm.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/AddUserAccessForm.tsx
@@ -1,5 +1,5 @@
-import { Input } from '@openfun/cunningham-react';
-import { Box, Heading, Paragraph, Select } from 'grommet';
+import { Input, Select } from '@openfun/cunningham-react';
+import { Box, Heading, Paragraph } from 'grommet';
import { Nullable } from 'lib-common';
import { ModalButton } from 'lib-components';
import { debounce } from 'lodash';
@@ -67,7 +67,7 @@ export const AddUserAccessForm = ({
const [searchedUser, setSearchedUser] = useState('');
const [selectedUser, setSelectedUser] = useState>(null);
const [roleValue, setRoleValue] = useState(
- options.find((option) => option.key === PlaylistRole.STUDENT),
+ options.find((option) => option.value === PlaylistRole.STUDENT),
);
const { mutate: createPlaylistAccess } = useCreatePlaylistAccess({
onSuccess: () => {
@@ -101,17 +101,17 @@ export const AddUserAccessForm = ({
', () => {
render();
- expect(await screen.findByText('sbire 1')).toBeInTheDocument();
+ await waitFor(() => {
+ expect(screen.getByText('sbire 1')).toBeInTheDocument();
+ });
expect(screen.getByText('sbire 2')).toBeInTheDocument();
expect(screen.getByText('sbire 3')).toBeInTheDocument();
});
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UpdatePlaylistPage.spec.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UpdatePlaylistPage.spec.tsx
index 87cb57bef3..cb5009fb1e 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UpdatePlaylistPage.spec.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UpdatePlaylistPage.spec.tsx
@@ -1,4 +1,4 @@
-import { screen, waitFor } from '@testing-library/react';
+import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import { Playlist } from 'lib-components';
@@ -78,13 +78,20 @@ describe('', () => {
expect(
await screen.findByRole('heading', { name: 'Main informations' }),
).toBeInTheDocument();
+ expect(await screen.findByText('first orga')).toBeInTheDocument();
expect(
- await screen.findByRole('button', {
- name: 'Open Drop; Selected: id orga',
+ screen.queryByRole('combobox', {
+ name: 'Organization',
}),
).not.toBeDisabled();
expect(screen.getByDisplayValue('playlist title')).not.toBeDisabled();
- expect(screen.getByDisplayValue('1 year')).not.toBeDisabled();
+
+ expect(screen.getByText('1 year')).toBeInTheDocument();
+ expect(
+ screen.queryByRole('combobox', {
+ name: 'Retention duration',
+ }),
+ ).not.toBeDisabled();
expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument();
@@ -103,12 +110,6 @@ describe('', () => {
await userEvent.click(screen.getByRole('button', { name: 'Save' }));
- await waitFor(() =>
- expect(
- screen.getByRole('button', { name: 'Open Drop; Selected: id orga' }),
- ).toBeDisabled(),
- );
-
fetchMock.mock('/api/playlists/some-id/', playlist, {
overwriteRoutes: true,
});
@@ -118,12 +119,6 @@ describe('', () => {
await screen.findByText('Playlist updated with success.'),
).toBeInTheDocument();
- await waitFor(() =>
- expect(
- screen.getByRole('button', { name: 'Open Drop; Selected: id orga' }),
- ).not.toBeDisabled(),
- );
-
expect(
screen.getByRole('button', { name: 'Delete playlist' }),
).toBeInTheDocument();
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UserListRow.spec.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UserListRow.spec.tsx
index 0b88e519ff..68418f7777 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UserListRow.spec.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UserListRow.spec.tsx
@@ -75,18 +75,13 @@ describe('', () => {
expect(
screen.getByText('my full name (my-email@openfun.fr)'),
).toBeInTheDocument();
- expect(
- screen.getByRole('button', { name: /Open Drop/ }),
- ).toBeInTheDocument();
- expect(screen.getByRole('textbox')).toHaveValue('Administrator');
expect(
screen.getByRole('button', { name: 'Delete user.' }),
).toBeInTheDocument();
- await userEvent.click(screen.getByRole('button', { name: /Open Drop/ }));
-
+ await userEvent.click(screen.getByText('Administrator'));
expect(
- await screen.findByRole('option', { name: 'Instructor' }),
+ screen.getByRole('option', { name: 'Instructor' }),
).toBeInTheDocument();
expect(screen.getByRole('option', { name: 'Student' })).toBeInTheDocument();
expect(
@@ -109,8 +104,7 @@ describe('', () => {
/>,
);
- await userEvent.click(screen.getByRole('button', { name: /Open Drop/ }));
-
+ await userEvent.click(screen.getByText('Administrator'));
const instructorOption = screen.getByRole('option', {
name: 'Instructor',
});
@@ -118,7 +112,7 @@ describe('', () => {
await userEvent.click(instructorOption);
- expect(screen.getByRole('textbox')).toHaveValue('Instructor');
+ expect(screen.getByText('Instructor')).toBeInTheDocument();
expect(
await screen.findByText('Right has been updated with success.'),
).toBeInTheDocument();
@@ -144,8 +138,9 @@ describe('', () => {
/>,
);
- await userEvent.click(screen.getByRole('button', { name: /Open Drop/ }));
+ expect(screen.queryByText('Instructor')).not.toBeInTheDocument();
+ await userEvent.click(screen.getByText('Administrator'));
const instructorOption = screen.getByRole('option', {
name: 'Instructor',
});
@@ -153,7 +148,7 @@ describe('', () => {
await userEvent.click(instructorOption);
- expect(screen.getByRole('textbox')).toHaveValue('Instructor');
+ expect(screen.getByText('Instructor')).toBeInTheDocument();
deferred.reject();
@@ -161,7 +156,7 @@ describe('', () => {
await screen.findByText('An error occurred while updating the right.'),
).toBeInTheDocument();
- expect(screen.getByRole('textbox')).toHaveValue('Administrator');
+ expect(await screen.findByText('Administrator')).toBeInTheDocument();
});
it('calls for delete', async () => {
@@ -260,8 +255,9 @@ describe('', () => {
expect(
screen.getByText('my full name (my-email@openfun.fr)'),
).toBeInTheDocument();
- expect(screen.getByRole('button', { name: /Open Drop/ })).toBeDisabled();
- expect(screen.getByRole('textbox')).toHaveValue('Administrator');
+ const select = screen.getByRole('combobox');
+ expect(select.contains(screen.getByText('Administrator'))).toBeTruthy();
+ expect(select.hasAttribute('disabled')).toBeTruthy();
expect(screen.getByRole('button', { name: 'Delete user.' })).toBeDisabled();
});
});
diff --git a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UserListRow.tsx b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UserListRow.tsx
index 240b6af976..312a20e0bb 100644
--- a/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UserListRow.tsx
+++ b/src/frontend/apps/standalone_site/src/features/Playlist/features/UpdatePlaylist/components/UserListRow.tsx
@@ -1,4 +1,5 @@
-import { Box, Button, Select, Text } from 'grommet';
+import { Select } from '@openfun/cunningham-react';
+import { Box, Button, Text } from 'grommet';
import {
AnonymousUser,
BinSVG,
@@ -13,12 +14,17 @@ import { toast } from 'react-hot-toast';
import { defineMessages, useIntl } from 'react-intl';
import { useDeletePlaylistAccess } from '../api/useDeletePlaylistAccess';
-import { useUpdatePlaylistAcess } from '../api/useUpdatePlaylistAccess';
+import { useUpdatePlaylistAccess } from '../api/useUpdatePlaylistAccess';
import { PlaylistAccess, PlaylistRole } from '../types/playlistAccess';
import { userRoleOptions } from './UserRoleOptions';
const messages = defineMessages({
+ labelSelectRole: {
+ defaultMessage: 'Role',
+ description: 'The label on the select role input.',
+ id: 'features.Playlist.features.UpdatePlaylist.components.UserListRow.labelSelectRole',
+ },
anonymousUser: {
defaultMessage: 'Anonymous',
description: 'Update page, playlist access row for user without full name.',
@@ -66,9 +72,6 @@ const messages = defineMessages({
},
});
-type Option = { label: string; key: PlaylistRole };
-type SelectOnChangeEvent = { option: Option };
-
interface UserLabelColumnProps {
user: PlaylistAccess['user'];
}
@@ -84,7 +87,17 @@ export const UserLabelColumn = ({ user }: UserLabelColumnProps) => {
userLabel = user.email;
}
- return {userLabel};
+ return (
+
+ {userLabel}
+
+ );
};
interface UserRolesColumnProps {
@@ -101,16 +114,16 @@ export const UserRolesColumn = ({
const intl = useIntl();
const options = userRoleOptions(intl);
- const initialOption = options.find((option) => option.key === role);
+ const initialRole = options.find((option) => option.value === role)?.value;
+ const [userRole, setUserRole] = useState(initialRole);
- const [userRole, setUserRole] = useState(initialOption);
- const { mutate: updateMutation } = useUpdatePlaylistAcess(playlistAccessId, {
+ const { mutate: updateMutation } = useUpdatePlaylistAccess(playlistAccessId, {
onSuccess: () => {
toast.success(intl.formatMessage(messages.updatePlaylistAccessSuccess));
},
onError: () => {
toast.error(intl.formatMessage(messages.updatePlaylistAccessError));
- setUserRole(initialOption);
+ setUserRole(initialRole);
},
});
const { currentUser } = useCurrentUser();
@@ -122,15 +135,23 @@ export const UserRolesColumn = ({
return (
-
+
-
-
+
+
+
diff --git a/src/frontend/packages/lib_markdown/src/components/MarkdownViewer/index.spec.tsx b/src/frontend/packages/lib_markdown/src/components/MarkdownViewer/index.spec.tsx
index 24d736192c..33cbbbb82d 100644
--- a/src/frontend/packages/lib_markdown/src/components/MarkdownViewer/index.spec.tsx
+++ b/src/frontend/packages/lib_markdown/src/components/MarkdownViewer/index.spec.tsx
@@ -45,7 +45,7 @@ describe('', () => {
// Change language to fr
await userEvent.click(
- screen.getByRole('button', { name: /Select language/i }),
+ screen.getByRole('combobox', { name: /Select language/i }),
);
await userEvent.click(
await screen.findByRole('option', { name: /French/i }),
@@ -75,7 +75,7 @@ describe('', () => {
// Change language to fr
await userEvent.click(
- screen.getByRole('button', { name: /Select language/i }),
+ screen.getByRole('combobox', { name: /Select language/i }),
);
await userEvent.click(
await screen.findByRole('option', { name: /French/i }),
@@ -127,7 +127,7 @@ describe('', () => {
// Change language to fr
await userEvent.click(
- screen.getByRole('button', { name: /Select language/i }),
+ screen.getByRole('combobox', { name: /Select language/i }),
);
await userEvent.click(
await screen.findByRole('option', { name: /French/i }),
diff --git a/src/frontend/packages/lib_video/src/components/common/VideoWidgetProvider/LocalizedTimedTextTrackUpload/LanguageSelect/index.spec.tsx b/src/frontend/packages/lib_video/src/components/common/VideoWidgetProvider/LocalizedTimedTextTrackUpload/LanguageSelect/index.spec.tsx
index 21d5d87e3a..88c9eab100 100644
--- a/src/frontend/packages/lib_video/src/components/common/VideoWidgetProvider/LocalizedTimedTextTrackUpload/LanguageSelect/index.spec.tsx
+++ b/src/frontend/packages/lib_video/src/components/common/VideoWidgetProvider/LocalizedTimedTextTrackUpload/LanguageSelect/index.spec.tsx
@@ -1,4 +1,4 @@
-import { screen, waitFor } from '@testing-library/react';
+import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import {
@@ -26,8 +26,6 @@ const languageChoices = [
];
describe('', () => {
- //jest.spyOn(console, 'error').mockImplementation(() => jest.fn());
-
afterEach(() => {
fetchMock.restore();
});
@@ -49,14 +47,10 @@ describe('', () => {
}),
);
- screen.getByRole('button', {
- name: 'Select the language for which you want to upload a timed text file; Selected: fr',
+ const button = await screen.findByRole('combobox', {
+ name: 'Choose the language',
});
- expect(
- screen.getByRole('textbox', {
- name: 'Select the language for which you want to upload a timed text file, fr',
- }),
- ).toHaveValue('French');
+ expect(within(button).getByText('French')).toBeInTheDocument();
});
it('renders the component with instructor local language unavailable', async () => {
@@ -76,14 +70,10 @@ describe('', () => {
}),
);
- screen.getByRole('button', {
- name: 'Select the language for which you want to upload a timed text file; Selected: en',
+ const button = await screen.findByRole('combobox', {
+ name: 'Choose the language',
});
- expect(
- screen.getByRole('textbox', {
- name: 'Select the language for which you want to upload a timed text file, en',
- }),
- ).toHaveValue('English');
+ expect(within(button).getByText('English')).toBeInTheDocument();
});
it('renders the component with some languages already having some subtitles uploaded', async () => {
@@ -114,17 +104,12 @@ describe('', () => {
}),
);
- expect(
- screen.getByRole('textbox', {
- name: 'Select the language for which you want to upload a timed text file, fr',
- }),
- ).toHaveValue('French');
+ const button = await screen.findByRole('combobox', {
+ name: 'Choose the language',
+ });
+ expect(within(button).getByText('French')).toBeInTheDocument();
- await userEvent.click(
- screen.getByRole('button', {
- name: 'Select the language for which you want to upload a timed text file; Selected: fr',
- }),
- );
+ await userEvent.click(button);
screen.getByRole('option', { name: 'English' });
screen.getByRole('option', { name: 'French' });
@@ -162,14 +147,12 @@ describe('', () => {
}),
).not.toBeInTheDocument();
- screen.getByRole('button', {
- name: 'Select the language for which you want to upload a timed text file; Selected: error',
+ const button = await screen.findByRole('combobox', {
+ name: 'Choose the language',
});
expect(
- screen.getByRole('textbox', {
- name: 'Select the language for which you want to upload a timed text file, error',
- }),
- ).toHaveValue('No language availables');
+ within(button).getByText('No language availables'),
+ ).toBeInTheDocument();
});
it('changes the selected language', async () => {
@@ -189,29 +172,12 @@ describe('', () => {
}),
);
- expect(
- await screen.findByRole('textbox', {
- name: 'Select the language for which you want to upload a timed text file, fr',
- }),
- ).toHaveValue('French');
-
- await userEvent.click(
- screen.getByRole('button', {
- name: 'Select the language for which you want to upload a timed text file; Selected: fr',
- }),
- );
-
- const englishButtonOption = screen.getByRole('option', { name: 'English' });
-
- await userEvent.click(englishButtonOption);
-
- screen.getByRole('button', {
- name: 'Select the language for which you want to upload a timed text file; Selected: en',
+ const button = await screen.findByRole('combobox', {
+ name: 'Choose the language',
});
- expect(
- screen.getByRole('textbox', {
- name: 'Select the language for which you want to upload a timed text file, en',
- }),
- ).toHaveValue('English');
+ expect(within(button).getByText('French')).toBeInTheDocument();
+ await userEvent.click(button);
+ await userEvent.click(screen.getByRole('option', { name: 'English' }));
+ expect(within(button).getByText('English')).toBeInTheDocument();
});
});
diff --git a/src/frontend/packages/lib_video/src/components/common/VideoWidgetProvider/LocalizedTimedTextTrackUpload/LanguageSelect/index.tsx b/src/frontend/packages/lib_video/src/components/common/VideoWidgetProvider/LocalizedTimedTextTrackUpload/LanguageSelect/index.tsx
index 3aa1b81521..850c3a6e62 100644
--- a/src/frontend/packages/lib_video/src/components/common/VideoWidgetProvider/LocalizedTimedTextTrackUpload/LanguageSelect/index.tsx
+++ b/src/frontend/packages/lib_video/src/components/common/VideoWidgetProvider/LocalizedTimedTextTrackUpload/LanguageSelect/index.tsx
@@ -1,4 +1,5 @@
-import { Select, timedTextMode, useTimedTextTrack } from 'lib-components';
+import { Select } from '@openfun/cunningham-react';
+import { timedTextMode, useTimedTextTrack } from 'lib-components';
import { useEffect, useMemo, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
@@ -6,12 +7,18 @@ import { LanguageChoice } from '@lib-video/types/SelectOptions';
const messages = defineMessages({
selectLanguageLabel: {
- defaultMessage:
- 'Select the language for which you want to upload a timed text file',
+ defaultMessage: 'Choose the language',
description:
'The label of the select used for choosing the language for which the user wants to upload a file.',
id: 'components.LanguageSelect.selectLanguageLabel',
},
+ selectLanguageInfo: {
+ defaultMessage:
+ 'The language for which you want to upload a timed text file',
+ description:
+ 'The text under the select used for choosing the language for which the user wants to upload a file.',
+ id: 'components.LanguageSelect.selectLanguageInfo',
+ },
noLanguageAvailableLabel: {
defaultMessage: 'No language availables',
description:
@@ -98,14 +105,19 @@ export const LanguageSelect = ({
return (