Skip to content

Commit

Permalink
Test for images and RichText (#103)
Browse files Browse the repository at this point in the history
* Add test for images

* Add test for richtext
  • Loading branch information
benjick authored Feb 19, 2020
1 parent d0408d0 commit 590dc33
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
1 change: 1 addition & 0 deletions cypress/integration/Home.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ context('CI', () => {
it('can render blok', () => {
cy.visit('ci')
cy.contains('ci=working')
cy.contains('I am testing this')
})
})

Expand Down
13 changes: 13 additions & 0 deletions cypress/integration/Images.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference types="Cypress" />

context('Images', () => {
it('can render images', () => {
cy.visit('images')
cy.get('[data-testid="storyblok-page"]').find('img').should('have.length', 3)
cy.get('[data-testid="storyblok-page"]')
.find('img')
.first()
.should('have.attr', 'src')
.should('include', 'https://img2.storyblok.com')
})
})
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"license": "MIT",
"scripts": {
"bootstrap": "lerna bootstrap --no-ci",
"test:ci": "yarn test:ci:start; yarn test:ci:test",
"test:ci:start": "docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.test.yml up -d",
"test:ci:test": "docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.test.yml up --abort-on-container-exit --exit-code-from cypress",
"test": "cypress open",
"cypress": "cypress open",
"pree2e": "wait-on http://localhost:3000/ci",
"e2e": " cypress run",
"lint": "eslint --ext .js,.vue,.ts .",
Expand Down
2 changes: 1 addition & 1 deletion packages/vsf-storyblok-module/components/Page.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div data-testid="storyblok-page">
<sb-render v-for="child in item.body" :item="child" :key="child.uuid" />
</div>
</template>
Expand Down
11 changes: 1 addition & 10 deletions theme/components/storyblok/Image.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="image" :style="{ backgroundImage: `url(${item.url})` }" />
<sb-img :src="item.image" :width="1200" :lazy="true" />
</template>

<script>
Expand All @@ -9,12 +9,3 @@ export default {
extends: Blok
}
</script>

<style lang="scss" scoped>
.image {
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 500px;
}
</style>
13 changes: 13 additions & 0 deletions theme/components/storyblok/RichText.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<div>
<sb-rich-text v-if="item.text" :text="item.text" />
</div>
</template>

<script>
import { Blok } from 'src/modules/vsf-storyblok-module/components'
export default {
name: 'RichTextBlok',
extends: Blok
}
</script>
3 changes: 2 additions & 1 deletion theme/components/storyblok/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { add } from 'src/modules/vsf-storyblok-module/components'

add('hero', () => import('./Hero.vue'))
add('demoImage', () => import('./Image.vue'))
add('Image', () => import('./Image.vue'))
add('RichText', () => import('./RichText.vue'))
add('ciLink', () => import('./Link.vue'))
// Overwrite an existing component
// add('tile', () => import('./Tile.vue'), { force: true })

0 comments on commit 590dc33

Please sign in to comment.