-
Notifications
You must be signed in to change notification settings - Fork 86
Improve CLI sync error messages for sites that can't be synced #4202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4983fc8
dd4839a
eab0934
959235f
28bb033
1b86324
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { transformSitesResponse } from '../transform-sites'; | ||
|
|
||
| // WordPress.com only returns options.software_version for Atomic/Jetpack | ||
| // sites. Simple sites — which includes Business plans that have not yet been | ||
| // transferred to Atomic, plus Free/Personal plans — omit it entirely. | ||
| function simpleBusinessSite() { | ||
| return { | ||
| ID: 1, | ||
| name: 'Simple Business', | ||
| URL: 'https://simplebusiness.wordpress.com', | ||
| is_wpcom_atomic: false, | ||
| jetpack: false, | ||
| is_deleted: false, | ||
| is_a8c: false, | ||
| hosting_provider_guess: 'automattic', | ||
| capabilities: { manage_options: true }, | ||
| plan: { | ||
| features: { active: [ 'studio-sync' ] }, | ||
| product_id: 1008, | ||
| product_name_short: 'Business', | ||
| product_slug: 'business-bundle', | ||
| }, | ||
| options: { created_at: '2021-11-17T16:23:55+00:00', wpcom_staging_blog_ids: [] }, | ||
| }; | ||
| } | ||
|
|
||
| function freeSite() { | ||
| return { | ||
| ...simpleBusinessSite(), | ||
| ID: 2, | ||
| name: 'Free', | ||
| URL: 'https://free.wordpress.com', | ||
| plan: { | ||
| features: { active: [] as string[] }, | ||
| product_id: 1, | ||
| product_name_short: 'Free', | ||
| product_slug: 'free_plan', | ||
| is_free: true, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function atomicSite() { | ||
| return { | ||
| ID: 3, | ||
| name: 'Atomic', | ||
| URL: 'https://atomic.wordpress.com', | ||
| is_wpcom_atomic: true, | ||
| jetpack: true, | ||
| is_deleted: false, | ||
| is_a8c: false, | ||
| capabilities: { manage_options: true }, | ||
| plan: { | ||
| features: { active: [ 'studio-sync' ] }, | ||
| product_id: 1008, | ||
| product_name_short: 'Business', | ||
| product_slug: 'business-bundle', | ||
| }, | ||
| options: { | ||
| created_at: '2021-11-17T16:23:55+00:00', | ||
| wpcom_staging_blog_ids: [], | ||
| software_version: '6.5', | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| describe( 'transformSitesResponse', () => { | ||
| it( 'retains Simple sites whose options omit software_version and classifies them', () => { | ||
| const result = transformSitesResponse( [ simpleBusinessSite(), freeSite() ] ); | ||
|
|
||
| expect( result ).toHaveLength( 2 ); | ||
| expect( result.find( ( s ) => s.id === 1 )?.syncSupport ).toBe( 'needs-transfer' ); | ||
| expect( result.find( ( s ) => s.id === 2 )?.syncSupport ).toBe( 'needs-upgrade' ); | ||
| } ); | ||
|
|
||
| it( 'reports software_version as wpVersion when present, undefined when omitted', () => { | ||
| const result = transformSitesResponse( [ atomicSite(), simpleBusinessSite() ] ); | ||
|
|
||
| expect( result.find( ( s ) => s.id === 3 )?.wpVersion ).toBe( '6.5' ); | ||
| expect( result.find( ( s ) => s.id === 1 )?.wpVersion ).toBeUndefined(); | ||
| } ); | ||
| } ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,11 @@ export const sitesEndpointSiteSchema = z.object( { | |
| .object( { | ||
| created_at: z.string(), | ||
| wpcom_staging_blog_ids: z.array( z.number() ), | ||
| software_version: z.string(), | ||
| // WordPress.com only returns software_version for Atomic/Jetpack | ||
| // sites; Simple sites (e.g. Business plans not yet transferred to | ||
| // Atomic, or Free/Personal plans) omit it. Requiring it here would | ||
| // silently drop every Simple site from the synced-sites list. | ||
| software_version: z.string().optional(), | ||
|
Comment on lines
+27
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The list of sites returned should match the existing list returned by the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point on keeping feature parity, but I think this change preserves it. The change is in the shared Earlier, simple sites weren’t deliberately filtered out, it was a schema bug. IMO keeping them in the list is a small UX enhancement. Rather than hiding a site the customer paid for, we surface it as non-syncable with a suggested next step (“enable hosting features” / “upgrade your plan”).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds like a great improvement to me, if the next step is clear to the user. Thanks for improving this! |
||
| } ) | ||
| .optional(), | ||
| capabilities: z | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.