add: NEXT_PUBLIC_STOREFRONT_URL and NEXT_PUBLIC_HOMEPAGE_URL. Remove NEXT_PUBLIC_MARKETPLACE_URL.
Build & Deploy / Build & Push Docker Image (push) Failing after 1m5s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / Type Check (all packages) (push) Failing after 32s
Test / API Unit Tests (push) Has been skipped
Test / Homepage Unit Tests (push) Has been skipped
Test / Storefront Unit Tests (push) Has been skipped
Test / Admin Unit Tests (push) Has been skipped
Test / Dashboard Unit Tests (push) Has been skipped
Test / API Integration Tests (push) Has been skipped
Build & Deploy / Build & Push Docker Image (push) Failing after 1m5s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / Type Check (all packages) (push) Failing after 32s
Test / API Unit Tests (push) Has been skipped
Test / Homepage Unit Tests (push) Has been skipped
Test / Storefront Unit Tests (push) Has been skipped
Test / Admin Unit Tests (push) Has been skipped
Test / Dashboard Unit Tests (push) Has been skipped
Test / API Integration Tests (push) Has been skipped
This commit is contained in:
@@ -9,7 +9,7 @@ function installWindow(hostname: string, protocol = 'https:') {
|
||||
|
||||
async function loadUrls(env: Record<string, string | undefined> = {}) {
|
||||
vi.resetModules()
|
||||
for (const key of ['NEXT_PUBLIC_MARKETPLACE_URL', 'NEXT_PUBLIC_ADMIN_URL']) {
|
||||
for (const key of ['NEXT_PUBLIC_STOREFRONT_URL', 'NEXT_PUBLIC_ADMIN_URL']) {
|
||||
if (env[key] === undefined) {
|
||||
delete process.env[key]
|
||||
} else {
|
||||
@@ -21,44 +21,44 @@ async function loadUrls(env: Record<string, string | undefined> = {}) {
|
||||
|
||||
afterEach(() => {
|
||||
Reflect.deleteProperty(globalThis, 'window')
|
||||
delete process.env.NEXT_PUBLIC_MARKETPLACE_URL
|
||||
delete process.env.NEXT_PUBLIC_STOREFRONT_URL
|
||||
delete process.env.NEXT_PUBLIC_ADMIN_URL
|
||||
vi.resetModules()
|
||||
})
|
||||
|
||||
describe('dashboard cross-app URLs', () => {
|
||||
it('uses default marketplace and admin bases on the server', async () => {
|
||||
const { marketplaceUrl, adminUrl } = await loadUrls()
|
||||
const { storefrontUrl, adminUrl } = await loadUrls()
|
||||
|
||||
expect(marketplaceUrl).toBe('http://localhost:3000')
|
||||
expect(storefrontUrl).toBe('http://localhost:3000')
|
||||
expect(adminUrl).toBe('http://localhost:3000/admin')
|
||||
})
|
||||
|
||||
it('strips trailing slashes from configured absolute URLs', async () => {
|
||||
const { marketplaceUrl, adminUrl } = await loadUrls({
|
||||
NEXT_PUBLIC_MARKETPLACE_URL: 'https://market.example.com/',
|
||||
const { storefrontUrl, adminUrl } = await loadUrls({
|
||||
NEXT_PUBLIC_STOREFRONT_URL: 'https://market.example.com/',
|
||||
NEXT_PUBLIC_ADMIN_URL: 'https://ops.example.com/admin/',
|
||||
})
|
||||
|
||||
expect(marketplaceUrl).toBe('https://market.example.com')
|
||||
expect(storefrontUrl).toBe('https://market.example.com')
|
||||
expect(adminUrl).toBe('https://ops.example.com/admin')
|
||||
})
|
||||
|
||||
it('rewrites local browser fallbacks onto the current production host', async () => {
|
||||
installWindow('tenant.rentaldrivego.com', 'https:')
|
||||
const { marketplaceUrl, adminUrl } = await loadUrls()
|
||||
const { storefrontUrl, adminUrl } = await loadUrls()
|
||||
|
||||
expect(marketplaceUrl).toBe('https://tenant.rentaldrivego.com')
|
||||
expect(storefrontUrl).toBe('https://tenant.rentaldrivego.com')
|
||||
expect(adminUrl).toBe('https://tenant.rentaldrivego.com/admin')
|
||||
})
|
||||
|
||||
it('preserves non-URL values after normalizing their trailing slash', async () => {
|
||||
const { marketplaceUrl, adminUrl } = await loadUrls({
|
||||
NEXT_PUBLIC_MARKETPLACE_URL: '/marketplace/',
|
||||
const { storefrontUrl, adminUrl } = await loadUrls({
|
||||
NEXT_PUBLIC_STOREFRONT_URL: '/marketplace/',
|
||||
NEXT_PUBLIC_ADMIN_URL: '/admin/',
|
||||
})
|
||||
|
||||
expect(marketplaceUrl).toBe('/marketplace')
|
||||
expect(storefrontUrl).toBe('/marketplace')
|
||||
expect(adminUrl).toBe('/admin')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -9,8 +9,8 @@ function toAppBase(url: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export const marketplaceUrl = toAppBase(
|
||||
resolveBrowserAppUrl(process.env.NEXT_PUBLIC_MARKETPLACE_URL ?? 'http://localhost:3000'),
|
||||
export const storefrontUrl = toAppBase(
|
||||
resolveBrowserAppUrl(process.env.NEXT_PUBLIC_STOREFRONT_URL ?? 'http://localhost:3000'),
|
||||
)
|
||||
|
||||
export const adminUrl = toAppBase(
|
||||
|
||||
Reference in New Issue
Block a user