Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions src/pages/AccountSettings/tabs/Admin/DeletionCard/DeletionCard.jsx

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { render, screen } from '@testing-library/react'
import { MemoryRouter, Route } from 'react-router-dom'

import DeletionCard from './DeletionCard'

const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => (
<MemoryRouter initialEntries={['/account/gh/test-user']}>
<Route path="/account/:provider/:owner">{children}</Route>
</MemoryRouter>
)

describe('DeletionCard', () => {
it('renders header', () => {
render(<DeletionCard isPersonalSettings={true} />, { wrapper })

const header = screen.getByRole('heading', { name: 'Delete account' })
expect(header).toBeInTheDocument()
})

describe('when isPersonalSettings is true', () => {
it('renders account deletion message', () => {
render(<DeletionCard isPersonalSettings={true} />, { wrapper })

const message = screen.getByText(
/Erase all my personal content and projects./
)
expect(message).toBeInTheDocument()
})
})

describe('when isPersonalSettings is false', () => {
it('renders organization deletion message', () => {
render(<DeletionCard isPersonalSettings={false} />, { wrapper })

const message = screen.getByText(
/Erase all my organization content and projects./
)
expect(message).toBeInTheDocument()
})
})
})
45 changes: 45 additions & 0 deletions src/pages/AccountSettings/tabs/Admin/DeletionCard/DeletionCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Card from 'old_ui/Card'
import A from 'ui/A'

interface EraseSectionProps {
isPersonalSettings: boolean
}

function EraseSection({ isPersonalSettings }: EraseSectionProps) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between this and the other DeletionCard component in the profile tab? Do we want to update that too?

Copy link
Contributor Author

@nicholas-codecov nicholas-codecov May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrmrmrm profile tab is self hosted only or DEC, let me go ask in the ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They wanted it on both

if (isPersonalSettings) {
return (
<p>
Erase all my personal content and projects.{' '}
<A to={{ pageName: 'support' }} hook="contact-support-link" isExternal>
Contact support
</A>
</p>
)
}

return (
<p>
Erase all my organization content and projects.{' '}
<A to={{ pageName: 'support' }} hook="contact-support-link" isExternal>
Contact support
</A>
</p>
)
}

interface DeletionCardProps {
isPersonalSettings: boolean
}

function DeletionCard({ isPersonalSettings }: DeletionCardProps) {
return (
<div className="flex flex-col gap-4">
<h2 className="text-lg font-semibold">Delete account</h2>
<Card>
<EraseSection isPersonalSettings={isPersonalSettings} />
</Card>
</div>
)
}

export default DeletionCard
Loading