generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from eea/develop
Release
- Loading branch information
Showing
18 changed files
with
485 additions
and
96 deletions.
There are no files selected for viewing
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
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 was deleted.
Oops, something went wrong.
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,58 @@ | ||
import { slateBeforeEach, slateAfterEach } from '../support/e2e'; | ||
|
||
describe('Blocks Tests', () => { | ||
beforeEach(slateBeforeEach); | ||
afterEach(slateAfterEach); | ||
|
||
it('Add Block: Video link', () => { | ||
// Intercept cmshare request | ||
cy.intercept('GET', 'https://cmshare.eea.europa.eu//download').as( | ||
'cmshare', | ||
); | ||
|
||
// Change page title | ||
cy.clearSlateTitle(); | ||
cy.getSlateTitle().type('Volto NextCloud Video Demo'); | ||
cy.get('.documentFirstHeading').contains('Volto NextCloud Video Demo'); | ||
cy.getSlate().click(); | ||
|
||
// Add block | ||
cy.get('.ui.basic.icon.button.block-add-button').first().click(); | ||
cy.get(".blocks-chooser .ui.form .field.searchbox input[type='text']").type( | ||
'video (NextCloud)', | ||
); | ||
cy.get('.nextCloudVideo').click(); | ||
|
||
// Check if error message is not displayed | ||
cy.get('.ui.error.message').should('not.exist'); | ||
|
||
// Add youtube video link and check if it is valid | ||
cy.get('.block.video .toolbar-inner .ui.input').type( | ||
'https://www.youtube.com/', | ||
); | ||
cy.get('.block.video .toolbar-inner .ui.buttons .ui.basic.primary').click(); | ||
cy.get('.ui.error.message').should('exist'); | ||
|
||
// Delete the link and check if the error message is not displayed | ||
cy.get('.block.video .toolbar-inner .ui.buttons .ui.basic.cancel').click(); | ||
cy.get('.ui.error.message').should('not.exist'); | ||
|
||
// Add cmshare video link and check if it is valid | ||
cy.get('.block.video .toolbar-inner .ui.input').type( | ||
'https://cmshare.eea.europa.eu/', | ||
); | ||
cy.get('.block.video .toolbar-inner .ui.buttons .ui.basic.primary').click(); | ||
cy.get('.ui.error.message').should('not.exist'); | ||
|
||
// Wait for cmshare request | ||
cy.wait('@cmshare'); | ||
|
||
// Save | ||
cy.get('#toolbar-save').click(); | ||
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page'); | ||
|
||
// The page view should contain our changes | ||
cy.contains('Volto NextCloud Video Demo'); | ||
cy.get('.block.video'); | ||
}); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import Body from './Body'; | ||
import { isInternalURL } from '@plone/volto/helpers'; | ||
import { getFieldURL } from '@eeacms/volto-nextcloud-video-block/helpers'; | ||
|
||
jest.mock('@eeacms/volto-nextcloud-video-block/helpers', () => ({ | ||
getFieldURL: jest.fn(), | ||
})); | ||
|
||
jest.mock('@plone/volto/helpers', () => ({ | ||
isInternalURL: jest.fn(), | ||
flattenToAppURL: jest.fn(), | ||
withBlockExtensions: jest.fn((Component) => Component), | ||
})); | ||
|
||
jest.mock('./players', () => ({ | ||
nextCloud: jest.fn(() => <div>NextCloud Player</div>), | ||
})); | ||
|
||
describe('Body', () => { | ||
it('renders correctly', () => { | ||
const props = { | ||
data: { | ||
url: 'nextCloud', | ||
align: 'full', | ||
preview_image: '/path/to/image', | ||
}, | ||
}; | ||
|
||
const component = renderer.create(<Body {...props} />); | ||
const json = component.toJSON(); | ||
expect(json).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders the correct player based on the url', () => { | ||
const props = { | ||
data: { | ||
url: 'nextCloud', | ||
align: 'full', | ||
preview_image: '/path/to/image', | ||
}, | ||
}; | ||
|
||
isInternalURL.mockReturnValue(true); | ||
getFieldURL.mockReturnValue('/path/to/video'); | ||
|
||
const component = renderer.create(<Body {...props} />); | ||
expect(component.toJSON().props.className).toContain('video-inner'); | ||
}); | ||
|
||
it('renders the correct player based on the url', () => { | ||
const props = { | ||
data: { | ||
url: 'nextCloud', | ||
align: 'full', | ||
preview_image: '/path/to/image', | ||
}, | ||
}; | ||
|
||
isInternalURL.mockReturnValue(false); | ||
getFieldURL.mockReturnValue('nextCloud'); | ||
|
||
const component = renderer.create(<Body {...props} />); | ||
|
||
expect(component.toJSON().props.className).toContain('video-inner'); | ||
}); | ||
}); |
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.