fix(editor): Hide version control main menu component if no feature flag (#6419)

* fix(editor): Hide version control main menu component if no feature flag

* fix(editor): Update unit tes

* test(editor): Test for feature flag
This commit is contained in:
Csaba Tuncsik 2023-06-13 17:09:17 +02:00 committed by GitHub
parent d041602754
commit 75c0ab03f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -25,7 +25,7 @@ const tooltipOpenDelay = ref(300);
const currentBranch = computed(() => { const currentBranch = computed(() => {
return versionControlStore.preferences.branchName; return versionControlStore.preferences.branchName;
}); });
const featureEnabled = computed(() => window.localStorage.getItem('version-control'));
const setupButtonTooltipPlacement = computed(() => (props.isCollapsed ? 'right' : 'top')); const setupButtonTooltipPlacement = computed(() => (props.isCollapsed ? 'right' : 'top'));
async function pushWorkfolder() { async function pushWorkfolder() {
@ -80,6 +80,7 @@ const goToVersionControlSetup = async () => {
<template> <template>
<div <div
v-if="featureEnabled"
:class="{ :class="{
[$style.sync]: true, [$style.sync]: true,
[$style.collapsed]: isCollapsed, [$style.collapsed]: isCollapsed,

View file

@ -28,7 +28,10 @@ const renderComponent = (renderOptions: Parameters<typeof render>[1] = {}) => {
}; };
describe('MainSidebarVersionControl', () => { describe('MainSidebarVersionControl', () => {
const getItemSpy = vi.spyOn(Storage.prototype, 'getItem');
beforeEach(() => { beforeEach(() => {
getItemSpy.mockReturnValue('true');
pinia = createTestingPinia({ pinia = createTestingPinia({
initialState: { initialState: {
[STORES.SETTINGS]: { [STORES.SETTINGS]: {
@ -41,6 +44,12 @@ describe('MainSidebarVersionControl', () => {
usersStore = useUsersStore(); usersStore = useUsersStore();
}); });
it('should render nothing', async () => {
getItemSpy.mockReturnValue(null);
const { container } = renderComponent({ props: { isCollapsed: false } });
expect(container).toBeEmptyDOMElement();
});
it('should render empty content', async () => { it('should render empty content', async () => {
const { getByTestId } = renderComponent({ props: { isCollapsed: false } }); const { getByTestId } = renderComponent({ props: { isCollapsed: false } });
expect(getByTestId('main-sidebar-version-control')).toBeInTheDocument(); expect(getByTestId('main-sidebar-version-control')).toBeInTheDocument();