Skip to content

Commit

Permalink
test: fix test and format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-Torrent committed Oct 22, 2021
1 parent e4b9cd5 commit dbac48d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
10 changes: 8 additions & 2 deletions cypress/fixtures/apps.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { APP_NAME } from './apps/apps';
import { ITEM_TYPES } from '../../src/enums';
import { DEFAULT_FOLDER_ITEM } from './items';
import { CURRENT_USER } from './members';
Expand All @@ -16,7 +17,7 @@ export const GRAASP_APP_ITEM = {
description: 'my app description',
type: ITEM_TYPES.APP,
extra: {
[ITEM_TYPES.APP]: { url: 'http://localhost.com:3333' },
[ITEM_TYPES.APP]: { url: 'http://localhost.com:3333', name: APP_NAME },
},
creator: CURRENT_USER.id,
};
Expand All @@ -28,6 +29,7 @@ export const GRAASP_APP_PARENT_FOLDER = {
path: 'bdf09f5a_5688_11eb_ae93_0242ac130002',
extra: {
image: 'someimageurl',
name: APP_NAME
},
};

Expand All @@ -39,7 +41,10 @@ export const GRAASP_APP_CHILDREN_ITEM = {
description: 'my app description',
type: ITEM_TYPES.APP,
extra: {
[ITEM_TYPES.APP]: { url: 'http://localhost.com:3333' },
[ITEM_TYPES.APP]: {
url: 'http://localhost.com:3333',
name: APP_NAME
},
},
creator: CURRENT_USER.id,
};
Expand All @@ -53,6 +58,7 @@ export const APP_USING_CONTEXT_ITEM = {
extra: {
[ITEM_TYPES.APP]: {
url: `${API_HOST}/${buildAppItemLinkForTest('app.html')}`,
name: APP_NAME
},
},
creator: CURRENT_USER.id,
Expand Down
7 changes: 4 additions & 3 deletions cypress/fixtures/apps/apps.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// eslint-disable-next-line import/prefer-default-export
export const APP_NAME = "test app";

export const APPS_LIST = [
{
name: "test",
name: APP_NAME,
url: "http://localhost.com:3333",
extra:{
extra: {
image: "https://pbs.twimg.com/profile_images/1300707321262346240/IsQAyu7q_400x400.jpg"
}
}
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Cypress.Commands.add(
if(type){
cy.get(`#${ITEM_FORM_APP_URL_ID}`).type(getAppExtra(extra)?.url);
}else{
cy.get(`#${buildItemFormAppOptionId(getAppExtra(extra)?.url)}`).click();
cy.get(`#${buildItemFormAppOptionId(getAppExtra(extra)?.name)}`).click();
}

if (confirm) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/PinButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ const PinButton = ({ item }) => {

const handlePin = () => {
setPinned(!isPinned);

editItem.mutate({
id: item.id,
name: item.name,
settings: {
isPinned: !isPinned
isPinned: !isPinned,
},
});
};
Expand Down
17 changes: 12 additions & 5 deletions src/components/item/form/AppForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import { Autocomplete } from '@material-ui/lab';
import BaseItemForm from './BaseItemForm';
import { buildAppExtra, getAppExtra } from '../../../utils/itemExtra';
import { hooks } from '../../../config/queryClient';
import { ITEM_FORM_APP_URL_ID, buildItemFormAppOptionId } from '../../../config/selectors';
import {
ITEM_FORM_APP_URL_ID,
buildItemFormAppOptionId,
} from '../../../config/selectors';

const useStyles = makeStyles((theme) => ({
img: {
verticalAlign: 'middle',
margin: theme.spacing(1),
height: '30px'
height: '30px',
},
}));

Expand All @@ -25,7 +28,7 @@ const AppForm = ({ onChange, item }) => {
onChange({ ...item, extra: buildAppExtra({ url }) });
};

const classes = useStyles()
const classes = useStyles();
const { useApps } = hooks;
const { data } = useApps();

Expand All @@ -35,7 +38,7 @@ const AppForm = ({ onChange, item }) => {
<div>
<Typography variant="h6">{t('Create an App')}</Typography>
<BaseItemForm onChange={onChange} item={item} />

<Autocomplete
id={ITEM_FORM_APP_URL_ID}
freeSolo
Expand All @@ -46,7 +49,11 @@ const AppForm = ({ onChange, item }) => {
onInputChange={handleAppUrlInput}
renderOption={(option) => (
<div id={buildItemFormAppOptionId(option.name)}>
<img className={classes.img} src={option.extra.image} alt={option.name} />
<img
className={classes.img}
src={option.extra.image}
alt={option.name}
/>
{option.name}
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/item/settings/ItemSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ItemSettings = ({ item }) => {
id: item.get('id'),
name: item.get('name'),
settings: {
showChatbox: event.target.checked
showChatbox: event.target.checked,
},
});
};
Expand All @@ -52,7 +52,7 @@ const ItemSettings = ({ item }) => {
id: item.get('id'),
name: item.get('name'),
settings: {
isPinned: event.target.checked
isPinned: event.target.checked,
},
});
};
Expand Down
3 changes: 2 additions & 1 deletion src/config/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export const DOCUMENT_ITEM_TEXT_EDITOR_ID = 'documentItemTextEditor';
export const DOCUMENT_ITEM_TEXT_EDITOR_SELECTOR = `#${DOCUMENT_ITEM_TEXT_EDITOR_ID} .ql-editor`;
export const CREATE_ITEM_APP_ID = 'createItemApp';
export const ITEM_FORM_APP_URL_ID = 'itemFormAppUrl';
export const buildItemFormAppOptionId = (name) => `${name.replaceAll(/\s/g, '-')}`;
export const buildItemFormAppOptionId = (name) =>
`${name.replaceAll(/\s/g, '-')}`;
export const TEXT_EDITOR_CLASS = 'ql-editor';
export const buildSaveButtonId = (id) => `saveButton-${id}`;
export const MEMBER_PROFILE_MEMBER_ID_ID = 'memberProfileMemberId';
Expand Down

0 comments on commit dbac48d

Please sign in to comment.