This repository has been archived by the owner on May 29, 2023. It is now read-only.
generated from eea/volto-frontend-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a667e03
commit a609d2b
Showing
15 changed files
with
231 additions
and
118 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const save = (path) => { | ||
cy.url().then(($url) => { | ||
if ($url.includes(path)) { | ||
//cy.get('.ui.button.save').click(); | ||
cy.get('#toolbar-save').click(); | ||
cy.url().should('eq', Cypress.config().baseUrl + path); | ||
} else { | ||
cy.log('Wrong path'); | ||
} | ||
}); | ||
}; | ||
|
||
export const cancel = (path) => { | ||
cy.url().then(($url) => { | ||
if ($url.includes(path)) { | ||
cy.get('.ui.button.cancel').click(); | ||
cy.url().should('eq', Cypress.config().baseUrl + path); | ||
} else { | ||
cy.log('Wrong path'); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { openSidebar, closeSidebar } from '../index'; | ||
|
||
export const changePageTitle = (title, delay = 10) => { | ||
cy.get('[contenteditable=true]').first().clear(); | ||
|
||
cy.get('[contenteditable=true]').first().type(title); | ||
|
||
cy.get('.documentFirstHeading').contains(title); | ||
|
||
cy.get('[contenteditable=true]').first().type('{enter}'); | ||
}; | ||
|
||
export const addBlock = (groupTitle, groupId, blockId) => { | ||
closeSidebar(); | ||
cy.getIfExists('#page-edit div.block-editor-text', () => { | ||
cy.get('#page-edit div.block-editor-text').last().click(); | ||
}); | ||
cy.getIfExists('#page-edit div.block-editor-slate', () => { | ||
cy.get('#page-edit div.block-editor-slate').last().click(); | ||
}); | ||
cy.get('.ui.basic.icon.button.block-add-button').last().click(); | ||
cy.getIfExists( | ||
`.content.active.${groupId}`, | ||
() => { | ||
cy.get(`.content.active.${groupId} .button.${blockId}`).click(); | ||
cy.get(`#page-edit div.block-editor-${blockId}`); | ||
openSidebar(); | ||
}, | ||
() => { | ||
cy.get('.blocks-chooser .title').contains(groupTitle).click(); | ||
cy.get(`.content.active.${groupId} .button.${blockId}`).click(); | ||
cy.get(`#page-edit div.block-editor-${blockId}`); | ||
openSidebar(); | ||
}, | ||
); | ||
}; | ||
|
||
export const selectBlock = (blockId) => { | ||
cy.get(`#page-edit div.block-editor-${blockId}`).click(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './actions'; | ||
export * from './blocks'; | ||
export * from './sidebar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export const openSidebar = () => { | ||
cy.get('#sidebar > div.sidebar-container').then(($sidebar) => { | ||
if ($sidebar.hasClass('collapsed')) { | ||
cy.get('#sidebar > div.sidebar-container > button.ui.button.trigger') | ||
.first() | ||
.click(); | ||
} | ||
}); | ||
}; | ||
|
||
export const closeSidebar = () => { | ||
cy.get('#sidebar > div.sidebar-container').then(($sidebar) => { | ||
if (!$sidebar.hasClass('collapsed')) { | ||
cy.get('#sidebar > div.sidebar-container > button.ui.button.trigger') | ||
.first() | ||
.click(); | ||
} | ||
}); | ||
}; | ||
|
||
export const openSidebarTab = (tab) => { | ||
openSidebar(); | ||
cy.get( | ||
'#sidebar > div.sidebar-container div.ui.pointing.secondary.attached.tabular.formtabs.menu > a.item', | ||
) | ||
.contains(tab) | ||
.then(($tab) => { | ||
if (!$tab.hasClass('active')) { | ||
cy.get( | ||
'#sidebar > div.sidebar-container div.ui.pointing.secondary.attached.tabular.formtabs.menu > a.item', | ||
) | ||
.contains(tab) | ||
.click(); | ||
} | ||
}); | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { setupBeforeEach, tearDownAfterEach } from '../support'; | ||
import { changePageTitle, addBlock, save } from '../helpers'; | ||
|
||
describe('Blocks Tests', () => { | ||
beforeEach(setupBeforeEach); | ||
afterEach(tearDownAfterEach); | ||
|
||
it('Add Block: Empty', () => { | ||
// Change page title | ||
changePageTitle('My Add-on Page'); | ||
// Add block | ||
addBlock('Common blocks', 'common_blocks', 'image'); | ||
cy.get('.block.inner.text').type('My Add-on Page'); | ||
|
||
// Save | ||
save('/cypress/my-page'); | ||
// then the page view should contain our changes | ||
cy.contains('My Add-on Page'); | ||
cy.get('.block.image'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.