-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: LDP-2575: Improve default fallback code and tests
- Loading branch information
Showing
7 changed files
with
49 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<div class="node"> | ||
<div class="node node--default"> | ||
<h2>Node: {{ title }}</h2> | ||
<div | ||
v-if="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
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,25 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { describe, it, expect } from 'vitest' | ||
import { setup, $fetch } from '@nuxt/test-utils' | ||
import DrupalCe from '../..' | ||
|
||
describe('Non-default custom element', async () => { | ||
await setup({ | ||
rootDir: fileURLToPath(new URL('../fixtures/debug', import.meta.url)), | ||
nuxtConfig: { | ||
modules: [ | ||
DrupalCe, | ||
], | ||
drupalCe: { | ||
drupalBaseUrl: 'http://127.0.0.1:3103', | ||
ceApiEndpoint: '/api', | ||
}, | ||
}, | ||
port: 3103, | ||
}) | ||
it('non-default custom element is rendered correctly', async () => { | ||
const html = await $fetch('/node/4') | ||
expect(html).toContain('<div class="node node-article-demo"') | ||
expect(html).toContain('Article demo') | ||
}) | ||
}) |
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,5 @@ | ||
<template> | ||
<div class="node node-article-demo"> | ||
<h2>Article demo</h2> | ||
</div> | ||
</template> |
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,8 @@ | ||
<template> | ||
<component :is="renderCustomElements(page.content)" /> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
const { fetchPage, renderCustomElements } = useDrupalCe() | ||
const page = await fetchPage(useRoute().path, { query: useRoute().query }) | ||
</script> |
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,2 @@ | ||
export default defineEventHandler(() => ({ title: 'Node 4', messages: [], breadcrumbs: [], metatags: { meta: [{ name: 'title', content: 'Node 4 | lupus decoupled' }, { name: 'description', content: 'This node is testing custom elements fallback. node-article-demo --> node--default.' }], link: [{ rel: 'canonical', href: 'https:\/\/8080-drunomics-lupusdecouple-fd0ilwlpax7.ws-eu84.gitpod.io\/node\/4' }, { rel: 'alternate', hreflang: 'de', href: 'https:\/\/8080-drunomics-lupusdecouple-fd0ilwlpax7.ws-eu84.gitpod.io\/de\/node\/4' }, { rel: 'alternate', hreflang: 'en', href: 'https:\/\/8080-drunomics-lupusdecouple-fd0ilwlpax7.ws-eu84.gitpod.io\/node\/4' }] }, content_format: 'json', content: { element: 'node-article-demo', type: 'page', uid: '1', title: 'Node 4', created: '1674823558', body: ['\u003Cp\u003EThis node is testing custom elements fallback. node-article-demo --> node--default.\u003C\/p\u003E'] }, page_layout: 'default', local_tasks: [], | ||
})) |