Skip to content

Commit

Permalink
fix: update fixed storyblok-js (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
edodusi authored Dec 27, 2024
1 parent 40a5d06 commit c1b4545
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 62 deletions.
52 changes: 13 additions & 39 deletions cypress/components/index.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('@storyblok/vue', () => {
beforeEach(() => {
cy.spy(window.console, 'log').as('log');
cy.spy(window.console, 'error').as('error');
delete window.storyblokRegisterEvent;
delete (window as any).storyblokRegisterEvent;
document.getElementById('storyblok-javascript-bridge')?.remove();
});

Expand Down Expand Up @@ -206,51 +206,28 @@ describe('@storyblok/vue', () => {
components: { Teaser, Grid, Page, Feature },
});

cy.get('[data-test=root]')
.children()
.find('h1')
.should('have.text', 'Headline 1');
cy.contains('h1', 'Headline 1', { timeout: 1000 });
});

it('Should render headline tags correctly', () => {
prepare({ use: [apiPlugin] }, RichText, {
components: { Teaser, Grid, Page, Feature },
});

cy.get('[data-test=root]')
.children()
.find('h1')
.should('have.text', 'Headline 1');
cy.get('[data-test=root]')
.children()
.find('h2')
.should('have.text', 'Headline 2');
cy.get('[data-test=root]')
.children()
.find('h3')
.should('have.text', 'Headline 3');
cy.get('[data-test=root]')
.children()
.find('h4')
.should('have.text', 'Headline 4');
cy.get('[data-test=root]')
.children()
.find('h5')
.should('have.text', 'Headline 5');
cy.get('[data-test=root]')
.children()
.find('h6')
.should('have.text', 'Headline 6');
cy.contains('h1', 'Headline 1', { timeout: 1000 });
cy.contains('h2', 'Headline 2', { timeout: 1000 });
cy.contains('h3', 'Headline 3', { timeout: 1000 });
cy.contains('h4', 'Headline 4', { timeout: 1000 });
cy.contains('h5', 'Headline 5', { timeout: 1000 });
cy.contains('h6', 'Headline 6', { timeout: 1000 });
});

it('Should render images correctly', () => {
prepare({ use: [apiPlugin] }, RichText, {
components: { Teaser, Grid, Page, Feature },
});

cy.get('[data-test=root]')
.children()
.find('img')
cy.get('img')
.should(
'have.attr',
'src',
Expand All @@ -263,9 +240,7 @@ describe('@storyblok/vue', () => {
components: { Teaser, Grid, Page, Feature },
});

cy.get('[data-test=root]')
.children()
.find('a')
cy.get('a')
.should('have.attr', 'href', 'https://storyblok.com/');
});

Expand All @@ -274,10 +249,9 @@ describe('@storyblok/vue', () => {
components: { IframeEmbed },
});

cy.get('[data-test=root]')
.children()
.find('iframe')
.should('have.attr', 'src', 'https://storyblok.com/');
cy.get('iframe')
.should('exist')
.and('have.attr', 'src', 'https://storyblok.com/');
});

it('should redirect internal links', () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/components/testing-components/Essential.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const blokProd = {
const storyblokApi = useStoryblokApi();
const apiExists = !!(storyblokApi && typeof storyblokApi.get === 'function');
// eslint-disable-next-line no-console
onMounted(() => useStoryblokBridge(12345, () => console.log('hola')));
</script>

Expand Down
21 changes: 11 additions & 10 deletions cypress/components/testing-components/RichTextChild.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
<script setup lang="ts">
import {
useStoryblok,
MarkTypes,
StoryblokRichText,
type StoryblokRichTextNode,
MarkTypes,
} from "@storyblok/vue";
import { type VNode, h } from "vue";
import { RouterLink } from "vue-router";
const story = await useStoryblok("vue/test-richtext", { version: "draft" });
useStoryblok,
} from '@storyblok/vue';
import { h, type VNode } from 'vue';
import { RouterLink } from 'vue-router';
const story = await useStoryblok('vue/test-richtext', { version: 'draft' });
const resolvers = {
[MarkTypes.LINK]: (node: StoryblokRichTextNode<VNode>) => {
return node.attrs?.linktype === "STORY"
return node.attrs?.linktype === 'STORY'
? h(
RouterLink,
{
to: node.attrs?.href,
target: node.attrs?.target,
},
node.text
node.text,
)
: h(
"a",
'a',
{
href: node.attrs?.href,
target: node.attrs?.target,
},
node.text
node.text,
);
},
};
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
// }
9 changes: 5 additions & 4 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable ts/no-namespace */
// ***********************************************************
// This example support/component.ts is processed and
// loaded automatically before your test files.
Expand All @@ -19,23 +20,23 @@
// Alternatively you can use CommonJS syntax:
// require('./commands')

import { mount } from "cypress/vue";
import { mount } from 'cypress/vue';

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
// eslint-disable-next-line no-unused-vars

namespace Cypress {
// eslint-disable-next-line no-unused-vars

interface Chainable {
mount: typeof mount;
}
}
}

Cypress.Commands.add("mount", mount);
Cypress.Commands.add('mount', mount);

// Example use:
// cy.mount(MyComponent)
2 changes: 1 addition & 1 deletion cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./commands";
import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { storyblokLintConfig } from '@storyblok/eslint-config';

export default storyblokLintConfig({
ignores: ['**/node_modules/**', 'cypress/', 'README.md'],
ignores: ['**/node_modules/**', 'README.md'],
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"vue": ">=3.4"
},
"dependencies": {
"@storyblok/js": "3.1.9"
"@storyblok/js": "3.2.1"
},
"devDependencies": {
"@commitlint/cli": "^19.6.1",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c1b4545

Please sign in to comment.