-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #883 from chromaui/revert-876-ghengeveld/ap-3909-c…
…li-replace-getbuilduploadurls-with-uploadbuild-mutation Revert "Replace `getUploadUrls` with `uploadBuild` mutation"
- Loading branch information
Showing
28 changed files
with
316 additions
and
535 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,16 +98,14 @@ vi.mock('node-fetch', () => ({ | |
} | ||
|
||
if (query?.match('PublishBuildMutation')) { | ||
publishedBuild = { | ||
id: variables.id, | ||
...variables.input, | ||
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/', | ||
}; | ||
if (variables.input.isolatorUrl.startsWith('http://throw-an-error')) { | ||
throw new Error('fetch error'); | ||
} | ||
publishedBuild = { id: variables.id, ...variables.input }; | ||
return { | ||
data: { | ||
publishBuild: { | ||
status: 'PUBLISHED', | ||
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/', | ||
}, | ||
}, | ||
}; | ||
|
@@ -134,8 +132,8 @@ vi.mock('node-fetch', () => ({ | |
status: 'IN_PROGRESS', | ||
specCount: 1, | ||
componentCount: 1, | ||
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/', | ||
webUrl: 'http://test.com', | ||
cachedUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/iframe.html', | ||
...mockBuildFeatures, | ||
app: { | ||
account: { | ||
|
@@ -195,8 +193,7 @@ vi.mock('node-fetch', () => ({ | |
}; | ||
} | ||
|
||
if (query?.match('UploadBuildMutation') || query?.match('UploadMetadataMutation')) { | ||
const key = query?.match('UploadBuildMutation') ? 'uploadBuild' : 'uploadMetadata'; | ||
if (query?.match('GetUploadUrlsMutation')) { | ||
const contentTypes = { | ||
html: 'text/html', | ||
js: 'text/javascript', | ||
|
@@ -205,17 +202,13 @@ vi.mock('node-fetch', () => ({ | |
}; | ||
return { | ||
data: { | ||
[key]: { | ||
info: { | ||
targets: variables.files.map(({ filePath }) => ({ | ||
contentType: contentTypes[filePath.split('.').at(-1)], | ||
fileKey: '', | ||
filePath, | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
})), | ||
}, | ||
userErrors: [], | ||
getUploadUrls: { | ||
domain: 'https://chromatic.com', | ||
urls: variables.paths.map((path: string) => ({ | ||
path, | ||
url: `https://cdn.example.com/${path}`, | ||
contentType: contentTypes[path.split('.').at(-1)], | ||
})), | ||
}, | ||
}, | ||
}; | ||
|
@@ -412,7 +405,7 @@ it('runs in simple situations', async () => { | |
storybookViewLayer: 'viewLayer', | ||
committerEmail: '[email protected]', | ||
committerName: 'tester', | ||
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/', | ||
isolatorUrl: `https://chromatic.com/iframe.html`, | ||
}); | ||
}); | ||
|
||
|
@@ -469,24 +462,20 @@ it('calls out to npm build script passed and uploads files', async () => { | |
expect.any(Object), | ||
[ | ||
{ | ||
contentHash: 'hash', | ||
contentLength: 42, | ||
contentType: 'text/html', | ||
fileKey: '', | ||
filePath: 'iframe.html', | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
localPath: expect.stringMatching(/\/iframe\.html$/), | ||
targetPath: 'iframe.html', | ||
targetUrl: 'https://cdn.example.com/iframe.html', | ||
}, | ||
{ | ||
contentHash: 'hash', | ||
contentLength: 42, | ||
contentType: 'text/html', | ||
fileKey: '', | ||
filePath: 'index.html', | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
localPath: expect.stringMatching(/\/index\.html$/), | ||
targetPath: 'index.html', | ||
targetUrl: 'https://cdn.example.com/index.html', | ||
}, | ||
], | ||
expect.any(Function) | ||
|
@@ -502,24 +491,20 @@ it('skips building and uploads directly with storybook-build-dir', async () => { | |
expect.any(Object), | ||
[ | ||
{ | ||
contentHash: 'hash', | ||
contentLength: 42, | ||
contentType: 'text/html', | ||
fileKey: '', | ||
filePath: 'iframe.html', | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
localPath: expect.stringMatching(/\/iframe\.html$/), | ||
targetPath: 'iframe.html', | ||
targetUrl: 'https://cdn.example.com/iframe.html', | ||
}, | ||
{ | ||
contentHash: 'hash', | ||
contentLength: 42, | ||
contentType: 'text/html', | ||
fileKey: '', | ||
filePath: 'index.html', | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
localPath: expect.stringMatching(/\/index\.html$/), | ||
targetPath: 'index.html', | ||
targetUrl: 'https://cdn.example.com/index.html', | ||
}, | ||
], | ||
expect.any(Function) | ||
|
@@ -714,44 +699,32 @@ it('should upload metadata files if --upload-metadata is passed', async () => { | |
expect(upload.mock.calls.at(-1)[1]).toEqual( | ||
expect.arrayContaining([ | ||
{ | ||
contentLength: 518, | ||
contentType: 'text/javascript', | ||
fileKey: '', | ||
filePath: '.chromatic/main.js', | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
localPath: '.storybook/main.js', | ||
targetPath: '.chromatic/main.js', | ||
contentLength: 518, | ||
contentType: 'text/javascript', | ||
targetUrl: 'https://cdn.example.com/.chromatic/main.js', | ||
}, | ||
{ | ||
contentLength: 457, | ||
contentType: 'application/json', | ||
fileKey: '', | ||
filePath: '.chromatic/preview-stats.trimmed.json', | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
localPath: 'storybook-out/preview-stats.trimmed.json', | ||
targetPath: '.chromatic/preview-stats.trimmed.json', | ||
contentLength: 457, | ||
contentType: 'application/json', | ||
targetUrl: 'https://cdn.example.com/.chromatic/preview-stats.trimmed.json', | ||
}, | ||
{ | ||
contentLength: 1338, | ||
contentType: 'text/javascript', | ||
fileKey: '', | ||
filePath: '.chromatic/preview.js', | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
localPath: '.storybook/preview.js', | ||
targetPath: '.chromatic/preview.js', | ||
contentLength: 1338, | ||
contentType: 'text/javascript', | ||
targetUrl: 'https://cdn.example.com/.chromatic/preview.js', | ||
}, | ||
{ | ||
contentLength: expect.any(Number), | ||
contentType: 'text/html', | ||
fileKey: '', | ||
filePath: '.chromatic/index.html', | ||
formAction: 'https://s3.amazonaws.com', | ||
formFields: {}, | ||
localPath: expect.any(String), | ||
targetPath: '.chromatic/index.html', | ||
contentLength: expect.any(Number), | ||
contentType: 'text/html', | ||
targetUrl: 'https://cdn.example.com/.chromatic/index.html', | ||
}, | ||
]) | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.