Feat: nested collections (#3716)
This commit is contained in:
@ -22,8 +22,10 @@ import {
|
||||
populateEntry,
|
||||
publishAndCreateNewEntryInEditor,
|
||||
publishAndDuplicateEntryInEditor,
|
||||
assertNotification,
|
||||
assertFieldValidationError,
|
||||
} from '../utils/steps';
|
||||
import { workflowStatus, editorStatus, publishTypes } from '../utils/constants';
|
||||
import { workflowStatus, editorStatus, publishTypes, notifications } from '../utils/constants';
|
||||
|
||||
const entry1 = {
|
||||
title: 'first title',
|
||||
@ -192,4 +194,123 @@ describe('Test Backend Editorial Workflow', () => {
|
||||
updateWorkflowStatusInEditor(editorStatus.ready);
|
||||
publishAndDuplicateEntryInEditor(entry1);
|
||||
});
|
||||
|
||||
const inSidebar = func => {
|
||||
cy.get('[class*=SidebarNavList]').within(func);
|
||||
};
|
||||
|
||||
const inGrid = func => {
|
||||
cy.get('[class*=CardsGrid]').within(func);
|
||||
};
|
||||
|
||||
it('can access nested collection items', () => {
|
||||
login();
|
||||
|
||||
inSidebar(() => cy.contains('a', 'Pages').click());
|
||||
inSidebar(() => cy.contains('a', 'Directory'));
|
||||
inGrid(() => cy.contains('a', 'Root Page'));
|
||||
inGrid(() => cy.contains('a', 'Directory'));
|
||||
|
||||
inSidebar(() => cy.contains('a', 'Directory').click());
|
||||
|
||||
inGrid(() => cy.contains('a', 'Sub Directory'));
|
||||
inGrid(() => cy.contains('a', 'Another Sub Directory'));
|
||||
|
||||
inSidebar(() => cy.contains('a', 'Sub Directory').click());
|
||||
inGrid(() => cy.contains('a', 'Nested Directory'));
|
||||
cy.url().should(
|
||||
'eq',
|
||||
'http://localhost:8080/#/collections/pages/filter/directory/sub-directory',
|
||||
);
|
||||
|
||||
inSidebar(() => cy.contains('a', 'Pages').click());
|
||||
inSidebar(() => cy.contains('a', 'Pages').click());
|
||||
|
||||
inGrid(() => cy.contains('a', 'Another Sub Directory').should('not.exist'));
|
||||
});
|
||||
|
||||
it('can navigate to nested entry', () => {
|
||||
login();
|
||||
|
||||
inSidebar(() => cy.contains('a', 'Pages').click());
|
||||
inSidebar(() => cy.contains('a', 'Directory').click());
|
||||
inGrid(() => cy.contains('a', 'Another Sub Directory').click());
|
||||
|
||||
cy.url().should(
|
||||
'eq',
|
||||
'http://localhost:8080/#/collections/pages/entries/directory/another-sub-directory/index',
|
||||
);
|
||||
});
|
||||
|
||||
it(`can create a new entry with custom path`, () => {
|
||||
login();
|
||||
|
||||
inSidebar(() => cy.contains('a', 'Pages').click());
|
||||
inSidebar(() => cy.contains('a', 'Directory').click());
|
||||
inSidebar(() => cy.contains('a', 'Sub Directory').click());
|
||||
cy.contains('a', 'New Page').click();
|
||||
|
||||
cy.get('[id^="path-field"]').should('have.value', 'directory/sub-directory');
|
||||
cy.get('[id^="path-field"]').type('/new-path');
|
||||
cy.get('[id^="title-field"]').type('New Path Title');
|
||||
cy.clock().then(clock => {
|
||||
clock.tick(150);
|
||||
});
|
||||
cy.contains('button', 'Save').click();
|
||||
assertNotification(notifications.saved);
|
||||
updateWorkflowStatusInEditor(editorStatus.ready);
|
||||
publishEntryInEditor(publishTypes.publishNow);
|
||||
exitEditor();
|
||||
|
||||
inGrid(() => cy.contains('a', 'New Path Title'));
|
||||
inSidebar(() => cy.contains('a', 'Directory').click());
|
||||
inSidebar(() => cy.contains('a', 'Directory').click());
|
||||
inGrid(() => cy.contains('a', 'New Path Title').should('not.exist'));
|
||||
});
|
||||
|
||||
it(`can't create an entry with an existing path`, () => {
|
||||
login();
|
||||
|
||||
inSidebar(() => cy.contains('a', 'Pages').click());
|
||||
inSidebar(() => cy.contains('a', 'Directory').click());
|
||||
inSidebar(() => cy.contains('a', 'Sub Directory').click());
|
||||
|
||||
cy.contains('a', 'New Page').click();
|
||||
cy.get('[id^="title-field"]').type('New Path Title');
|
||||
cy.clock().then(clock => {
|
||||
clock.tick(150);
|
||||
});
|
||||
cy.contains('button', 'Save').click();
|
||||
|
||||
assertFieldValidationError({
|
||||
message: `Path 'directory/sub-directory' already exists`,
|
||||
fieldLabel: 'Path',
|
||||
});
|
||||
});
|
||||
|
||||
it('can move an existing entry to a new path', () => {
|
||||
login();
|
||||
|
||||
inSidebar(() => cy.contains('a', 'Pages').click());
|
||||
inGrid(() => cy.contains('a', 'Directory').click());
|
||||
|
||||
cy.get('[id^="path-field"]').should('have.value', 'directory');
|
||||
cy.get('[id^="path-field"]').clear();
|
||||
cy.get('[id^="path-field"]').type('new-directory');
|
||||
cy.get('[id^="title-field"]').clear();
|
||||
cy.get('[id^="title-field"]').type('New Directory');
|
||||
cy.clock().then(clock => {
|
||||
clock.tick(150);
|
||||
});
|
||||
cy.contains('button', 'Save').click();
|
||||
assertNotification(notifications.saved);
|
||||
updateWorkflowStatusInEditor(editorStatus.ready);
|
||||
publishEntryInEditor(publishTypes.publishNow);
|
||||
exitEditor();
|
||||
|
||||
inSidebar(() => cy.contains('a', 'New Directory').click());
|
||||
|
||||
inGrid(() => cy.contains('a', 'Sub Directory'));
|
||||
inGrid(() => cy.contains('a', 'Another Sub Directory'));
|
||||
});
|
||||
});
|
||||
|
@ -1,3 +1,4 @@
|
||||
import '../utils/dismiss-local-backup';
|
||||
import {
|
||||
login,
|
||||
newPost,
|
||||
|
Reference in New Issue
Block a user