go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/common/layouts/side_bar/sidebar.test.tsx (about)

     1  // Copyright 2023 The LUCI Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  import { render, screen } from '@testing-library/react';
    16  
    17  import { UiPage } from '@/common/constants/view';
    18  import { FakeContextProvider } from '@/testing_tools/fakes/fake_context_provider';
    19  
    20  import { Sidebar } from './sidebar';
    21  
    22  describe('Sidebar', () => {
    23    it('given an empty project, should display builders search', async () => {
    24      render(
    25        <FakeContextProvider
    26          pageMeta={{
    27            selectedPage: UiPage.BuilderSearch,
    28          }}
    29        >
    30          <Sidebar open={true} />
    31        </FakeContextProvider>,
    32      );
    33      await screen.findByRole('complementary');
    34      expect(screen.getByText('Builder search')).toBeInTheDocument();
    35      expect(screen.queryByText('Builders')).toBeNull();
    36    });
    37  
    38    it('should display a list of navigation items for a project', async () => {
    39      render(
    40        <FakeContextProvider
    41          pageMeta={{
    42            selectedPage: UiPage.Builders,
    43            project: 'chrome',
    44          }}
    45        >
    46          <Sidebar open={true} />
    47        </FakeContextProvider>,
    48      );
    49      await screen.findByRole('complementary');
    50      expect(screen.getByText('Builder search')).toBeInTheDocument();
    51      expect(screen.getByText('Builders')).toBeInTheDocument();
    52      expect(screen.getByText('Builder groups (Consoles)')).toBeInTheDocument();
    53      expect(screen.getByText('Test history')).toBeInTheDocument();
    54      expect(screen.getByText('Failure clusters')).toBeInTheDocument();
    55      expect(screen.getByText('Sheriff-o-Matic')).toBeInTheDocument();
    56      expect(screen.getByText('ChromiumDash')).toBeInTheDocument();
    57    });
    58  });