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: 47 additions & 0 deletions src/renderer/src/components/App/OrgHead.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,51 @@ describe('OrgHead', () => {
// Should NOT display the organization name
cy.contains(orgName).should('not.exist');
});

it('should remove leading > and trailing < characters from organization names', () => {
const orgId = 'test-org-id';
// Test with name that starts with >
const orgNameWithPrefix = '>Test Organization';
const orgDataWithPrefix = createMockOrganization(orgId, orgNameWithPrefix);

mountOrgHead(createInitialState(), ['/team'], orgId, orgDataWithPrefix);

// The displayed name should not start with >
cy.get('h6, [variant="h6"]')
.should('be.visible')
.then(($el) => {
const displayedText = $el.text();
expect(displayedText.startsWith('>')).to.be.false;
expect(displayedText).to.equal('Test Organization');
});

// Test with name that ends with <
const orgNameWithSuffix = 'Test Organization<';
const orgDataWithSuffix = createMockOrganization(orgId, orgNameWithSuffix);

mountOrgHead(createInitialState(), ['/team'], orgId, orgDataWithSuffix);

// The displayed name should not end with <
cy.get('h6, [variant="h6"]')
.should('be.visible')
.then(($el) => {
const displayedText = $el.text();
expect(displayedText.endsWith('<')).to.be.false;
expect(displayedText).to.equal('Test Organization');
});
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

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

Missing blank line before the third test case (testing name with both prefix and suffix). Adding a blank line here would improve readability and maintain consistency with the structure of the previous two test cases within this test.

Suggested change
});
});

Copilot uses AI. Check for mistakes.
const orgNameWithBoth = '>Test Organization<';
const orgDataWithBoth = createMockOrganization(orgId, orgNameWithBoth);

mountOrgHead(createInitialState(), ['/team'], orgId, orgDataWithBoth);

// The displayed name should not start with > or end with <
cy.get('h6, [variant="h6"]')
.should('be.visible')
.then(($el) => {
const displayedText = $el.text();
expect(displayedText.startsWith('>')).to.be.false;
expect(displayedText.endsWith('<')).to.be.false;
expect(displayedText).to.equal('Test Organization');
});
});
});
14 changes: 13 additions & 1 deletion src/renderer/src/components/App/OrgHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ export const OrgHead = () => {
setOpenMember(true);
};

const cleanOrgName = (orgRec: OrganizationD | undefined) => {
let name = orgRec?.attributes.name;
if (!name) return '';
if (name.startsWith('>')) {
name = name.slice(1);
}
if (name.endsWith('<')) {
name = name.slice(0, -1);
}
return name;
Comment on lines +91 to +97
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

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

The cleanOrgName function only removes a single leading '>' or trailing '<' character. Consider what should happen if an organization name legitimately contains multiple consecutive '>' or '<' characters, or if these characters appear in the middle of the name. The current implementation would only remove one character from each end. If the goal is to remove all leading '>' and trailing '<' characters, consider using a loop or regular expressions. If only one character should be removed, document this behavior clearly in a comment.

Suggested change
if (name.startsWith('>')) {
name = name.slice(1);
}
if (name.endsWith('<')) {
name = name.slice(0, -1);
}
return name;
// Remove all leading '>' and all trailing '<' characters, but leave any in the middle
return name.replace(/^>+/, '').replace(/<+$/, '');

Copilot uses AI. Check for mistakes.
};

return (
<Stack direction="row">
<Typography
Expand All @@ -100,7 +112,7 @@ export const OrgHead = () => {
>
{isSwitchTeamsScreen
? API_CONFIG.productName
: orgRec?.attributes.name || API_CONFIG.productName}
: cleanOrgName(orgRec) || API_CONFIG.productName}
</Typography>
{isTeamScreen && (
<>
Expand Down