@shopify/cli
Version:
A CLI tool to build for the Shopify platform
45 lines • 2.21 kB
JavaScript
import { DoctorSuite } from '@shopify/cli-kit/node/doctor/framework';
/**
* Tests for `shopify theme push` command
*/
class ThemePushTests extends DoctorSuite {
tests() {
this.test('push creates unpublished theme', async () => {
// Check prerequisite: theme must be initialized
if (!this.context.themePath) {
this.assert(false, 'Theme init did not complete successfully; themePath is missing in context');
return;
}
// Build command
const themeName = this.context.themeName ?? 'doctor-theme';
let cmd = `shopify theme push --unpublished --json --path ${this.context.themePath} -t ${themeName}`;
if (this.context.environment) {
cmd += ` -e ${this.context.environment}`;
}
if (this.context.store) {
cmd += ` -s ${this.context.store}`;
}
if (this.context.password) {
cmd += ` --password ${this.context.password}`;
}
const result = await this.run(cmd);
this.assertSuccess(result);
// Parse and validate JSON output
const json = this.assertJson(result, (data) => typeof data.theme?.id === 'number');
if (json?.theme) {
this.assert(typeof json.theme.id === 'number', 'Theme was created with a valid ID');
this.assertEqual(json.theme.role, 'unpublished', 'Theme role is unpublished');
this.assert(json.theme.editor_url.includes('/admin/themes/'), 'Editor URL is provided');
this.assert(json.theme.preview_url.includes('preview_theme_id='), 'Preview URL is provided');
// Update context for subsequent tests
this.context.themeId = String(json.theme.id);
this.context.data.editorUrl = json.theme.editor_url;
this.context.data.previewUrl = json.theme.preview_url;
}
});
}
}
ThemePushTests.description = 'Tests pushing a theme to the store creates an unpublished theme';
ThemePushTests.requiresStore = true;
export default ThemePushTests;
//# sourceMappingURL=push.js.map