fix: action cacheClass cache not getting revalidation after deleting (#2188)

This commit is contained in:
Matti Nannt
2024-03-05 13:04:36 +01:00
committed by GitHub
parent 45d5980527
commit 09974e1a10
4 changed files with 13 additions and 11 deletions

3
apps/web/.gitignore vendored
View File

@@ -42,4 +42,5 @@ next-env.d.ts
token.json
# Local Uploads
uploads/
uploads/
certificates

View File

@@ -224,7 +224,7 @@ export default function AddNoCodeActionModal({
Cancel
</Button>
<Button variant="darkCTA" type="submit" loading={isCreatingAction}>
Track Action
Create Action
</Button>
</div>
</div>
@@ -275,7 +275,7 @@ export default function AddNoCodeActionModal({
Cancel
</Button>
<Button variant="darkCTA" type="submit" loading={isCreatingAction}>
Track Action
Create Action
</Button>
</div>
</div>

View File

@@ -36,7 +36,7 @@ const createNoCodeActionByCSSSelector = async (
// User fills the CSS Selector to track
await expect(page.locator("[name='noCodeConfig.cssSelector.value']")).toBeVisible();
await page.locator("[name='noCodeConfig.cssSelector.value']").fill(selector);
await page.getByRole("button", { name: "Track Action", exact: true }).click();
await page.getByRole("button", { name: "Create Action", exact: true }).click();
await page.waitForLoadState("networkidle");
await page.waitForTimeout(500);
};
@@ -88,8 +88,8 @@ const createNoCodeActionByPageURL = async (
// User clicks the Test Match button
await page.getByRole("button", { name: "Test Match", exact: true }).click();
// User clicks the Track Action button
await page.getByRole("button", { name: "Track Action", exact: true }).click();
// User clicks the Create Action button
await page.getByRole("button", { name: "Create Action", exact: true }).click();
await page.waitForLoadState("networkidle");
await page.waitForTimeout(500);
};
@@ -127,7 +127,7 @@ const createNoCodeActionByInnerText = async (
// User fills the Inner Text to track
await expect(page.locator("[name='noCodeConfig.innerHtml.value']")).toBeVisible();
await page.locator("[name='noCodeConfig.innerHtml.value']").fill(innerText);
await page.getByRole("button", { name: "Track Action", exact: true }).click();
await page.getByRole("button", { name: "Create Action", exact: true }).click();
await page.waitForLoadState("networkidle");
await page.waitForTimeout(500);
};
@@ -293,7 +293,7 @@ test.describe("Create and Edit Code Action", async () => {
await expect(page.getByLabel("Description")).toBeVisible();
await page.getByLabel("Description").fill(actions.create.code.description);
await page.getByRole("button", { name: "Track Action", exact: true }).click();
await page.getByRole("button", { name: "Create Action", exact: true }).click();
await page.waitForLoadState("networkidle");
await page.waitForTimeout(500);
});

View File

@@ -128,20 +128,21 @@ export const deleteActionClass = async (
validateInputs([environmentId, ZId], [actionClassId, ZId]);
try {
const result = await prisma.actionClass.delete({
const actionClass = await prisma.actionClass.delete({
where: {
id: actionClassId,
},
select,
});
if (result === null) throw new ResourceNotFoundError("Action", actionClassId);
if (actionClass === null) throw new ResourceNotFoundError("Action", actionClassId);
actionClassCache.revalidate({
environmentId,
id: actionClassId,
name: actionClass.name,
});
return result;
return actionClass;
} catch (error) {
throw new DatabaseError(
`Database error when deleting an action with id ${actionClassId} for environment ${environmentId}`