Skip to content

Commit

Permalink
Merge pull request #160 from hubblecommerce/rc2.3
Browse files Browse the repository at this point in the history
Release Candidate 2.3
  • Loading branch information
dm-heinze authored Sep 29, 2023
2 parents 262e355 + 8345cd7 commit 16ba13a
Show file tree
Hide file tree
Showing 7 changed files with 6,563 additions and 5,335 deletions.
15 changes: 0 additions & 15 deletions __tests__/module/module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
import { setup, $fetch, fetch } from '@nuxt/test-utils'

async function throw404 () {
return await $fetch('/this-route-not-exists')
}

describe('hubble Nuxt.js module setup', async () => {
await setup({
rootDir: fileURLToPath(new URL('./fixture', import.meta.url))
Expand Down Expand Up @@ -80,17 +76,6 @@ describe('hubble Nuxt.js module setup', async () => {
expect(html).toContain('RuntimeConfig | meta.category.title: Category - Hubble Demo')
})

/*
* Error handling
*/
it('adds custom error page and override it', async () => {
try {
await throw404()
} catch (e: any) {
expect(e.data).toContain('Override Custom Error Page')
}
})

/*
* i18n
*/
Expand Down
6 changes: 6 additions & 0 deletions cypress/e2e/module.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ describe('TailwindCSS and DaisyUI integration', () => {
.should('have.css', 'color')
.should('equal', 'rgb(0, 0, 0)')
})

it('is possible to override MiscError.vue to create a custom error page', () => {
cy.request({ url: '/this-route-not-exists', failOnStatusCode: false }).its('status').should('equal', 404)
cy.visit('/this-route-not-exists', { failOnStatusCode: false })
cy.get('html').contains('Override Custom Error Page')
})
})
11,701 changes: 6,450 additions & 5,251 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hubblecommerce/hubble",
"version": "2.2.1",
"version": "2.3.0",
"description": "PWA for eCommerce frameworks based on NuxtJs",
"author": "hubble commerce",
"license": "MIT",
Expand Down Expand Up @@ -62,6 +62,7 @@
},
"dependencies": {
"@heroicons/vue": "^2.0.16",
"@intlify/devtools-if": "^9.5.0",
"@intlify/nuxt3": "^0.2.4",
"@json2csv/node": "^7.0.1",
"@nuxt/kit": "^3.2.3",
Expand All @@ -77,6 +78,7 @@
"lmify": "^0.3.0",
"mitt": "^3.0.0",
"portal-vue": "^3.0.0",
"ufo": "^1.3.0",
"untyped": "^1.2.2",
"unzipper": "^0.10.11"
},
Expand All @@ -93,11 +95,11 @@
"eslint-plugin-vue": "^9.9.0",
"husky": "^8.0.3",
"lint-staged": "^13.1.2",
"nuxt": "^3.6.5",
"nuxt": "^3.7.4",
"openapi-typescript-codegen": "^0.25.0",
"rollup-plugin-copy": "^3.4.0",
"start-server-and-test": "^2.0.0",
"typescript": "^5.1.6",
"typescript": "~5.1.6",
"vite-plugin-eslint": "^1.8.1",
"vitest": "^0.33.0",
"vuepress": "2.0.0-beta.61"
Expand Down
16 changes: 14 additions & 2 deletions src/platforms/shopware/composables/usePage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Ref, ref } from 'vue'
import { RouteLocationNormalizedLoaded } from 'vue-router'
import { useRouter, useRequestURL } from '#app'
import { joinURL } from 'ufo'
import { getRequestURL as h3GetRequestUrl } from 'h3'
import { useRouter, useRuntimeConfig } from '#app'
import {
HblIUsePage,
HblPage,
Expand All @@ -18,6 +20,7 @@ import {
} from '@hubblecommerce/hubble/platforms/shopware/api-client'
import { request as __request } from '@hubblecommerce/hubble/platforms/shopware/request'
import { useLocalisation, hblMapPage, hblMapProductListing, hblMapProduct } from '#imports'
import { useRequestEvent } from '#app/composables/ssr'

const associations = {
media: {},
Expand All @@ -28,6 +31,15 @@ const associations = {
}
}

export function getRequestURL () {
if (process.server) {
const url: any = h3GetRequestUrl(useRequestEvent())
url.pathname = joinURL(useRuntimeConfig().app.baseURL, url.pathname)
return url
}
return new URL(window.location.href)
}

export const usePage = function (): HblIUsePage {
const loading: Ref<boolean> = ref(false)
const error: Ref = ref(false)
Expand Down Expand Up @@ -143,7 +155,7 @@ export const usePage = function (): HblIUsePage {

// Write parameters to current url without reloading the page
function updateUri (params: any): void {
const url = new URL(useRequestURL().origin + currentRoute.value.path)
const url = new URL(getRequestURL().origin + currentRoute.value.path)
url.search = new URLSearchParams(params).toString()
window.history.pushState(
{},
Expand Down
76 changes: 44 additions & 32 deletions tsconfig-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,80 @@
"paths": {
"@hubblecommerce/hubble/platforms/shopware/api-client": ["../../../src/platforms/shopware/api-client/generated/index"],
"@hubblecommerce/hubble/platforms/shopware/request": ["../../../src/platforms/shopware/api-client/generated/core/request"],
"~~": [
"."
],
"~~/*": [
"./*"
],
"@@": [
"."
],
"@@/*": [
"./*"
],
"~": [
".hubble"
"../.hubble"
],
"~/*": [
".hubble/*"
"../.hubble/*"
],
"@": [
".hubble"
"../.hubble"
],
"@/*": [
".hubble/*"
"../.hubble/*"
],
"~~": [
".."
],
"~~/*": [
"../*"
],
"@@": [
".."
],
"@@/*": [
"../*"
],
"assets": [
".hubble/assets"
"../.hubble/assets"
],
"assets/*": [
".hubble/assets/*"
"../.hubble/assets/*"
],
"public": [
".hubble/public"
"../.hubble/public"
],
"#app": [
"../../../node_modules/nuxt/dist/app"
"../../../../node_modules/nuxt/dist/app"
],
"#app/*": [
"../../../node_modules/nuxt/dist/app/*"
"../../../../node_modules/nuxt/dist/app/*"
],
"vue-demi": [
"../../../node_modules/nuxt/dist/app/compat/vue-demi"
"../../../../node_modules/nuxt/dist/app/compat/vue-demi"
],
"pinia": [
"pinia/dist/pinia"
"../../../../node_modules/pinia/dist/pinia"
],
"#head": [
"../../../node_modules/nuxt/dist/head/runtime"
"#color-mode-options": [
"./color-mode-options.mjs"
],
"#head/*": [
"../../../node_modules/nuxt/dist/head/runtime/*"
"@intlify/shared": [
"../../../../node_modules/@intlify/shared/dist/shared.esm-bundler"
],
"#components": [
".nuxt/components"
"@intlify/core-base": [
"../../../../node_modules/@intlify/core-base/dist/core-base.esm-bundler"
],
"@intlify/devtools-if": [
"../../../../node_modules/@intlify/devtools-if/dist/devtools-if.esm-bundler"
],
"vue-i18n": [
"../../../../node_modules/vue-i18n/dist/vue-i18n.runtime.esm-bundler"
],
"#vue-router": [
"./vue-router"
],
"#imports": [
".nuxt/imports"
"./imports"
],
"#build": [
".nuxt"
"."
],
"#build/*": [
".nuxt/*"
"./*"
],
"#components": [
"./components"
]
}
},
Expand Down
76 changes: 44 additions & 32 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,80 @@
"paths": {
"@hubblecommerce/hubble/platforms/shopware/api-client": ["../src/platforms/shopware/api-client/generated/index"],
"@hubblecommerce/hubble/platforms/shopware/request": ["../src/platforms/shopware/api-client/generated/core/request"],
"~~": [
"."
],
"~~/*": [
"./*"
],
"@@": [
"."
],
"@@/*": [
"./*"
],
"~": [
".hubble"
"../.hubble"
],
"~/*": [
".hubble/*"
"../.hubble/*"
],
"@": [
".hubble"
"../.hubble"
],
"@/*": [
".hubble/*"
"../.hubble/*"
],
"~~": [
".."
],
"~~/*": [
"../*"
],
"@@": [
".."
],
"@@/*": [
"../*"
],
"assets": [
".hubble/assets"
"../.hubble/assets"
],
"assets/*": [
".hubble/assets/*"
"../.hubble/assets/*"
],
"public": [
".hubble/public"
"../.hubble/public"
],
"#app": [
"../node_modules/nuxt/dist/app"
"../../node_modules/nuxt/dist/app"
],
"#app/*": [
"../node_modules/nuxt/dist/app/*"
"../../node_modules/nuxt/dist/app/*"
],
"vue-demi": [
"../node_modules/nuxt/dist/app/compat/vue-demi"
"../../node_modules/nuxt/dist/app/compat/vue-demi"
],
"pinia": [
"pinia/dist/pinia"
"../../node_modules/pinia/dist/pinia"
],
"#head": [
"../node_modules/nuxt/dist/head/runtime"
"#color-mode-options": [
"./color-mode-options.mjs"
],
"#head/*": [
"../node_modules/nuxt/dist/head/runtime/*"
"@intlify/shared": [
"../../node_modules/@intlify/shared/dist/shared.esm-bundler"
],
"#components": [
".nuxt/components"
"@intlify/core-base": [
"../../node_modules/@intlify/core-base/dist/core-base.esm-bundler"
],
"@intlify/devtools-if": [
"../../node_modules/@intlify/devtools-if/dist/devtools-if.esm-bundler"
],
"vue-i18n": [
"../../node_modules/vue-i18n/dist/vue-i18n.esm-bundler"
],
"#vue-router": [
"./vue-router"
],
"#imports": [
".nuxt/imports"
"./imports"
],
"#build": [
".nuxt"
"."
],
"#build/*": [
".nuxt/*"
"./*"
],
"#components": [
"./components"
]
}
},
Expand Down

0 comments on commit 16ba13a

Please sign in to comment.