|
1 | 1 | import {calculatePrefixColumnSize, Dev} from './Dev.js' |
2 | 2 | import {fetchAppPreviewMode} from '../../fetch.js' |
3 | 3 | import {testDeveloperPlatformClient, testUIExtension} from '../../../../models/app/app.test-data.js' |
4 | | -import {devSessionStatusManager} from '../../processes/dev-session-status-manager.js' |
5 | 4 | import { |
6 | 5 | getLastFrameAfterUnmount, |
7 | 6 | render, |
@@ -341,7 +340,6 @@ describe('Dev', () => { |
341 | 340 | " |
342 | 341 | `) |
343 | 342 | expect(developerPreview.disable).toHaveBeenCalledOnce() |
344 | | - expect(testApp.developerPlatformClient.devSessionDelete).toHaveBeenCalledOnce() |
345 | 343 |
|
346 | 344 | // unmount so that polling is cleared after every test |
347 | 345 | renderInstance.unmount() |
@@ -407,7 +405,6 @@ describe('Dev', () => { |
407 | 405 | " |
408 | 406 | `) |
409 | 407 | expect(developerPreview.disable).toHaveBeenCalledOnce() |
410 | | - expect(testApp.developerPlatformClient.devSessionDelete).toHaveBeenCalledOnce() |
411 | 408 |
|
412 | 409 | // unmount so that polling is cleared after every test |
413 | 410 | renderInstance.unmount() |
@@ -976,156 +973,6 @@ describe('Dev', () => { |
976 | 973 | // unmount so that polling is cleared after every test |
977 | 974 | renderInstance.unmount() |
978 | 975 | }) |
979 | | - |
980 | | - test('updates UI when devSessionEnabled changes from false to true', async () => { |
981 | | - // Given |
982 | | - devSessionStatusManager.updateStatus({isReady: false}) |
983 | | - |
984 | | - const renderInstance = render( |
985 | | - <Dev |
986 | | - processes={[]} |
987 | | - abortController={new AbortController()} |
988 | | - previewUrl="https://shopify.com" |
989 | | - graphiqlUrl="https://graphiql.shopify.com" |
990 | | - graphiqlPort={1234} |
991 | | - app={{ |
992 | | - ...testApp, |
993 | | - canEnablePreviewMode: false, |
994 | | - developerPlatformClient: { |
995 | | - ...testDeveloperPlatformClient(), |
996 | | - supportsDevSessions: true, |
997 | | - }, |
998 | | - }} |
999 | | - developerPreview={developerPreview} |
1000 | | - shopFqdn="mystore.shopify.io" |
1001 | | - />, |
1002 | | - ) |
1003 | | - |
1004 | | - await waitForInputsToBeReady() |
1005 | | - |
1006 | | - // Initial state - dev session not ready |
1007 | | - expect(unstyled(renderInstance.lastFrame()!).replace(/\d/g, '0')).toMatchInlineSnapshot(` |
1008 | | - " |
1009 | | - ──────────────────────────────────────────────────────────────────────────────────────────────────── |
1010 | | -
|
1011 | | - › Press q │ quit |
1012 | | -
|
1013 | | - Preview URL: https://shopify.com |
1014 | | - GraphiQL URL: http://localhost:0000/graphiql |
1015 | | - " |
1016 | | - `) |
1017 | | - |
1018 | | - // When dev session becomes ready |
1019 | | - devSessionStatusManager.updateStatus({isReady: true, previewURL: 'https://shopify.com'}) |
1020 | | - |
1021 | | - // Wait for the polling interval to update the UI |
1022 | | - await waitForContent(renderInstance, 'preview in your browser') |
1023 | | - |
1024 | | - // Then - preview shortcut should be visible |
1025 | | - expect(unstyled(renderInstance.lastFrame()!).replace(/\d/g, '0')).toMatchInlineSnapshot(` |
1026 | | - " |
1027 | | - ──────────────────────────────────────────────────────────────────────────────────────────────────── |
1028 | | -
|
1029 | | - › Press g │ open GraphiQL (Admin API) in your browser |
1030 | | - › Press p │ preview in your browser |
1031 | | - › Press q │ quit |
1032 | | -
|
1033 | | - Preview URL: https://shopify.com |
1034 | | - GraphiQL URL: http://localhost:0000/graphiql |
1035 | | - " |
1036 | | - `) |
1037 | | - |
1038 | | - // unmount so that polling is cleared after every test |
1039 | | - renderInstance.unmount() |
1040 | | - }) |
1041 | | - |
1042 | | - test('updates preview URL when devSessionStatus provides a new URL', async () => { |
1043 | | - // Given |
1044 | | - const initialPreviewUrl = 'https://shopify.com' |
1045 | | - const newPreviewUrl = 'https://my-new-preview-url.shopify.com' |
1046 | | - devSessionStatusManager.updateStatus({isReady: true, previewURL: undefined}) |
1047 | | - |
1048 | | - const renderInstance = render( |
1049 | | - <Dev |
1050 | | - processes={[]} |
1051 | | - abortController={new AbortController()} |
1052 | | - previewUrl={initialPreviewUrl} |
1053 | | - graphiqlUrl="https://graphiql.shopify.com" |
1054 | | - graphiqlPort={1234} |
1055 | | - app={{ |
1056 | | - ...testApp, |
1057 | | - developerPlatformClient: { |
1058 | | - ...testDeveloperPlatformClient(), |
1059 | | - supportsDevSessions: true, |
1060 | | - }, |
1061 | | - }} |
1062 | | - developerPreview={developerPreview} |
1063 | | - shopFqdn="mystore.shopify.io" |
1064 | | - />, |
1065 | | - ) |
1066 | | - |
1067 | | - await waitForInputsToBeReady() |
1068 | | - |
1069 | | - // Initial state should show the default preview URL |
1070 | | - expect(unstyled(renderInstance.lastFrame()!)).toContain(`Preview URL: ${initialPreviewUrl}`) |
1071 | | - |
1072 | | - // When dev session provides a new preview URL |
1073 | | - devSessionStatusManager.updateStatus({isReady: true, previewURL: newPreviewUrl}) |
1074 | | - |
1075 | | - // Wait for the polling interval to update the UI |
1076 | | - await waitForContent(renderInstance, newPreviewUrl) |
1077 | | - |
1078 | | - // Then - status message should show the new preview URL |
1079 | | - expect(unstyled(renderInstance.lastFrame()!)).toContain(`Preview URL: ${newPreviewUrl}`) |
1080 | | - |
1081 | | - // unmount so that polling is cleared after every test |
1082 | | - renderInstance.unmount() |
1083 | | - }) |
1084 | | - |
1085 | | - test('opens the updated preview URL when p is pressed after URL changes', async () => { |
1086 | | - // Given |
1087 | | - const initialPreviewUrl = 'https://shopify.com' |
1088 | | - const newPreviewUrl = 'https://my-new-preview-url.shopify.com' |
1089 | | - devSessionStatusManager.updateStatus({isReady: true, previewURL: undefined}) |
1090 | | - |
1091 | | - const renderInstance = render( |
1092 | | - <Dev |
1093 | | - processes={[]} |
1094 | | - abortController={new AbortController()} |
1095 | | - previewUrl={initialPreviewUrl} |
1096 | | - graphiqlUrl="https://graphiql.shopify.com" |
1097 | | - graphiqlPort={1234} |
1098 | | - app={{ |
1099 | | - ...testApp, |
1100 | | - developerPlatformClient: { |
1101 | | - ...testDeveloperPlatformClient(), |
1102 | | - supportsDevSessions: true, |
1103 | | - }, |
1104 | | - }} |
1105 | | - developerPreview={developerPreview} |
1106 | | - shopFqdn="mystore.shopify.io" |
1107 | | - />, |
1108 | | - ) |
1109 | | - |
1110 | | - await waitForInputsToBeReady() |
1111 | | - |
1112 | | - // Initial state should show the default preview URL |
1113 | | - expect(unstyled(renderInstance.lastFrame()!)).toContain(`Preview URL: ${initialPreviewUrl}`) |
1114 | | - |
1115 | | - // When dev session provides a new preview URL |
1116 | | - devSessionStatusManager.updateStatus({isReady: true, previewURL: newPreviewUrl}) |
1117 | | - |
1118 | | - // Wait for the polling interval to update the UI |
1119 | | - await waitForContent(renderInstance, newPreviewUrl) |
1120 | | - |
1121 | | - await waitForInputsToBeReady() |
1122 | | - await sendInputAndWait(renderInstance, 100, 'p') |
1123 | | - |
1124 | | - // Then |
1125 | | - expect(vi.mocked(openURL)).toHaveBeenNthCalledWith(1, newPreviewUrl) |
1126 | | - |
1127 | | - renderInstance.unmount() |
1128 | | - }) |
1129 | 976 | }) |
1130 | 977 |
|
1131 | 978 | describe('calculatePrefixColumnSize', () => { |
|
0 commit comments