Skip to content

Commit 465f7e8

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

File tree

1 file changed

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

1 file changed

+37
-0
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,43 @@ public function testCmsMultipleBlockResolverCacheAndInvalidationAsGuest()
130130
);
131131
}
132132

133+
/**
134+
* @magentoDataFixture Magento/Cms/_files/block.php
135+
*/
136+
public function testCmsBlockResolverCacheInvalidatesWhenBlockGetsDeleted()
137+
{
138+
$block = $this->blockRepository->getById('fixture_block');
139+
140+
$query = $this->getQuery([
141+
$block->getIdentifier(),
142+
]);
143+
144+
$response = $this->graphQlQueryWithResponseHeaders($query);
145+
146+
$cacheIdentityString = $this->getResolverCacheKeyFromResponseAndBlocks($response, [$block]);
147+
148+
$cacheEntry = $this->graphqlCache->load($cacheIdentityString);
149+
$cacheEntryDecoded = json_decode($cacheEntry, true);
150+
151+
$this->assertEqualsCanonicalizing(
152+
$this->generateExpectedDataFromBlocks([$block]),
153+
$cacheEntryDecoded
154+
);
155+
156+
$this->assertTagsByCacheIdentityAndBlocks(
157+
$cacheIdentityString,
158+
[$block]
159+
);
160+
161+
// assert that cache is invalidated after block deletion
162+
$this->blockRepository->delete($block);
163+
164+
$this->assertFalse(
165+
$this->graphqlCache->test($cacheIdentityString),
166+
'Cache entry should be invalidated after block deletion'
167+
);
168+
}
169+
133170
/**
134171
* @magentoDataFixture Magento/Cms/_files/block.php
135172
* @magentoDataFixture Magento/Store/_files/second_store.php

0 commit comments

Comments
 (0)