mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
Add patch test for profile
This commit is contained in:
parent
2b93840807
commit
35ef677c60
|
@ -54,6 +54,19 @@ class TestUserUserProfileAPIView(APITestCase):
|
|||
self.assertEqual(response.data['first_name'], self.first_name)
|
||||
self.assertEqual(response.data['last_name'], '')
|
||||
|
||||
def test_patch_profile(self):
|
||||
self.client.force_login(user=self.user)
|
||||
data = json.dumps({
|
||||
'email': '123@mail.ru',
|
||||
'first_name': 'firstName',
|
||||
'last_name': 'lastName',
|
||||
})
|
||||
response = self.client.patch('/users/api/profile', data=data, content_type='application/json')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data['email'], '123@mail.ru')
|
||||
self.assertEqual(response.data['first_name'], 'firstName')
|
||||
self.assertEqual(response.data['last_name'], 'lastName')
|
||||
|
||||
def test_edit_profile(self):
|
||||
newmail = 'newmail@gmail.com'
|
||||
data = json.dumps({'email': newmail})
|
||||
|
|
|
@ -7,6 +7,8 @@ import { Loader } from '../../components/Common/Loader';
|
|||
import { useRSForm } from '../../context/RSFormContext';
|
||||
import useLocalStorage from '../../hooks/useLocalStorage';
|
||||
import { type IConstituenta } from '../../utils/models';
|
||||
import DlgCloneRSForm from './DlgCloneRSForm';
|
||||
import DlgUploadRSForm from './DlgUploadRSForm';
|
||||
import EditorConstituenta from './EditorConstituenta';
|
||||
import EditorItems from './EditorItems';
|
||||
import EditorRSForm from './EditorRSForm';
|
||||
|
@ -24,6 +26,9 @@ function RSTabs() {
|
|||
const [tabIndex, setTabIndex] = useLocalStorage('rsform_edit_tab', RSTabsList.CARD);
|
||||
const [init, setInit] = useState(false);
|
||||
|
||||
const [showUploadDialog, setShowUploadDialog] = useState(false);
|
||||
const [showCloneDialog, setShowCloneDialog] = useState(false);
|
||||
|
||||
const onEditCst = (cst: IConstituenta) => {
|
||||
setActiveID(cst.id);
|
||||
setTabIndex(RSTabsList.CST_EDIT)
|
||||
|
@ -84,6 +89,15 @@ function RSTabs() {
|
|||
{ loading && <Loader /> }
|
||||
{ error && <BackendError error={error} />}
|
||||
{ schema && !loading &&
|
||||
<>
|
||||
<DlgUploadRSForm
|
||||
show={showUploadDialog}
|
||||
hideWindow={() => { setShowUploadDialog(false); }}
|
||||
/>
|
||||
<DlgCloneRSForm
|
||||
show={showCloneDialog}
|
||||
hideWindow={() => { setShowCloneDialog(false); }}
|
||||
/>
|
||||
<Tabs
|
||||
selectedIndex={tabIndex}
|
||||
onSelect={onSelectTab}
|
||||
|
@ -91,7 +105,10 @@ function RSTabs() {
|
|||
selectedTabClassName='font-bold'
|
||||
>
|
||||
<TabList className='flex items-start w-fit clr-bg-pop'>
|
||||
<RSTabsMenu />
|
||||
<RSTabsMenu
|
||||
showCloneDialog={() => setShowCloneDialog(true)}
|
||||
showUploadDialog={() => setShowUploadDialog(true)}
|
||||
/>
|
||||
<ConceptTab>Паспорт схемы</ConceptTab>
|
||||
<ConceptTab className='border-x-2 clr-border min-w-[10rem] flex justify-between gap-2'>
|
||||
<span>Конституенты</span>
|
||||
|
@ -112,7 +129,7 @@ function RSTabs() {
|
|||
<TabPanel>
|
||||
<EditorConstituenta />
|
||||
</TabPanel>
|
||||
</Tabs>
|
||||
</Tabs></>
|
||||
}
|
||||
</div>);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useState } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import Button from '../../components/Common/Button';
|
||||
|
@ -10,10 +10,13 @@ import { useAuth } from '../../context/AuthContext';
|
|||
import { useRSForm } from '../../context/RSFormContext';
|
||||
import useDropdown from '../../hooks/useDropdown';
|
||||
import { claimOwnershipProc, deleteRSFormProc, downloadRSFormProc, shareCurrentURLProc } from '../../utils/procedures';
|
||||
import DlgCloneRSForm from './DlgCloneRSForm';
|
||||
import DlgUploadRSForm from './DlgUploadRSForm';
|
||||
|
||||
function RSTabsMenu() {
|
||||
interface RSTabsMenuProps {
|
||||
showUploadDialog: () => void
|
||||
showCloneDialog: () => void
|
||||
}
|
||||
|
||||
function RSTabsMenu({showUploadDialog, showCloneDialog}: RSTabsMenuProps) {
|
||||
const navigate = useNavigate();
|
||||
const { user } = useAuth();
|
||||
const {
|
||||
|
@ -24,8 +27,7 @@ function RSTabsMenu() {
|
|||
} = useRSForm();
|
||||
const schemaMenu = useDropdown();
|
||||
const editMenu = useDropdown();
|
||||
const [showUploadDialog, setShowUploadDialog] = useState(false);
|
||||
const [showCloneDialog, setShowCloneDialogl] = useState(false);
|
||||
|
||||
|
||||
const handleClaimOwner = useCallback(() => {
|
||||
editMenu.hide();
|
||||
|
@ -45,13 +47,13 @@ function RSTabsMenu() {
|
|||
|
||||
const handleUpload = useCallback(() => {
|
||||
schemaMenu.hide();
|
||||
setShowUploadDialog(true);
|
||||
}, [schemaMenu]);
|
||||
showUploadDialog();
|
||||
}, [schemaMenu, showUploadDialog]);
|
||||
|
||||
const handleClone = useCallback(() => {
|
||||
schemaMenu.hide();
|
||||
setShowCloneDialogl(true);
|
||||
}, [schemaMenu]);
|
||||
showCloneDialog();
|
||||
}, [schemaMenu, showCloneDialog]);
|
||||
|
||||
const handleShare = useCallback(() => {
|
||||
schemaMenu.hide();
|
||||
|
@ -59,15 +61,6 @@ function RSTabsMenu() {
|
|||
}, [schemaMenu]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DlgUploadRSForm
|
||||
show={showUploadDialog}
|
||||
hideWindow={() => { setShowUploadDialog(false); }}
|
||||
/>
|
||||
<DlgCloneRSForm
|
||||
show={showCloneDialog}
|
||||
hideWindow={() => { setShowCloneDialogl(false); }}
|
||||
/>
|
||||
<div className='flex items-center w-fit'>
|
||||
<div ref={schemaMenu.ref}>
|
||||
<Button
|
||||
|
@ -152,7 +145,6 @@ function RSTabsMenu() {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ export function patchUploadTRS(target: string, request: FrontExchange<IRSFormUpl
|
|||
// ============ Helper functions =============
|
||||
function AxiosGet<ResponseData>({ endpoint, request, title, options }: IAxiosRequest<undefined, ResponseData>) {
|
||||
console.log(`REQUEST: [[${title}]]`);
|
||||
if (request.setLoading) request?.setLoading(true);
|
||||
if (request.setLoading) request.setLoading(true);
|
||||
axios.get<ResponseData>(endpoint, options)
|
||||
.then((response) => {
|
||||
if (request.setLoading) request.setLoading(false);
|
||||
|
|
Loading…
Reference in New Issue
Block a user