Skip to content

Commit ede1a66

Browse files
committed
add store theme level support tests
1 parent 9ec56c5 commit ede1a66

8 files changed

Lines changed: 69 additions & 170 deletions

File tree

.github copy/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github copy/workflows/ci.yml

Lines changed: 0 additions & 86 deletions
This file was deleted.

.github copy/workflows/lint.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Actions/FetchMainTheme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function handle(ShopModel $shop): array
2424
}');
2525

2626
if ($response['errors']) {
27-
Log::error('Fetching main theme error: ' . json_encode($response['errors']));
27+
Log::error('Fetching main theme error: '.json_encode($response['errors']));
2828

2929
return [];
3030
}

src/Actions/FetchThemeAssets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function handle(ShopModel $shop, string $mainThemeId, array $filenames):
4747
$content = data_get($data, 'body.content');
4848

4949
if ($content === null) {
50-
Log::warning('Theme file body is not text, skipping: '. data_get($data, 'filename', '?'));
50+
Log::warning('Theme file body is not text, skipping: '.data_get($data, 'filename', '?'));
5151

5252
return null;
5353
}

tests/Actions/VerifyThemeSupportTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,51 @@ public function testStoreWithOnlyProductTemplateHasFullSupport(): void
5454
$this->assertEquals(ThemeSupportLevel::FULL, $result);
5555
}
5656

57+
public function testStoreWithOnlyProductTemplateWithoutAppBlockIsUnsupported(): void
58+
{
59+
$this->fakeGraphqlApi(['main_theme', 'theme_with_one_asset', 'theme_with_empty_sections']);
60+
$shop = factory($this->model)->create();
61+
$action = $this->app->make(VerifyThemeSupport::class);
62+
63+
$result = call_user_func(
64+
$action,
65+
$shop->getId()
66+
);
67+
68+
$this->assertNotNull($result);
69+
$this->assertEquals(ThemeSupportLevel::UNSUPPORTED, $result);
70+
}
71+
72+
public function testStoreWithGraphqlTopLevelErrorsIsUnsupported(): void
73+
{
74+
$this->fakeGraphqlApi(['empty_with_error_graphql']);
75+
$shop = factory($this->model)->create();
76+
$action = $this->app->make(VerifyThemeSupport::class);
77+
78+
$result = call_user_func(
79+
$action,
80+
$shop->getId()
81+
);
82+
83+
$this->assertNotNull($result);
84+
$this->assertEquals(ThemeSupportLevel::UNSUPPORTED, $result);
85+
}
86+
87+
public function testStoreWithTemplateContainingJsonComments(): void
88+
{
89+
$this->fakeGraphqlApi(['main_theme', 'theme_with_json_comments_asset', 'theme_with_one_section']);
90+
$shop = factory($this->model)->create();
91+
$action = $this->app->make(VerifyThemeSupport::class);
92+
93+
$result = call_user_func(
94+
$action,
95+
$shop->getId()
96+
);
97+
98+
$this->assertNotNull($result);
99+
$this->assertEquals(ThemeSupportLevel::FULL, $result);
100+
}
101+
57102
public function testStoreWithPartialExtensionSupport(): void
58103
{
59104
$shop = factory($this->model)->create();
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
2+
"errors": [
3+
{
4+
"message": "Could not get access scopes"
5+
}
6+
],
27
"data": {
38
"currentAppInstallation": {
4-
"accessScopes": [],
5-
"userErrors": {
6-
"message": "Could not get access copes"
7-
}
9+
"accessScopes": []
810
}
911
}
1012
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"data": {
3+
"theme": {
4+
"files": {
5+
"nodes": [
6+
{
7+
"filename": "templates/product.json",
8+
"body": {
9+
"content": "/*\n * This file is auto-generated by Shopify. Do not edit directly.\n */\n{\n \"sections\": {\n // main product section\n \"main\": {\n \"type\": \"main-product\",\n \"settings\": {}\n }\n },\n \"order\": [\"main\"]\n}"
10+
}
11+
}
12+
]
13+
}
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)