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

fix(uve): Hide workflow actions toolbar button when editing a variant #30726 #31001

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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
#personaSelector
data-testId="persona-selector" />

<dot-uve-workflow-actions />
@if ($toolbarProps().isDefaultVariant) {
<dot-uve-workflow-actions />
}

@if ($toolbarProps().unlockButton; as unlockButton) {
<p-button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe('EditEmaToolbarComponent', () => {
runningExperiment: null,
workflowActionsInode: pageAPIResponse?.page.inode,
unlockButton: null,
isDefaultVariant: true,
showInfoDisplay: shouldShowInfoDisplay,
deviceSelector: {
apiLink: `${params?.clientHost ?? 'http://localhost'}${pageAPI}`,
Expand Down Expand Up @@ -405,12 +406,10 @@ describe('EditEmaToolbarComponent', () => {
});
});
});

it('should have a dot-uve-workflow-actions component', () => {
const workflowActions = spectator.query(DotUveWorkflowActionsComponent);
expect(workflowActions).toBeTruthy();
});

describe('dot-ema-info-display', () => {
it('should be hidden', () => {
const infoDisplay = spectator.query(byTestId('info-display'));
Expand All @@ -426,7 +425,7 @@ describe('EditEmaToolbarComponent', () => {
});
});

xdescribe('constrains', () => {
describe('constrains', () => {
describe('dot-ema-info-display', () => {
beforeEach(() => {
spectator = createComponent({
Expand Down Expand Up @@ -466,6 +465,46 @@ describe('EditEmaToolbarComponent', () => {
expect(infoDisplay).toBeDefined();
});
});
describe('dot-uve-workflow-actions', () => {
beforeEach(() => {
spectator = createComponent({
providers: [
mockProvider(UVEStore, {
$toolbarProps: signal({
bookmarksUrl,
copyUrl: '',
apiUrl: '',
currentLanguage: pageAPIResponse?.viewAs.language,
urlContentMap: null,
runningExperiment: null,
workflowActionsInode: '',
unlockButton: null,
isDefaultVariant: false,
showInfoDisplay: true,
deviceSelector: {
apiLink: '',
hideSocialMedia: true
},
personaSelector: {
pageId: '',
value: DEFAULT_PERSONA
}
}),
setDevice: jest.fn(),
setSocialMedia: jest.fn(),
pageParams: signal(params)
})
]
});
store = spectator.inject(UVEStore);
messageService = spectator.inject(MessageService);
confirmationService = spectator.inject(ConfirmationService);
});
it('should not show when isDefaultVariant is false in the store', () => {
const workflowActions = spectator.query(DotUveWorkflowActionsComponent);
expect(workflowActions).toBeNull();
});
});
describe('experiments', () => {
const experiment = getRunningExperimentMock();

Expand Down Expand Up @@ -499,7 +538,6 @@ describe('EditEmaToolbarComponent', () => {
]
});
});

describe('dot-ema-running-experiment', () => {
it('should have attr', () => {
const experiments = spectator.query(DotEmaRunningExperimentComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export interface ToolbarProps {
bookmarksUrl: string;
copyUrl: string;
apiUrl: string;
isDefaultVariant: boolean;
showInfoDisplay: boolean;
currentLanguage: DotLanguage;
runningExperiment?: DotExperiment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ export function withEditorToolbar() {
inode: pageAPIResponse?.page.inode,
loading: store.status() === UVE_STATUS.LOADING
};
const isDefaultVariant = getIsDefaultVariant(pageAPIResponse?.viewAs.variantId);

const shouldShowInfoDisplay =
!getIsDefaultVariant(pageAPIResponse?.viewAs.variantId) ||
!isDefaultVariant ||
!store.canEditPage() ||
isPageLocked ||
!!store.device() ||
Expand All @@ -94,6 +95,7 @@ export function withEditorToolbar() {
runningExperiment: isExperimentRunning ? experiment : null,
workflowActionsInode: store.canEditPage() ? pageAPIResponse?.page.inode : null,
unlockButton: shouldShowUnlock ? unlockButton : null,
isDefaultVariant,
showInfoDisplay: shouldShowInfoDisplay,
deviceSelector: {
apiLink: `${clientHost}${pageAPI}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('withEditor', () => {
value: MOCK_RESPONSE_HEADLESS.viewAs.persona ?? DEFAULT_PERSONA
},
runningExperiment: null,
isDefaultVariant: true,
showInfoDisplay: false,
unlockButton: null,
urlContentMap: null,
Expand Down Expand Up @@ -331,6 +332,35 @@ describe('withEditor', () => {
expect(store.$toolbarProps().showInfoDisplay).toBe(false);
});
});

describe('isDefaultVariant', () => {
it('should have isDefaultVariant as true if the page variant is default', () => {
patchState(store, {
pageAPIResponse: {
...MOCK_RESPONSE_HEADLESS,
viewAs: {
...MOCK_RESPONSE_HEADLESS.viewAs,
variantId: DEFAULT_VARIANT_ID
}
}
});

expect(store.$toolbarProps().isDefaultVariant).toBe(true);
});
it('should have isDefaultVariant as false if the page is a variant different from default', () => {
patchState(store, {
pageAPIResponse: {
...MOCK_RESPONSE_HEADLESS,
viewAs: {
...MOCK_RESPONSE_HEADLESS.viewAs,
variantId: 'test'
}
}
});

expect(store.$toolbarProps().isDefaultVariant).toBe(false);
});
});
});

describe('$infoDisplayOptions', () => {
Expand Down