Skip to content

Commit e70371b

Browse files
committed
B2B-2530: Unskip GraphQL cache tests skipped due to DEVOPS-4924
- Added review comments fixes
1 parent f2db9aa commit e70371b

File tree

5 files changed

+74
-48
lines changed

5 files changed

+74
-48
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/CacheTagTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,22 @@ private function getProductQuery(string $productSku): string
155155
*/
156156
private function getCategoryQuery(): string
157157
{
158-
$categoryId = 4;
159-
$pageSize = 10;
160-
$currentPage = 1;
161158
$categoryQueryString = <<<QUERY
162159
query {
163-
category(id: $categoryId) {
160+
category(id: 4) {
164161
id
165162
description
166163
name
167164
product_count
168-
products(pageSize: $pageSize, currentPage: $currentPage) {
165+
products(pageSize: 10, currentPage: 1) {
169166
items {
170167
id
171168
name
172169
url_key
173170
}
174171
total_count
175172
}
176-
}
173+
}`
177174
}
178175
QUERY;
179176
return $categoryQueryString;

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/Cms/BlockCacheTest.php

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ public function testCacheIsUsedOnSecondRequest()
3636
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
3737
$this->assertCacheMissAndReturnResponse($query, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
3838
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
39-
$responseAfterUpdate = $this->assertCacheHitAndReturnResponse(
39+
$responseHit = $this->assertCacheHitAndReturnResponse(
4040
$query,
4141
[CacheIdCalculator::CACHE_ID_HEADER => $cacheId]
4242
);
4343

4444
//cached data should be correct
45-
$this->assertNotEmpty($responseAfterUpdate['body']);
46-
$this->assertArrayNotHasKey('errors', $responseAfterUpdate['body']);
47-
$blocks = $responseAfterUpdate['body']['cmsBlocks']['items'];
45+
$this->assertNotEmpty($responseHit['body']);
46+
$this->assertArrayNotHasKey('errors', $responseHit['body']);
47+
$blocks = $responseHit['body']['cmsBlocks']['items'];
4848
$this->assertEquals($blockIdentifier, $blocks[0]['identifier']);
4949
$this->assertEquals('CMS Block Title', $blocks[0]['title']);
5050
}
@@ -66,43 +66,61 @@ public function testCacheIsInvalidatedOnBlockUpdate()
6666
//cache-debug should be a MISS on first request and HIT on second request
6767
$fixtureBlock = $this->graphQlQueryWithResponseHeaders($fixtureBlockQuery);
6868
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $fixtureBlock['headers']);
69-
$cacheId = $fixtureBlock['headers'][CacheIdCalculator::CACHE_ID_HEADER];
69+
$cacheIdOfFixtureBlock = $fixtureBlock['headers'][CacheIdCalculator::CACHE_ID_HEADER];
7070
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
71-
$this->assertCacheMissAndReturnResponse($fixtureBlockQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
71+
$this->assertCacheMissAndReturnResponse(
72+
$fixtureBlockQuery,
73+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdOfFixtureBlock]
74+
);
7275

7376
$enabledBlock = $this->graphQlQueryWithResponseHeaders($enabledBlockQuery);
7477
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $enabledBlock['headers']);
75-
$cacheId = $enabledBlock['headers'][CacheIdCalculator::CACHE_ID_HEADER];
78+
$cacheIdOfEnabledBlock = $enabledBlock['headers'][CacheIdCalculator::CACHE_ID_HEADER];
7679
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
77-
$this->assertCacheMissAndReturnResponse($enabledBlockQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
80+
$this->assertCacheMissAndReturnResponse(
81+
$enabledBlockQuery,
82+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdOfEnabledBlock]
83+
);
7884

7985
//cache should be a HIT on second request
8086
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
81-
$this->assertCacheHitAndReturnResponse($fixtureBlockQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
87+
$this->assertCacheHitAndReturnResponse(
88+
$fixtureBlockQuery,
89+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdOfFixtureBlock]
90+
);
8291
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
83-
$this->assertCacheHitAndReturnResponse($enabledBlockQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
92+
$this->assertCacheHitAndReturnResponse(
93+
$enabledBlockQuery,
94+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdOfEnabledBlock]
95+
);
8496

8597
$newBlockContent = 'New block content!!!';
8698
$this->updateBlockContent($fixtureBlockIdentifier, $newBlockContent);
8799

88100
//cache-debug should be a MISS after update the block on fixture block query
89101
$fixtureBlockAfterUpdate = $this->graphQlQueryWithResponseHeaders($fixtureBlockQuery);
90102
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $fixtureBlock['headers']);
91-
$cacheId = $fixtureBlockAfterUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
103+
$cacheIdOfFixtureBlockAfterUpdate = $fixtureBlockAfterUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
92104
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
93-
$this->assertCacheMissAndReturnResponse($fixtureBlockQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
105+
$fixtureBlockHitResponse = $this->assertCacheMissAndReturnResponse(
106+
$fixtureBlockQuery,
107+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdOfFixtureBlockAfterUpdate]
108+
);
94109

95110
//cache-debug should be a HIT after update the block on enabled block query
96111
$enabledBlockAfterUpdate = $this->graphQlQueryWithResponseHeaders($enabledBlockQuery);
97112
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $enabledBlock['headers']);
98-
$cacheId = $enabledBlockAfterUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
113+
$cacheIdOfEnabledBlockAfterUpdate = $enabledBlockAfterUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
99114
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
100-
$this->assertCacheHitAndReturnResponse($enabledBlockQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
115+
$this->assertCacheHitAndReturnResponse(
116+
$enabledBlockQuery,
117+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdOfEnabledBlockAfterUpdate]
118+
);
101119

102120
//updated block data should be correct on fixture block
103-
$this->assertNotEmpty($fixtureBlockAfterUpdate['body']);
104-
$blocks = $fixtureBlockAfterUpdate['body']['cmsBlocks']['items'];
105-
$this->assertArrayNotHasKey('errors', $fixtureBlockAfterUpdate['body']);
121+
$this->assertNotEmpty($fixtureBlockHitResponse['body']);
122+
$blocks = $fixtureBlockHitResponse['body']['cmsBlocks']['items'];
123+
$this->assertArrayNotHasKey('errors', $fixtureBlockHitResponse['body']);
106124
$this->assertEquals($fixtureBlockIdentifier, $blocks[0]['identifier']);
107125
$this->assertEquals('CMS Block Title', $blocks[0]['title']);
108126
$this->assertEquals($newBlockContent, $blocks[0]['content']);

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/Cms/PageCacheTest.php

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public function testCacheIsUsedOnSecondRequest()
5252
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
5353
$this->assertCacheMissAndReturnResponse($query, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
5454
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
55-
$responseAfterUpdate = $this->assertCacheHitAndReturnResponse(
55+
$responseHit = $this->assertCacheHitAndReturnResponse(
5656
$query,
5757
[CacheIdCalculator::CACHE_ID_HEADER => $cacheId]
5858
);
5959

6060
//cached data should be correct
61-
$this->assertNotEmpty($responseAfterUpdate['body']);
62-
$this->assertArrayNotHasKey('errors', $responseAfterUpdate['body']);
63-
$pageData = $responseAfterUpdate['body']['cmsPage'];
61+
$this->assertNotEmpty($responseHit['body']);
62+
$this->assertArrayNotHasKey('errors', $responseHit['body']);
63+
$pageData = $responseHit['body']['cmsPage'];
6464
$this->assertEquals('Cms Page 100', $pageData['title']);
6565
}
6666

@@ -85,20 +85,32 @@ public function testCacheIsInvalidatedOnPageUpdate()
8585
//cache-debug should be a MISS on first request
8686
$page100Response = $this->graphQlQueryWithResponseHeaders($page100Query);
8787
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $page100Response['headers']);
88-
$cacheId = $page100Response['headers'][CacheIdCalculator::CACHE_ID_HEADER];
88+
$cacheIdPage100Response = $page100Response['headers'][CacheIdCalculator::CACHE_ID_HEADER];
8989
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
90-
$this->assertCacheMissAndReturnResponse($page100Query, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
90+
$this->assertCacheMissAndReturnResponse(
91+
$page100Query,
92+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdPage100Response]
93+
);
9194

9295
$pageBlankResponse = $this->graphQlQueryWithResponseHeaders($pageBlankQuery);
9396
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $pageBlankResponse['headers']);
94-
$cacheId = $pageBlankResponse['headers'][CacheIdCalculator::CACHE_ID_HEADER];
97+
$cacheIdPageBlankResponse = $pageBlankResponse['headers'][CacheIdCalculator::CACHE_ID_HEADER];
9598
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
96-
$this->assertCacheMissAndReturnResponse($pageBlankQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
99+
$this->assertCacheMissAndReturnResponse(
100+
$pageBlankQuery,
101+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdPageBlankResponse]
102+
);
97103

98104
//cache-debug should be a HIT on second request
99-
$this->assertCacheHitAndReturnResponse($page100Query, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
105+
$this->assertCacheHitAndReturnResponse(
106+
$page100Query,
107+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdPage100Response]
108+
);
100109
//cache-debug should be a HIT on second request
101-
$this->assertCacheHitAndReturnResponse($pageBlankQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
110+
$this->assertCacheHitAndReturnResponse(
111+
$pageBlankQuery,
112+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdPageBlankResponse]
113+
);
102114

103115
$pageRepository = Bootstrap::getObjectManager()->get(PageRepository::class);
104116
$newPageContent = 'New page content for blank page.';
@@ -108,17 +120,24 @@ public function testCacheIsInvalidatedOnPageUpdate()
108120
//cache-debug should be a MISS after updating the page
109121
$pageBlankResponseMissAfterUpdate = $this->graphQlQueryWithResponseHeaders($pageBlankQuery);
110122
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $pageBlankResponseMissAfterUpdate['headers']);
111-
$cacheId = $pageBlankResponseMissAfterUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
123+
$cacheIdPageBlankResponseMissAfterUpdate =
124+
$pageBlankResponseMissAfterUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
112125
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
113-
$this->assertCacheMissAndReturnResponse($pageBlankQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
126+
$this->assertCacheMissAndReturnResponse(
127+
$pageBlankQuery,
128+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdPageBlankResponseMissAfterUpdate]
129+
);
114130

115131
$page100ResponseHitAfterUpdate = $this->graphQlQueryWithResponseHeaders($page100Query);
116132
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $page100ResponseHitAfterUpdate['headers']);
117-
$cacheId = $page100ResponseHitAfterUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
118-
$this->assertCacheHitAndReturnResponse($page100Query, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
133+
$cacheIdPage100ResponseHitAfterUpdate = $page100ResponseHitAfterUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
134+
$this->assertCacheHitAndReturnResponse(
135+
$page100Query,
136+
[CacheIdCalculator::CACHE_ID_HEADER => $cacheIdPage100ResponseHitAfterUpdate]
137+
);
119138

120139
//updated page data should be correct
121-
$this->assertNotEmpty($pageBlankResponseMissAfterUpdate['body']);
140+
$this->assertNotEmpty($page100ResponseHitAfterUpdate['body']);
122141
$pageData = $pageBlankResponseMissAfterUpdate['body']['cmsPage'];
123142
$this->assertArrayNotHasKey('errors', $pageBlankResponseMissAfterUpdate['body']);
124143
$this->assertEquals('Cms Page Design Blank', $pageData['title']);

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/Quote/Guest/CartCacheTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class CartCacheTest extends GraphQLPageCacheAbstract
1919
{
2020
/**
21-
* Check if the cart is not cached
21+
* @inheritdoc
2222
*
2323
* @magentoConfigFixture default/system/full_page_cache/caching_application 2
2424
*/
@@ -40,9 +40,6 @@ public function testCartIsNotCached()
4040

4141
// Cache debug header value is still a MISS for any subsequent request
4242
// Obtain the X-Magento-Cache-Id from the response which will be used as the cache key
43-
$responseMissNext = $this->graphQlQueryWithResponseHeaders($getCartQuery);
44-
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $responseMissNext['headers']);
45-
$cacheId = $responseMissNext['headers'][CacheIdCalculator::CACHE_ID_HEADER];
4643
// Verify we obtain a cache MISS the second time we search the cache using this X-Magento-Cache-Id
4744
$this->assertCacheMissAndReturnResponse($getCartQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
4845
}

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/UrlRewrite/UrlResolverCacheTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Magento\TestFramework\Helper\Bootstrap;
1515

1616
/**
17-
* Test cache invalidation for url resolver.
17+
* Test cache works for url resolver.
1818
*/
1919
class UrlResolverCacheTest extends GraphQLPageCacheAbstract
2020
{
@@ -134,11 +134,6 @@ public function testCacheIsInvalidatedForUrlResolver()
134134
$product = $productRepository->get($productSku, false, null, true);
135135
$product->setUrlKey('p002-new.html')->save();
136136

137-
//cache-debug should be a MISS after updating the url key and accessing the same requestPath or urlKey
138-
$urlResolverQuery = $this->getUrlResolverQuery($urlKey);
139-
$responseMissAfterUrlUpdate = $this->graphQlQueryWithResponseHeaders($urlResolverQuery);
140-
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $responseMissAfterUrlUpdate['headers']);
141-
$cacheId = $responseMissAfterUrlUpdate['headers'][CacheIdCalculator::CACHE_ID_HEADER];
142137
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
143138
$this->assertCacheMissAndReturnResponse($urlResolverQuery, [CacheIdCalculator::CACHE_ID_HEADER => $cacheId]);
144139
}

0 commit comments

Comments
 (0)