Skip to content

Commit

Permalink
fix: Display source control buttons properly (#6756)
Browse files Browse the repository at this point in the history
  • Loading branch information
krynble authored and OlegIvaniv committed Aug 3, 2023
1 parent a67e3d8 commit 5132de3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ const tooltipOpenDelay = ref(300);
const currentBranch = computed(() => {
return sourceControlStore.preferences.branchName;
});
const featureEnabled = computed(() => window.localStorage.getItem('source-control'));
// TODO: use this for release
// const featureEnabled = computed(
// () => sourceControlStore.preferences.connected && sourceControlStore.preferences.branchName,
// );
const isInstanceOwner = computed(() => usersStore.isInstanceOwner);
const setupButtonTooltipPlacement = computed(() => (props.isCollapsed ? 'right' : 'top'));
Expand Down Expand Up @@ -125,11 +120,11 @@ const goToSourceControlSetup = async () => {

<template>
<div
v-if="featureEnabled && isInstanceOwner"
v-if="sourceControlStore.isEnterpriseSourceControlEnabled && isInstanceOwner"
:class="{
[$style.sync]: true,
[$style.collapsed]: isCollapsed,
[$style.isConnected]: featureEnabled,
[$style.isConnected]: sourceControlStore.isEnterpriseSourceControlEnabled,
}"
:style="{ borderLeftColor: sourceControlStore.preferences.branchColor }"
data-test-id="main-sidebar-source-control"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ const renderComponent = (renderOptions: Parameters<typeof render>[1] = {}) => {
};

describe('MainSidebarSourceControl', () => {
const getItemSpy = vi.spyOn(Storage.prototype, 'getItem');

beforeEach(() => {
getItemSpy.mockReturnValue('true');
pinia = createTestingPinia({
initialState: {
[STORES.SETTINGS]: {
Expand All @@ -44,20 +41,21 @@ describe('MainSidebarSourceControl', () => {
});

usersStore = useUsersStore(pinia);

vi.spyOn(usersStore, 'isInstanceOwner', 'get').mockReturnValue(true);

sourceControlStore = useSourceControlStore();
vi.spyOn(sourceControlStore, 'isEnterpriseSourceControlEnabled', 'get').mockReturnValue(true);

uiStore = useUIStore();
});

it('should render nothing', async () => {
getItemSpy.mockReturnValue(null);
it('should render nothing when not instance owner', async () => {
vi.spyOn(usersStore, 'isInstanceOwner', 'get').mockReturnValue(false);
const { container } = renderComponent({ props: { isCollapsed: false } });
expect(container).toBeEmptyDOMElement();
});

it('should render empty content', async () => {
it('should render empty content when instance owner but not connected', async () => {
const { getByTestId } = renderComponent({ props: { isCollapsed: false } });
expect(getByTestId('main-sidebar-source-control')).toBeInTheDocument();
expect(getByTestId('main-sidebar-source-control')).toBeEmptyDOMElement();
Expand Down

0 comments on commit 5132de3

Please sign in to comment.