Skip to content

Commit

Permalink
Merge pull request #1409 from danskernesdigitalebibliotek/purge-3.6-d…
Browse files Browse the repository at this point in the history
…isable-cli

Purge 3.6.0 / Disable the late runtime processor when using CLI
  • Loading branch information
kasperg authored Aug 12, 2024
2 parents 503aa78 + c584e06 commit d4599bd
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ tasks:
dev:enable-dev-tools:
desc: Enable dev modules and settings, which are not to be used in Prod. They are config-ignored
cmds:
- task dev:cli -- drush install -y devel dpl_example_content field_ui restui uuid_url views_ui dblog
- task dev:cli -- drush install -y devel dpl_example_content field_ui purge_ui restui uuid_url views_ui dblog

dev:enable-xdebug:
desc: "Enable xdebug within the container."
Expand Down
1 change: 1 addition & 0 deletions assets/all.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'dpl_example_breadcrumb',
'devel',
'field_ui',
'purge_ui',
'views_ui',
'restui',
'upgrade_status',
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"drupal/password_policy": "^4.0",
"drupal/pathauto": "^1.12",
"drupal/potion": "dev-2.x#e48d6ee336d960b9d2efb5d88e68402db6d229a6",
"drupal/purge": "^3.2",
"drupal/purge": "^3.6",
"drupal/recurring_events": "^2.0@RC",
"drupal/redirect": "^1.9",
"drupal/redis": "^1.7",
Expand Down Expand Up @@ -350,8 +350,8 @@
"3413314: Include .links.menu.yml files in YamlExtractor.php": "https://www.drupal.org/files/issues/2024-01-08/potion-add_links_menu_yml_title_and_description_to_yaml_extractor-3413314-3.patch"
},
"drupal/purge": {
"3391383: Uninstalling module triggers ServiceNotFoundException exception": "https://git.drupalcode.org/project/purge/-/commit/88546a6e6c043f10832be43e02ae4ae65cf5ceb2.patch",
"Combat NoCorrespondingEntityClassException": "patches/purge-5340bcf-combat-nocorresponding-entity-exception.patch"
"Combat NoCorrespondingEntityClassException": "patches/purge-5340bcf-combat-nocorresponding-entity-exception.patch",
"3462078: Disabling late runtime processor when using CLI": "https://git.drupalcode.org/project/purge/-/commit/14c09e0ec4f1f46df0f19876ad6b3e8c93921e00.patch"
},
"drupal/recurring_events": {
"3178696: Make compatible with Scheduler": "https://git.drupalcode.org/project/recurring_events/-/merge_requests/86.patch",
Expand Down
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/sync/purge_processor_lateruntime.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cli_disable: true
10 changes: 2 additions & 8 deletions cypress/e2e/campaign.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@ describe("Campaign creation and endpoint", () => {
});

before(() => {
// Login as admin.
cy.clearCookies();
cy.drupalLogin();

// Create campaigns.
Expand All @@ -298,13 +296,10 @@ describe("Campaign creation and endpoint", () => {
createRankingAndCampaign();
createRankingOrCampaign();

// Logout (obviously).
cy.drupalLogout();
cy.anonymousUser();
});

after(() => {
// Login as admin.
cy.clearCookies();
cy.drupalLogin();

// Delete campaigns.
Expand All @@ -313,8 +308,7 @@ describe("Campaign creation and endpoint", () => {
deleteCampaign(campaigns.rankingAndCampaign);
deleteCampaign(campaigns.rankingOrCampaign);

// Logout (obviously).
cy.drupalLogout();
cy.anonymousUser();
});

beforeEach(() => {
Expand Down
95 changes: 95 additions & 0 deletions cypress/e2e/varnish.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import "cypress-if";

const node = {
title: "Varnish test",
subtitle: "A subtitle",
path: "/articles/varnish-test",
};

const varnishCacheHeader = "x-varnish-cache";

describe("Varnish", () => {
it("is caching responses for anonymous users", () => {
cy.anonymousUser();
// Query the front page twice to ensure that Varnish has had a chance to
// cache the response.
cy.request("/");
cy.request("/").then((response) => {
cy.log("Headers", response.headers);
expect(response.headers).to.have.property(varnishCacheHeader, "HIT");
});
});

it("is purged when updating content", () => {
// Create a node as admin.
cy.drupalLogin("/node/add/article");
cy.findByLabelText("Title").type(node.title);
cy.findByRole("button", { name: "Save" }).click();
cy.contains(node.title);
cy.should("not.contain", node.subtitle);
// We do not have a good way to store the current path between tests so
// instead we ensure that the expected path is correct.
cy.url().should("include", node.path);

// Check that the node is accessible and rendered with the expected content
// for anonymous users.
cy.anonymousUser();
cy.visit(node.path);
cy.contains(node.title);
cy.should("not.contain", node.subtitle);

// Edit the page as admin and ensure that it is updated.
cy.drupalLogin();
cy.visit(node.path);
cy.findByRole("link", {
name: `Edit ${node.title}`,
}).click({
// Use force as the toolbar may cover the Edit link.
force: true,
});
cy.findByLabelText("Subtitle").type(node.subtitle);
cy.findByRole("button", { name: "Save" }).click();
cy.contains(node.title);
cy.contains(node.subtitle);

// Ensure that the cache is purged and update shown immediately to
// anonymous users.
cy.anonymousUser();
cy.request(node.path).then((response) => {
cy.log("Headers", response.headers);
expect(response.headers).to.have.property(varnishCacheHeader, "MISS");
});
cy.visit(node.path);
cy.contains(node.title);
cy.contains(node.subtitle);
});

before(() => {
cy.drupalLogin("/admin/content");
// Delete all preexisting instances of the node.
cy.get("a")
.contains(node.title)
.if()
.each(() => {
// We have to repeat the selector as Cypress will otherwise complain about
// missing references to elements when clicking the page.
cy.findAllByRole("link", { name: node.title }).first().click();
cy.findByRole("link", {
name: `Edit ${node.title}`,
}).click();
cy.findByRole("button", { name: "More actions" })
.click()
.parent()
.findByRole("link", { name: "Delete" })
.click();
cy.findByRole("dialog")
.findByRole("button", { name: "Delete" })
.click();

// Return to the node list to prepare for the next iteration.
cy.visit("/admin/content");
});

cy.anonymousUser();
});
});
25 changes: 17 additions & 8 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,27 @@ Cypress.Commands.add("logRequests", () => {
});

Cypress.Commands.add("drupalLogin", (url?: string) => {
cy.clearCookies();
cy.visit("/user/login");
cy.get('[name="name"]')
.type(Cypress.env("DRUPAL_USERNAME"))
.parent()
.get('[name="pass"]')
.type(Cypress.env("DRUPAL_PASSWORD"));
cy.get('[value="Log in"]').click();
const username = Cypress.env("DRUPAL_USERNAME");
const password = Cypress.env("DRUPAL_PASSWORD");
cy.session({ username, password }, () => {
cy.visit("/user/login");
cy.get('[name="name"]')
.type(username)
.parent()
.get('[name="pass"]')
.type(password);
cy.get('[value="Log in"]').click();
});

if (url) {
cy.visit(url);
}
});

Cypress.Commands.add("anonymousUser", () => {
cy.session("anonymous", () => {});
});

Cypress.Commands.add("drupalLogout", () => {
cy.visit("/logout");
});
Expand Down Expand Up @@ -334,6 +342,7 @@ declare global {
logRequests(): Chainable<null>;
getRequestCount(request: RequestPattern): Chainable<number>;
resetRequests(): Chainable<null>;
anonymousUser(): Chainable<null>;
drupalLogin(url?: string): Chainable<null>;
drupalLogout(): Chainable<null>;
drupalCron(): Chainable<null>;
Expand Down

0 comments on commit d4599bd

Please sign in to comment.