Skip to content

feat(marketing): add ability to override brand #67426

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

Closed
wants to merge 1 commit into from

Conversation

stephenliang
Copy link
Member

This PR adds a header which allows UI tests to override the brand to allow the same "All the Things" code that is in the Code.org space to be used for CSForAll to eliminate the need to maintain multiple experiences and sync them together.

This PR adds a header which allows UI tests to override the brand to
allow the same "All the Things" code that is in the Code.org space to be
used for CSForAll to eliminate the need to maintain multiple experiences
and sync them together.
@stephenliang stephenliang requested a review from Copilot July 29, 2025 22:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the ability to override the brand selection through an HTTP header (x-brand-override) for UI testing purposes. This allows the same codebase to be used across different brand experiences (Code.org, CSForAll) without maintaining separate implementations.

  • Added support for brand override via HTTP header in middleware
  • Created new utility function to parse brand strings
  • Updated brand resolution logic to prioritize header override over hostname-based detection

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
frontend/apps/marketing/src/middleware/withBrand.ts Modified middleware to check for x-brand-override header and use it for brand selection
frontend/apps/marketing/src/config/brand.ts Added getBrandFromString function to parse brand values from string input

Comment on lines +77 to +86
switch (brandString) {
case Brand.CODE_DOT_ORG:
return Brand.CODE_DOT_ORG;
case Brand.HOUR_OF_CODE:
return Brand.HOUR_OF_CODE;
case Brand.CS_FOR_ALL:
return Brand.CS_FOR_ALL;
default:
return undefined;
}
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

The function should validate that the input string matches expected Brand enum values rather than using a switch statement with hardcoded strings. Consider using Object.values(Brand).includes(brandString as Brand) for more robust validation.

Suggested change
switch (brandString) {
case Brand.CODE_DOT_ORG:
return Brand.CODE_DOT_ORG;
case Brand.HOUR_OF_CODE:
return Brand.HOUR_OF_CODE;
case Brand.CS_FOR_ALL:
return Brand.CS_FOR_ALL;
default:
return undefined;
}
if (brandString && Object.values(Brand).includes(brandString as Brand)) {
return brandString as Brand;
}
return undefined;

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

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

The switch/case is more legible and provides the same behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant