Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DISPLAY_SELF_HOSTED_EXPIRATION_BANNER probably #3695

Merged
merged 6 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const defaultConfig = {
GH_APP: DEFAULT_GH_APP,
GH_APP_AI: 'codecov-ai',
SUNBURST_ENABLED: true,
DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: true,
}

export function removeReactAppPrefix(obj) {
Expand All @@ -38,6 +39,10 @@ export function removeReactAppPrefix(obj) {
keys['SUNBURST_ENABLED'] = keys['SUNBURST_ENABLED'].toLowerCase() === 'true'
}

if ('DISPLAY_SELF_HOSTED_EXPIRATION_BANNER' in keys) {
keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'] = keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'].toLowerCase() === 'true'
}

if ('SENTRY_TRACING_SAMPLE_RATE' in keys) {
keys['SENTRY_TRACING_SAMPLE_RATE'] = parseFloat(
keys['SENTRY_TRACING_SAMPLE_RATE']
Expand Down
8 changes: 8 additions & 0 deletions src/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ describe('config', () => {
})
})

describe('sets DISPLAY_SELF_HOSTED_EXPIRATION_BANNER to boolean', () => {
it('sets to true', () => {
const obj = { DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: 'true' }

expect(removeReactAppPrefix(obj)).toEqual({ DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: true })
})
})

describe('sets IS_DEDICATED_NAMESPACE to boolean', () => {
it('sets to true', () => {
const obj = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@
expect(resolveIssueButton).not.toBeInTheDocument()
})

it('does not render the banner when disabled', async () => {
config.IS_SELF_HOSTED = true
config.IS_DEDICATED_NAMESPACE = true
config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER = false
setup({
seatsUsed: 5,
seatsLimit: 10,
expirationDate: null,
})
render(<SelfHostedLicenseExpiration />, { wrapper: wrapper(['']) })

const resolveIssueButton = screen.queryByText(/Resolve issue/)
expect(resolveIssueButton).not.toBeInTheDocument()
})

it('does not render the banner when there are no seats used', async () => {
config.IS_SELF_HOSTED = true
config.IS_DEDICATED_NAMESPACE = true
Expand Down Expand Up @@ -226,7 +241,7 @@
)

const resolveIssueButton = screen.queryByText(/Resolve issue/)
expect(resolveIssueButton).not.toBeInTheDocument()

Check failure on line 244 in src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx

View workflow job for this annotation

GitHub Actions / Test Runner #7 - Vitest

src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx > SelfHostedLicenseExpiration > self hosted and ECDN with correct params > does not render the banner when there is not a seat limit or when the license has not expired/will expire within 30 days

Error: expect(element).not.toBeInTheDocument() expected document not to contain element, found <button class=" flex items-center gap-1 rounded py-1 px-4 transition-colors duration-150 motion-reduce:transition-none focus:outline-none focus:ring disabled:cursor-not-allowed disabled:text-ds-gray-quaternary disabled:border-ds-gray-tertiary disabled:bg-ds-gray-primary justify-center font-semibold text-white bg-ds-blue-darker dark:bg-ds-blue-nonary border-ds-blue-quinary border-solid border shadow hover:bg-ds-blue-quinary " data-cy="license-expiration" data-marketing="license-expiration" data-testid="license-expiration" > Resolve issue </button> instead ❯ src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx:244:38
})

describe('when license is expired and seats limit is reached', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const SelfHostedLicenseExpiration = () => {
const shouldDisplayBanner =
isSeatsLimitReached || isLicenseExpired || isLicenseExpiringWithin30Days

if (!shouldDisplayBanner) {
if (!shouldDisplayBanner && config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER) {
return null
}

Expand Down
Loading