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

BACKLOG-21267: Display popup only in Page Composer view #922

Merged
merged 3 commits into from
Aug 4, 2023
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 @@ -7,6 +7,7 @@ import {GetContentPath} from './ContentPath.gql-queries';
import ContentPath from './ContentPath';
import {ContentPathDialog} from './ContentPathDialog';
import PropTypes from 'prop-types';
import JContentConstants from '~/JContent/JContent.constants';

function findLastIndex(array, callback) {
let lastIndex = -1;
Expand Down Expand Up @@ -43,14 +44,14 @@ const ContentPathContainer = ({setPathAction, selector}) => {
const dispatch = useDispatch();
const [currentItem, setCurrentItem] = useState(null);

const {mode, language, path} = useSelector(selector, shallowEqual);
const {mode, language, path, viewMode} = useSelector(selector, shallowEqual);

const {data, error} = useQuery(GetContentPath, {
variables: {path, language}
});

const handleNavigation = item => {
if (item.primaryNodeType?.name === 'jnt:contentList') {
if (item.primaryNodeType?.name === 'jnt:contentList' && mode === JContentConstants.mode.PAGES && viewMode === JContentConstants.tableView.viewMode.PAGE_COMPOSER) {
setCurrentItem(item);
} else {
dispatch(setPathAction(mode, item.path));
Expand Down Expand Up @@ -88,6 +89,7 @@ ContentPathContainer.propTypes = {
ContentPathContainer.defaultProps = {
selector: state => ({
mode: state.jcontent.mode,
viewMode: state.jcontent.tableView.viewMode,
path: state.jcontent.path,
language: state.language
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ describe('ContentPathContainer', () => {
useSelector.mockImplementation(callback => callback({
language: 'fr',
jcontent: {
path: '/x/y/z'
path: '/x/y/z',
tableView: {
viewMode: 'bar'
}
}
}));

Expand Down Expand Up @@ -64,6 +67,14 @@ describe('ContentPathContainer', () => {
}
}));

useSelector.mockImplementation(callback => callback({
jcontent: {
tableView: {
viewMode: 'bar'
}
}
}));

const wrapper = shallow(<ContentPathContainer/>).find('ContentPath');
expect(wrapper.type()).toBe(ContentPath);
expect(wrapper.prop('items')).toEqual(ancestors);
Expand All @@ -77,7 +88,10 @@ describe('ContentPathContainer', () => {

useSelector.mockImplementation(callback => callback({
jcontent: {
mode: 'foo'
mode: 'foo',
tableView: {
viewMode: 'bar'
}
}
}));

Expand Down
18 changes: 15 additions & 3 deletions tests/cypress/e2e/jcontent/breadcrumbs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,35 @@ describe('Breadcrumb navigation test', () => {
cy.loginAndStoreSession();
});

it('Handles area and parent page navigation correctly', () => {
let jcontent = JContent.visit('digitall', 'en', 'pages/home/newsroom/news-entry/article/all-organic-foods-network-gains');
it('Display popup when navigating to list and render list view when selected', () => {
const jcontent = JContent.visit('digitall', 'en', 'pages/home/newsroom/news-entry/article/all-organic-foods-network-gains');
jcontent.switchToPageComposer();
Breadcrumb.findByContent('article').click();
cy.get('button[data-cm-role="breadcrumb-view-list"]').should('be.visible').click();
cy.get('.moonstone-chip').find('span').contains('Content List').should('be.visible');
cy.get('h1').contains('article');
});

jcontent = JContent.visit('digitall', 'en', 'pages/home/newsroom/news-entry/article/all-organic-foods-network-gains');
it('Display popup when navigating to list and render parent page when selected', () => {
const jcontent = JContent.visit('digitall', 'en', 'pages/home/newsroom/news-entry/article/all-organic-foods-network-gains');
jcontent.switchToPageComposer();
Breadcrumb.findByContent('article').click();
cy.get('button[data-cm-role="breadcrumb-view-parent"]').should('be.visible').click();
cy.get('.moonstone-chip').find('span').contains('Page').should('be.visible');
cy.get('h1').contains('News Entry');
});

it('Do not display popup when navigating to page', () => {
const jcontent = JContent.visit('digitall', 'en', 'pages/home/newsroom/news-entry');
jcontent.switchToPageComposer();
Breadcrumb.findByContent('Newsroom').click();
cy.get('.moonstone-chip').find('span').contains('Page').should('be.visible');
cy.get('h1').contains('Newsroom');
});

it('Do not display popup when navigating to list in list view', () => {
JContent.visit('digitall', 'en', 'pages/home/investors/events/Events/ceos-of-the-digital-roundtable/relatedPeople');
Breadcrumb.findByContent('CEOs of The Digital Roundtable').click();
cy.get('.moonstone-chip').find('span').contains('Event').should('be.visible');
});
});
Loading