Skip to content

Commit

Permalink
Add Cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Feb 22, 2024
1 parent b23bd9a commit 2ad12dc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/coresandbox/src/components/Slots/SlotTest.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const SlotComponentTest = () => {
return (
<div style={{ margin: '0 auto 20px auto !important', width: '1127px' }}>
<div style={{ margin: '0 auto 20px auto', width: '1127px' }}>
<h2>This is a test slot component</h2>
<p>It should appear above the Content</p>
</div>
Expand Down
43 changes: 43 additions & 0 deletions packages/volto/cypress/tests/coresandbox/slots.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
context('Slots', () => {
describe('Block Default View / Edit', () => {
beforeEach(() => {
cy.intercept('GET', `/**/*?expand*`).as('content');
cy.intercept('GET', '/**/Document').as('schema');
// given a logged in editor and a page in edit mode
cy.autologin();
cy.createContent({
contentType: 'Document',
contentId: 'document',
contentTitle: 'Test document',
});
cy.createContent({
contentType: 'Document',
contentId: 'hello',
contentTitle: 'Test document Hello',
});

cy.visit('/');
cy.wait('@content');
});

it('[ContentTypeCondition(["Document"]), RouteCondition("/hello")] only renders when the predicates are true', function () {
cy.get('body').should(
'not.include.text',
'This is a test slot component',
);

cy.navigate('/document');
cy.wait('@content');

cy.get('body').should(
'not.include.text',
'This is a test slot component',
);

cy.navigate('/hello');
cy.wait('@content');

cy.get('body').should('include.text', 'This is a test slot component');
});
});
});

0 comments on commit 2ad12dc

Please sign in to comment.