From 72e53e4ea5942952238058f983abaa7f55b432a2 Mon Sep 17 00:00:00 2001 From: 1fanwang <1fannnw@gmail.com> Date: Thu, 13 Aug 2026 16:43:26 -0700 Subject: [PATCH] Compare the breadcrumb domain, not the project, when resolving an execution's domain getExecutionSpecProjectDomain tests breadcrumb.projectId against the execution's domain when deciding which domain to use. The project branch above it compares projectId to project, so the domain branch is comparing the wrong field. When a project happens to be named after a domain, the comparison succeeds and the breadcrumb resolves to whatever domain the user is currently browsing rather than the execution's own. Signed-off-by: 1fanwang <1fannnw@gmail.com> --- .../Breadcrumbs/async/utils/index.ts | 2 +- .../getExecutionSpecProjectDomain.test.ts | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 packages/oss-console/src/components/Breadcrumbs/async/utils/tests/getExecutionSpecProjectDomain.test.ts diff --git a/packages/oss-console/src/components/Breadcrumbs/async/utils/index.ts b/packages/oss-console/src/components/Breadcrumbs/async/utils/index.ts index ecfc8aee1..da5add6f0 100644 --- a/packages/oss-console/src/components/Breadcrumbs/async/utils/index.ts +++ b/packages/oss-console/src/components/Breadcrumbs/async/utils/index.ts @@ -67,7 +67,7 @@ export const getExecutionSpecProjectDomain = ( ? breadcrumb.projectId : executionSpecIdentifier.project; const domain = - breadcrumb.projectId === executionSpecIdentifier.domain + breadcrumb.domainId === executionSpecIdentifier.domain ? breadcrumb.domainId : executionSpecIdentifier.domain; diff --git a/packages/oss-console/src/components/Breadcrumbs/async/utils/tests/getExecutionSpecProjectDomain.test.ts b/packages/oss-console/src/components/Breadcrumbs/async/utils/tests/getExecutionSpecProjectDomain.test.ts new file mode 100644 index 000000000..c8d99f332 --- /dev/null +++ b/packages/oss-console/src/components/Breadcrumbs/async/utils/tests/getExecutionSpecProjectDomain.test.ts @@ -0,0 +1,33 @@ +import { getExecutionSpecProjectDomain } from '..'; +import { BreadcrumbFormControlInterface } from '../../../types'; +import { DomainIdentifierScope } from '../../../../../models/Common/types'; + +describe('getExecutionSpecProjectDomain', () => { + const breadcrumb = { projectId: 'production', domainId: 'staging' } as BreadcrumbFormControlInterface; + + it('returns the execution spec project and domain', () => { + const executionSpecIdentifier = { + project: 'my-project', + domain: 'development', + } as DomainIdentifierScope; + + expect(getExecutionSpecProjectDomain(executionSpecIdentifier, breadcrumb)).toEqual({ + project: 'my-project', + domain: 'development', + }); + }); + + it('returns the execution domain when a project is named after a domain', () => { + // breadcrumb.projectId ('production') matches the execution's domain, which is the case the + // domain branch compares against. + const executionSpecIdentifier = { + project: 'my-project', + domain: 'production', + } as DomainIdentifierScope; + + expect(getExecutionSpecProjectDomain(executionSpecIdentifier, breadcrumb)).toEqual({ + project: 'my-project', + domain: 'production', + }); + }); +});