Skip to content

Commit

Permalink
cleanup: remove commented code and unnecessary fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikmonsen committed Jan 10, 2025
1 parent c424a4c commit 12f171c
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 90 deletions.
68 changes: 0 additions & 68 deletions __tests__/components/ContactInformation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,71 +31,3 @@ test('ContactInformation should render emails', () => {
expect(screen.getByText('E-postadresse')).toBeTruthy();
expect(screen.getByText(MockContactEmail1.contact_value)).toBeTruthy();
});

// test('Title page contact and release does not open in edit mode', async () => {
// await screen.findByText('Legg til telefon');
//
// expect(screen.getByText('Kontaktinformasjon', {exact: false})).toBeTruthy();
// expect(screen.getByText('Avleverer:', {exact: false})).toBeTruthy();
// expect(screen.getByText('Kontaktperson:', {exact: false})).toBeTruthy();
// expect(screen.getByText('E-post:', {exact: false})).toBeTruthy();
// expect(screen.getByText('Telefon:', {exact: false})).toBeTruthy();
//
// expect(screen.queryByRole('textbox', {name: 'Avleverer'})).toBeNull();
// expect(screen.queryByRole('textbox', {name: 'Navn'})).toBeNull();
// expect(screen.queryByRole('textbox', {name: 'E-post'})).toBeNull();
// expect(screen.queryByRole('textbox', {name: 'Telefon'})).toBeNull();
// });
//
// test('Title page contact and release can be edited after button press', async () => {
// screen.getByRole('button', {name: 'Rediger'}).click();
// await vi.waitFor(() => screen.getByRole('textbox', {name: 'Avleverer'}));
//
// expect(screen.getByRole('textbox', {name: 'Avleverer'})).toBeTruthy();
// expect(screen.getByRole('textbox', {name: 'Navn'})).toBeTruthy();
// expect(screen.getByRole('textbox', {name: 'E-post'})).toBeTruthy();
// expect(screen.getByRole('textbox', {name: 'Telefon'})).toBeTruthy();
// });
//
// test('Title page contact and release shows success on successful button press', async () => {
// screen.getByRole('button', {name: 'Rediger'}).click();
// await vi.waitFor(() => screen.getByRole('textbox', {name: 'Avleverer'}));
//
// screen.getByRole('button', {name: 'Lagre'}).click();
// await vi.waitFor(() => screen.getByText('Kontakt- og utgivelsesinformasjon lagret!'));
// });
//
// test('Title page contact and release should have release pattern', async () => {
// expect(screen.getByText('Mandag:')).toBeTruthy();
// expect(screen.getByText('Tirsdag:')).toBeTruthy();
// expect(screen.getByText('Onsdag:')).toBeTruthy();
// expect(screen.getByText('Torsdag:')).toBeTruthy();
// expect(screen.getByText('Fredag:')).toBeTruthy();
// expect(screen.getByText('Lørdag:')).toBeTruthy();
// expect(screen.getByText('Søndag:')).toBeTruthy();
//
// screen.getByRole('button', {name: 'Rediger'}).click();
// await vi.waitFor(() => screen.getByRole('heading', {name: 'Utgivelsesmønster:'}));
// expect(screen.getAllByRole('gridcell', {name: '1'})).toBeTruthy();
// expect(screen.getAllByRole('gridcell', {name: '0'})).toBeTruthy();
// expect(screen.getByRole('rowheader', {name: 'Mandag'})).toBeTruthy();
// expect(screen.getByRole('rowheader', {name: 'Tirsdag'})).toBeTruthy();
// expect(screen.getByRole('rowheader', {name: 'Onsdag'})).toBeTruthy();
// expect(screen.getByRole('rowheader', {name: 'Torsdag'})).toBeTruthy();
// expect(screen.getByRole('rowheader', {name: 'Fredag'})).toBeTruthy();
// expect(screen.getByRole('rowheader', {name: 'Lørdag'})).toBeTruthy();
// expect(screen.getByRole('rowheader', {name: 'Søndag'})).toBeTruthy();
// });
//
// test('Title page contact and release should show error message on unsuccessful submit', async () => {
// cleanup();
// render(<Page params={{id: MockTitle.id.toString()}} />);
// // Mock rejected promise
// vi.mocked(putLocalTitle).mockImplementation(() => Promise.reject(new Error('Noe gikk galt ved lagring')));
//
// screen.getByRole('button', {name: 'Rediger'}).click();
// await vi.waitFor(() => screen.getByRole('textbox', {name: 'Avleverer'}));
//
// screen.getByRole('button', {name: 'Lagre'}).click();
// await vi.waitFor(() => screen.getByText('Noe gikk galt ved lagring', {exact: false}));
// });
2 changes: 1 addition & 1 deletion src/app/[id]/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default function Page({params}: { params: { id: string } }) {
type='button'
className='abort-button-style'
startContent={<FaArrowAltCircleLeft/>}
onPress={() => router.push(`/${params.id}?title=${titleString}`)}
onClick={() => router.push(`/${params.id}?title=${titleString}`)}
>
Tilbake til titteloversikt
</Button>
Expand Down
10 changes: 5 additions & 5 deletions src/app/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export default function Page({params}: { params: { id: string } }) {
endContent={<FaBoxOpen size={25}/>}
size={'md'}
className="edit-button-style ml-4 [&]:text-medium"
onPress={() => setShowBoxRegistrationModal(true)}>
onClick={() => setShowBoxRegistrationModal(true)}>
Ny eske
</Button>
</div>
Expand Down Expand Up @@ -355,7 +355,7 @@ export default function Page({params}: { params: { id: string } }) {
size="lg"
className="abort-button-style"
endContent={<ImCross size={25}/>}
onPress={() => {
onClick={() => {
resetForm();
setIsEditing(false);
}}
Expand Down Expand Up @@ -389,7 +389,7 @@ export default function Page({params}: { params: { id: string } }) {
size="lg"
className="edit-button-style mt-5"
endContent={<FaEdit size={25}/>}
onPress={() => setIsEditing(true)}
onClick={() => setIsEditing(true)}
>
Rediger
</Button>
Expand Down Expand Up @@ -452,7 +452,7 @@ export default function Page({params}: { params: { id: string } }) {
size={'lg'}
startContent={<FaArrowAltCircleLeft/>}
className="abort-button-style"
onPress={() => router.push('/')}
onClick={() => router.push('/')}
>
Tilbake
</Button>
Expand All @@ -461,7 +461,7 @@ export default function Page({params}: { params: { id: string } }) {
size={'lg'}
className="edit-button-style"
endContent={<FaEdit/>}
onPress={() => router.push(`/${params.id}/create?title=${titleString}`)}
onClick={() => router.push(`/${params.id}/create?title=${titleString}`)}
>
Legg til informasjon
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/components/BoxRegistrationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const BoxRegistrationModal: FC<BoxRegistrationModalProps> = (props: BoxRegistrat
startContent={<FaArrowAltCircleLeft/>}
size={'lg'}
className="abort-button-style mt-4"
onPress={() => props.closeModal()}>
onClick={() => props.closeModal()}>
Avbryt
</Button>
</div>
Expand All @@ -116,7 +116,7 @@ const BoxRegistrationModal: FC<BoxRegistrationModalProps> = (props: BoxRegistrat
showInfo.sameTitle ? (
<>
Esken er allerede registrert på denne tittelen ({props.titleName}). Ønsker du å laste inn den eksisterende esken?<br/>
<Button className="edit-button-style" onPress={() => {
<Button className="edit-button-style" onClick={() => {
void updateActiveBoxForTitle(props.titleId, existingBox!.id);
props.updateBoxInfo(existingBox!);
props.closeModal();
Expand Down
4 changes: 2 additions & 2 deletions src/components/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const ConfirmationModal: FC<ConfirmationModalProps> = ({
type='button'
size='lg'
className='abort-button-style mt-5'
onPress={() => handleExit()}
onClick={() => handleExit()}
>
Avbryt
</Button>
Expand All @@ -80,7 +80,7 @@ const ConfirmationModal: FC<ConfirmationModalProps> = ({
size='lg'
className='save-button-style mt-5'
disabled={isLoading}
onPress={() => {
onClick={() => {
handleConfirm();
}}
endContent={isLoading ? <Spinner size={'sm'}/> : undefined}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ContactInformationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const ContactInformationForm: FC<ContactInformationProps> = ({values, handleChan
variant="light"
color="primary"
className='text-md'
onPress={() => handleAdd(values, 'phone')}
onClick={() => handleAdd(values, 'phone')}
>
+ Legg til telefon
</Button>
Expand Down Expand Up @@ -119,7 +119,7 @@ const ContactInformationForm: FC<ContactInformationProps> = ({values, handleChan
variant="light"
color="primary"
className="text-md"
onPress={() => handleAdd(values, 'email')}
onClick={() => handleAdd(values, 'email')}
>
+ Legg til e-post
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ErrorModal: FC<ErrorModalProps> = ({
type='button'
size='lg'
className='abort-button-style mt-5'
onPress={() => handleExit()}
onClick={() => handleExit()}
>
Lukk
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function Header() {
<Link
color="foreground"
className="font-bold text-2xl hover:cursor-pointer"
onPress={() => router.push('/')}
onClick={() => router.push('/')}
>
<Image className="mr-2" src="/hugin/hugin.svg" alt="Hugin logo" width={45} height={45}/>
Hugin
Expand Down
2 changes: 1 addition & 1 deletion src/components/InfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const InfoModal: FC<InfoModalProps> = ({
type='button'
size='lg'
className='abort-button-style mt-5'
onPress={() => handleExit()}
onClick={() => handleExit()}
>
Lukk
</Button>
Expand Down
10 changes: 5 additions & 5 deletions src/components/IssueList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default function IssueList(props: {title: title; box: box}) {
type="button"
className="edit-button-style"
disabled={isSubmitting}
onPress={() => {
onClick={() => {
insert(0, proposeNewIssue(values.issues));
}}
>
Expand Down Expand Up @@ -306,13 +306,13 @@ export default function IssueList(props: {title: title; box: box}) {
<Button isIconOnly
className='save-button-style mr-1 [&]:text-medium [&]:bg-green-400'
type='button'
onPress={() => updateIssue(issue)}>
onClick={() => updateIssue(issue)}>
<FaSave/>
</Button>
<Button isIconOnly
className='abort-button-style mr-1'
type='button'
onPress={() => stopEditingIssue()}>
onClick={() => stopEditingIssue()}>
<ImCross/>
</Button>
</>
Expand All @@ -323,7 +323,7 @@ export default function IssueList(props: {title: title; box: box}) {
className={isEditingIssue() ? 'opacity-25 mr-0.5' : 'edit-button-style [&]:text-medium mr-0.5'}
type='button'
disabled={isEditingIssue()}
onPress={() => startEditingIssue(index)}
onClick={() => startEditingIssue(index)}
>
<FiEdit/>
</Button>
Expand All @@ -333,7 +333,7 @@ export default function IssueList(props: {title: title; box: box}) {
<Button isIconOnly
type="button"
className='delete-button-style'
onPress={() => {
onClick={() => {
if (!newspaperIsSaved(index, values.issues.length)) {
remove(index);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/components/LogoutButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const LogoutButton = () => {
<Button
className="edit-button-style"
endContent={<FaSignOutAlt size={25} />}
onPress={logout}
onClick={logout}
>
Logg ut
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SuccessModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const SuccessModal: FC<SuccessModalProps> = ({
type='button'
size='lg'
className="abort-button-style mt-5"
onPress={() => {buttonOnClick && buttonOnClick();}}
onClick={() => {buttonOnClick && buttonOnClick();}}
>
{buttonText}
</Button>
Expand Down

0 comments on commit 12f171c

Please sign in to comment.