Skip to content

Commit

Permalink
test: rests for dashboard footer; fixing issue with scheduled and arc…
Browse files Browse the repository at this point in the history
…hived release footer CTA
  • Loading branch information
jordanl17 committed Jan 9, 2025
1 parent 99f5d38 commit 94d6a32
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export function ReleaseDashboardFooter(props: {
const {documents, release, events} = props

const releaseActionButton = useMemo(() => {
if (release.state === 'archived') return null

if (release.metadata.releaseType === 'scheduled') {
return isReleaseScheduledOrScheduling(release) ? (
<ReleaseUnscheduleButton
Expand Down Expand Up @@ -64,7 +66,7 @@ export function ReleaseDashboardFooter(props: {
<ReleaseStatusItems events={events} release={release} />
</Flex>

<Flex flex="none" gap={1}>
<Flex flex="none" gap={1} data-testid="release-dashboard-footer-actions">
{releaseActionButton}
<ReleaseMenuButton release={release} ignoreCTA />
</Flex>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import {render, screen, waitFor} from '@testing-library/react'
import {describe, expect, test} from 'vitest'

import {createTestProvider} from '../../../../../../test/testUtils/TestProvider'
import {
activeASAPRelease,
activeScheduledRelease,
archivedScheduledRelease,
publishedASAPRelease,
scheduledRelease,
} from '../../../__fixtures__/release.fixture'
import {releasesUsEnglishLocaleBundle} from '../../../i18n'
import {ReleaseDashboardFooter} from '../ReleaseDashboardFooter'

const renderTest = async (props?: Partial<React.ComponentProps<typeof ReleaseDashboardFooter>>) => {
const wrapper = await createTestProvider({
resources: [releasesUsEnglishLocaleBundle],
})

const rendered = render(
<ReleaseDashboardFooter
release={activeASAPRelease}
events={[]}
documents={[]}
{...(props || {})}
/>,
{
wrapper,
},
)

await waitFor(() => {
expect(screen.queryByTestId('loading-block')).not.toBeInTheDocument()
})

return rendered
}

describe('ReleaseDashboardFooter', () => {
describe('for an active asap release', () => {
test('shows publish all button', async () => {
await renderTest()

expect(screen.getByTestId('publish-all-button')).toBeInTheDocument()
})

describe('for an active scheduled release', () => {
test('shows unschedule button', async () => {
await renderTest({release: activeScheduledRelease})

expect(screen.getByText('Schedule for publishing...')).toBeInTheDocument()
})
})
})

describe('for a published release', () => {
test('shows revert button', async () => {
await renderTest({release: publishedASAPRelease})

expect(screen.getByText('Revert release')).toBeInTheDocument()
})
})

describe('for a scheduled release', () => {
test('shows unschedule button', async () => {
await renderTest({release: scheduledRelease})

expect(screen.getByText('Unschedule for publishing')).toBeInTheDocument()
})
})

describe('for an archived release', () => {
test('shows the unarchive button', async () => {
await renderTest({release: archivedScheduledRelease})

expect(screen.getByTestId('release-dashboard-footer-actions').children.length).toEqual(1)
})
})
})

0 comments on commit 94d6a32

Please sign in to comment.