Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions packages/cli-kit/src/public/node/context/fqdn.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
partnersFqdn,
appManagementFqdn,
developerDashboardFqdn,
identityFqdn,
normalizeStoreFqdn,
businessPlatformFqdn,
appDevFqdn,
adminFqdn,
storeAdminUrl,
} from './fqdn.js'
import {Environment, serviceEnvironment} from '../../../private/node/context/service.js'
import {expect, describe, test, vi} from 'vitest'
Expand Down Expand Up @@ -174,6 +176,68 @@ describe('adminFqdn', () => {
})
})

describe('developerDashboardFqdn', () => {
test('returns the local fqdn when the environment is local', async () => {
// Given
vi.mocked(serviceEnvironment).mockReturnValue(Environment.Local)

// When
const got = await developerDashboardFqdn()

// Then
expect(got).toEqual('dev.myshopify.io')
})

test('returns the production fqdn when the environment is production', async () => {
// Given
vi.mocked(serviceEnvironment).mockReturnValue(Environment.Production)

// When
const got = await developerDashboardFqdn()

// Then
expect(got).toEqual('dev.shopify.com')
})
})

describe('storeAdminUrl', () => {
test('transforms store fqdn ending in .my.shop.dev when environment is local', () => {
// Given
vi.mocked(serviceEnvironment).mockReturnValue(Environment.Local)
const storeFqdn = 'my-store.my.shop.dev'

// When
const got = storeAdminUrl(storeFqdn)

// Then
expect(got).toEqual('admin.shop.dev/store/my-store')
})

test('returns unchanged store fqdn when environment is local but domain does not end in .my.shop.dev', () => {
// Given
vi.mocked(serviceEnvironment).mockReturnValue(Environment.Local)
const storeFqdn = 'my-store.myshopify.com'

// When
const got = storeAdminUrl(storeFqdn)

// Then
expect(got).toEqual('my-store.myshopify.com')
})

test('returns unchanged store fqdn when environment is production', () => {
// Given
vi.mocked(serviceEnvironment).mockReturnValue(Environment.Production)
const storeFqdn = 'my-store.my.shop.dev'

// When
const got = storeAdminUrl(storeFqdn)

// Then
expect(got).toEqual('my-store.my.shop.dev')
})
})

describe('normalizeStore', () => {
test('parses store name with http', async () => {
// When
Expand Down
Loading