11import { waitForThemeToBeProcessed } from './host-theme-watcher.js'
22import { HostThemeManager , DEFAULT_THEME_ZIP , FALLBACK_THEME_ZIP } from './host-theme-manager.js'
3- import { createTheme } from '@shopify/cli-kit/node/themes/api'
3+ import { themeCreate } from '@shopify/cli-kit/node/themes/api'
44import { beforeEach , describe , expect , test , vi } from 'vitest'
55import { DEVELOPMENT_THEME_ROLE } from '@shopify/cli-kit/node/themes/utils'
66import { AdminSession } from '@shopify/cli-kit/node/session'
@@ -18,8 +18,8 @@ describe('HostThemeManager', () => {
1818 vi . spyOn ( ThemeManager . prototype , 'generateThemeName' ) . mockImplementation ( ( ) => 'App Ext. Host Name' )
1919 } )
2020
21- test ( 'should call createTheme with the provided name and src param' , async ( ) => {
22- vi . mocked ( createTheme ) . mockResolvedValue ( {
21+ test ( 'should call themeCreate with the provided name and src param' , async ( ) => {
22+ vi . mocked ( themeCreate ) . mockResolvedValue ( {
2323 id : 12345 ,
2424 name : 'Theme' ,
2525 role : 'development' ,
@@ -31,7 +31,7 @@ describe('HostThemeManager', () => {
3131 await themeManager . findOrCreate ( )
3232
3333 // Then
34- expect ( createTheme ) . toHaveBeenCalledWith (
34+ expect ( themeCreate ) . toHaveBeenCalledWith (
3535 {
3636 name : 'App Ext. Host Name' ,
3737 role : DEVELOPMENT_THEME_ROLE ,
@@ -42,9 +42,9 @@ describe('HostThemeManager', () => {
4242 } )
4343
4444 describe ( 'dev preview' , ( ) => {
45- test ( 'should call createTheme with the provided name and src param' , async ( ) => {
45+ test ( 'should call themeCreate with the provided name and src param' , async ( ) => {
4646 // Given
47- vi . mocked ( createTheme ) . mockResolvedValue ( {
47+ vi . mocked ( themeCreate ) . mockResolvedValue ( {
4848 id : 12345 ,
4949 name : 'Theme' ,
5050 role : 'development' ,
@@ -56,7 +56,7 @@ describe('HostThemeManager', () => {
5656 await themeManager . findOrCreate ( )
5757
5858 // Then
59- expect ( createTheme ) . toHaveBeenCalledWith (
59+ expect ( themeCreate ) . toHaveBeenCalledWith (
6060 {
6161 name : 'App Ext. Host Name' ,
6262 role : DEVELOPMENT_THEME_ROLE ,
@@ -68,7 +68,7 @@ describe('HostThemeManager', () => {
6868
6969 test ( 'should wait for the theme to be processed' , async ( ) => {
7070 // Given
71- vi . mocked ( createTheme ) . mockResolvedValue ( {
71+ vi . mocked ( themeCreate ) . mockResolvedValue ( {
7272 id : 12345 ,
7373 name : 'Theme' ,
7474 role : 'development' ,
@@ -86,7 +86,7 @@ describe('HostThemeManager', () => {
8686
8787 test ( 'should retry creating the theme if the first attempt fails' , async ( ) => {
8888 // Given
89- vi . mocked ( createTheme ) . mockResolvedValueOnce ( undefined ) . mockResolvedValueOnce ( {
89+ vi . mocked ( themeCreate ) . mockResolvedValueOnce ( undefined ) . mockResolvedValueOnce ( {
9090 id : 12345 ,
9191 name : 'Theme' ,
9292 role : 'development' ,
@@ -98,8 +98,8 @@ describe('HostThemeManager', () => {
9898 await themeManager . findOrCreate ( )
9999
100100 // Then
101- expect ( createTheme ) . toHaveBeenCalledTimes ( 2 )
102- expect ( createTheme ) . toHaveBeenNthCalledWith (
101+ expect ( themeCreate ) . toHaveBeenCalledTimes ( 2 )
102+ expect ( themeCreate ) . toHaveBeenNthCalledWith (
103103 1 ,
104104 {
105105 role : DEVELOPMENT_THEME_ROLE ,
@@ -108,7 +108,7 @@ describe('HostThemeManager', () => {
108108 } ,
109109 adminSession ,
110110 )
111- expect ( createTheme ) . toHaveBeenNthCalledWith (
111+ expect ( themeCreate ) . toHaveBeenNthCalledWith (
112112 2 ,
113113 {
114114 role : DEVELOPMENT_THEME_ROLE ,
@@ -121,7 +121,7 @@ describe('HostThemeManager', () => {
121121
122122 test ( 'should gracefully handle a 422 from the server during theme creation' , async ( ) => {
123123 // Given
124- vi . mocked ( createTheme )
124+ vi . mocked ( themeCreate )
125125 . mockRejectedValueOnce ( new Error ( 'API request unprocessable content: {"src":["is empty"]}' ) )
126126 . mockRejectedValueOnce ( new Error ( 'API request unprocessable content: {"src":["is empty"]}' ) )
127127 . mockResolvedValueOnce ( {
@@ -136,12 +136,12 @@ describe('HostThemeManager', () => {
136136 await themeManager . findOrCreate ( )
137137
138138 // Then
139- expect ( createTheme ) . toHaveBeenCalledTimes ( 3 )
139+ expect ( themeCreate ) . toHaveBeenCalledTimes ( 3 )
140140 } )
141141
142142 test ( 'should retry creating the theme with the Fallback theme zip after 3 failed retry attempts' , async ( ) => {
143143 // Given
144- vi . mocked ( createTheme )
144+ vi . mocked ( themeCreate )
145145 . mockResolvedValueOnce ( undefined )
146146 . mockResolvedValueOnce ( undefined )
147147 . mockResolvedValueOnce ( undefined )
@@ -157,8 +157,8 @@ describe('HostThemeManager', () => {
157157 await themeManager . findOrCreate ( )
158158
159159 // Then
160- expect ( createTheme ) . toHaveBeenCalledTimes ( 4 )
161- expect ( createTheme ) . toHaveBeenLastCalledWith (
160+ expect ( themeCreate ) . toHaveBeenCalledTimes ( 4 )
161+ expect ( themeCreate ) . toHaveBeenLastCalledWith (
162162 {
163163 role : DEVELOPMENT_THEME_ROLE ,
164164 name : 'App Ext. Host Name' ,
@@ -170,14 +170,14 @@ describe('HostThemeManager', () => {
170170
171171 test ( 'should throw a BugError if the theme cannot be created' , async ( ) => {
172172 // Given
173- vi . mocked ( createTheme ) . mockResolvedValue ( undefined )
173+ vi . mocked ( themeCreate ) . mockResolvedValue ( undefined )
174174
175175 // When
176176 // Then
177177 await expect ( themeManager . findOrCreate ( ) ) . rejects . toThrow (
178178 'Could not create theme with name "App Ext. Host Name" and role "development"' ,
179179 )
180- expect ( createTheme ) . toHaveBeenCalledTimes ( 4 )
180+ expect ( themeCreate ) . toHaveBeenCalledTimes ( 4 )
181181 } )
182182 } )
183183} )
0 commit comments