Skip to content

Commit

Permalink
task/WP-65-DropdownViewFullPath-v9
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor Grafft authored and Taylor Grafft committed Oct 5, 2023
1 parent 41b0f80 commit 00f4c5c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
display: flex;
align-items: center;
gap: 1rem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ describe('DataFilesBreadcrumbs', () => {
systems: systemsFixture,
projects: projectsFixture,
});
const history = createMemoryHistory();
const { getByText, debug } = renderComponent(
const { getByText } = renderComponent(
<DataFilesBreadcrumbs
api="tapis"
scheme="private"
Expand All @@ -30,26 +29,17 @@ describe('DataFilesBreadcrumbs', () => {
createMemoryHistory()
);

expect(getByText(/My Data \(Frontera\)/)).toBeDefined();
expect(
getByText(/My Data \(Frontera\)/)
.closest('a')
.getAttribute('href')
).toEqual(
'/workbench/data/tapis/private/frontera.home.username/home/username/'
);
expect(getByText(/the/).closest('a').getAttribute('href')).toEqual(
'/workbench/data/tapis/private/frontera.home.username/home/username/path/to/the/'
);
expect(getByText(/files/).closest('a')).toBeNull();
// Check if the last part of the path is rendered as text
const filesText = getByText('files');
expect(filesText).toBeDefined();
expect(filesText.closest('a')).toBeNull();
});

it('renders correct breadcrumbs when in root of system', () => {
const store = mockStore({
systems: systemsFixture,
});
const history = createMemoryHistory();
const { getAllByText, debug } = renderComponent(
const { getByText } = renderComponent(
<DataFilesBreadcrumbs
api="tapis"
scheme="private"
Expand All @@ -61,7 +51,8 @@ describe('DataFilesBreadcrumbs', () => {
createMemoryHistory()
);

expect(getAllByText('Frontera')).toBeDefined();
// Check if the system name is rendered as text when in the root of the system
expect(getByText('Frontera')).toBeDefined();
});

it('render breadcrumbs for projects', () => {
Expand All @@ -70,8 +61,7 @@ describe('DataFilesBreadcrumbs', () => {
projects: projectsFixture,
files: filesFixture,
});
const history = createMemoryHistory();
const { getByText, debug } = renderComponent(
const { getByText } = renderComponent(
<DataFilesBreadcrumbs
api="tapis"
scheme="projects"
Expand All @@ -83,12 +73,10 @@ describe('DataFilesBreadcrumbs', () => {
createMemoryHistory()
);

expect(getByText(/Shared Workspaces/)).toBeDefined();
expect(
getByText(/Shared Workspaces/)
.closest('a')
.getAttribute('href')
).toEqual('/workbench/data/tapis/projects/');
// Check if the last part of the path is rendered as text for projects
const filesText = getByText('files');
expect(filesText).toBeDefined();
expect(filesText.closest('a')).toBeNull();
});

it('renders "View Full Path" button and is clickable', () => {
Expand Down Expand Up @@ -133,32 +121,6 @@ describe('DataFilesBreadcrumbs', () => {
expect(button.hasAttribute('disabled')).toBe(false);
});

it('renders "Go to ..." dropdown and can be toggled', () => {
const store = mockStore({
systems: systemsFixture,
});
const { getByText } = renderComponent(
<DataFilesBreadcrumbs
api="tapis"
scheme="private"
system="frontera.home.username"
path="/path/to/files"
section="FilesListing"
/>,
store,
createMemoryHistory()
);

const dropdownToggle = getByText('Go to ...');
expect(dropdownToggle).toBeDefined();

// Toggle dropdown
dropdownToggle.click();

// Now, dropdown content should be visible
expect(getByText('Root')).toBeDefined();
});

it('dispatches action to open full path modal on button click', () => {
const store = mockStore({
systems: systemsFixture,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { fireEvent } from '@testing-library/react';
import configureMockStore from 'redux-mock-store';
import renderComponent from 'utils/testing';
import systemsFixture from '../fixtures/DataFiles.systems.fixture';
import BreadcrumbsDropdown from './DataFilesDropdown';

const mockStore = configureMockStore();

describe('BreadcrumbsDropdown', () => {
it('renders "Go to ..." dropdown and can be toggled', () => {
const store = mockStore({
systems: systemsFixture,
});

const { getByText } = renderComponent(
<BreadcrumbsDropdown
api="tapis"
scheme="private"
system="frontera.home.username"
path="/path/to/files"
/>,
store
);

const dropdownToggle = getByText('Go to ...');
expect(dropdownToggle).toBeDefined();

// Toggle dropdown
fireEvent.click(dropdownToggle);

// Now, dropdown content should be visible
expect(getByText('Root')).toBeDefined();
});
});

0 comments on commit 00f4c5c

Please sign in to comment.