Skip to content

Commit ffe14c3

Browse files
committed
B2B-2659: Implement GraphQL Resolver Cache for cmsBlocks query
1 parent 465f7e8 commit ffe14c3

File tree

1 file changed

+38
-0
lines changed
  • dev/tests/api-functional/testsuite/Magento/CmsGraphQl/Model/Resolver

1 file changed

+38
-0
lines changed

dev/tests/api-functional/testsuite/Magento/CmsGraphQl/Model/Resolver/BlockTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,44 @@ public function testCmsBlockResolverCacheInvalidatesWhenBlockGetsDeleted()
167167
);
168168
}
169169

170+
/**
171+
* @magentoDataFixture Magento/Cms/_files/blocks.php
172+
*/
173+
public function testCmsBlockResolverCacheInvalidatesWhenBlockGetsDisabled()
174+
{
175+
$block = $this->blockRepository->getById('enabled_block');
176+
177+
$query = $this->getQuery([
178+
$block->getIdentifier(),
179+
]);
180+
181+
$response = $this->graphQlQueryWithResponseHeaders($query);
182+
183+
$cacheIdentityString = $this->getResolverCacheKeyFromResponseAndBlocks($response, [$block]);
184+
185+
$cacheEntry = $this->graphqlCache->load($cacheIdentityString);
186+
$cacheEntryDecoded = json_decode($cacheEntry, true);
187+
188+
$this->assertEqualsCanonicalizing(
189+
$this->generateExpectedDataFromBlocks([$block]),
190+
$cacheEntryDecoded
191+
);
192+
193+
$this->assertTagsByCacheIdentityAndBlocks(
194+
$cacheIdentityString,
195+
[$block]
196+
);
197+
198+
// assert that cache is invalidated after block disablement
199+
$block->setIsActive(false);
200+
$this->blockRepository->save($block);
201+
202+
$this->assertFalse(
203+
$this->graphqlCache->test($cacheIdentityString),
204+
'Cache entry should be invalidated after block disablement'
205+
);
206+
}
207+
170208
/**
171209
* @magentoDataFixture Magento/Cms/_files/block.php
172210
* @magentoDataFixture Magento/Store/_files/second_store.php

0 commit comments

Comments
 (0)