Skip to content

Commit

Permalink
Merge pull request #1780 from danskernesdigitalebibliotek/ddfher-94-u…
Browse files Browse the repository at this point in the history
…pdate-webmaster-modules-2

Ddfher 94 update webmaster modules 2
  • Loading branch information
xendk authored Nov 22, 2024
2 parents 069a6d9 + 4701142 commit 3b9ff15
Show file tree
Hide file tree
Showing 192 changed files with 1,732 additions and 1,349 deletions.
16 changes: 16 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"overrides": [
{
"files": ["*.css"],
"options": {
"parser": "css",
"printWidth": 10000,
"singleQuote": false
}
}
]
}
4 changes: 3 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ tasks:
dev:build:
summary: Build docker containers
# Ensure that we only rebuild if there are changes to Dockerfiles
# or the config files used.
sources:
- "{{ .LAGOON_DIR }}/*.dockerfile"
- "{{ .LAGOON_DIR }}/**/*"
- "{{ .LAGOON_DIR }}/*"
cmds:
- docker compose build

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@
},
"scripts": {
"post-drupal-scaffold-cmd": [
"[[ ! -d /app/web/sites/default/files/modules_local ]] && mkdir -p /app/web/sites/default/files/modules_local || exit 0",
"[[ ! -L /app/web/modules/local ]] && ln -s /app/web/sites/default/files/modules_local /app/web/modules/local || exit 0"
"[ ! -d web/sites/default/files/modules_local ] && mkdir -p web/sites/default/files/modules_local || exit 0",
"[ ! -L web/modules/local ] && ln -s web/sites/default/files/modules_local web/modules/local || exit 0"
]
},
"extra": {
Expand Down Expand Up @@ -297,7 +297,6 @@
"Add item count and url page parameter": "patches/add-item-count-views_infinite_scroll.patch"
},
"drupal/core": {
"Configure core to not check permissions before accepting an updated module": "patches/disable-core-upload-permission-check.diff",
"2280639: Add the FieldStorageDefinition class to define field storage definitions in hook_entity_field_storage_info()": "https://www.drupal.org/files/issues/2023-09-05/2280639-d10-reroll-156.patch",
"3402656: Toolbar causes a Javascript error if the subtrees content changes between page loads": "https://git.drupalcode.org/issue/drupal-3402656/-/commit/61ac007a84014f54a07825f8f92bb6bc0dfbd170.patch",
"3035578: Add details for AJAX response errors": "https://www.drupal.org/files/issues/2023-07-24/3035578-26.patch",
Expand Down
2 changes: 1 addition & 1 deletion 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/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module:
dpl_update: 0
dpl_url_proxy: 0
dpl_webform: 0
dpl_webmaster: 0
drupal_typed: 0
dynamic_entity_reference: 0
dynamic_page_cache: 0
Expand Down
134 changes: 67 additions & 67 deletions cypress/e2e/adgangsplatformen.cy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
describe("Adgangsplatformen", () => {
describe('Adgangsplatformen', () => {
beforeEach(() => {
Cypress.session.clearAllSavedSessions();
});

it("supports login with both uniqueId and CPR attribute", () => {
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60d70030fd1";
const userGuid = "19a4ae39-be07-4db9-a8b7-8bbb29f03da6";
it('supports login with both uniqueId and CPR attribute', () => {
const authorizationCode = '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc';
const accessToken = '447131b0a03fe0421204c54e5c21a60d70030fd1';
const userGuid = '19a4ae39-be07-4db9-a8b7-8bbb29f03da6';
const userCPR = 9999999999;

cy.adgangsplatformenLogin({
Expand All @@ -15,150 +15,150 @@ describe("Adgangsplatformen", () => {
userCPR,
userGuid,
});
cy.visit("/user");
cy.url().should("match", /user\/\d+/);
cy.visit('/user');
cy.url().should('match', /user\/\d+/);
});

it("supports login for user with only CPR attribute.", () => {
it('supports login for user with only CPR attribute.', () => {
// If a user does not have uniqueId attribute, it is a user not previously related to any library.
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60-new-user";
const authorizationCode = '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc';
const accessToken = '447131b0a03fe0421204c54e5c21a60-new-user';
const userCPR = 9999999999;

cy.adgangsplatformenLogin({
authorizationCode,
accessToken,
userCPR,
});
cy.visit("/user");
cy.url().should("match", /user\/\d+/);
cy.visit('/user');
cy.url().should('match', /user\/\d+/);
});

it("supports login for user only with uniqueId attribute.", () => {
it('supports login for user only with uniqueId attribute.', () => {
// If a user do not have a CPR attribute, it is probably a test user.
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60-new-user";
const userGuid = "19a4ae39-be07-4db9-a8b7-8bbb29f03da6";
const authorizationCode = '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc';
const accessToken = '447131b0a03fe0421204c54e5c21a60-new-user';
const userGuid = '19a4ae39-be07-4db9-a8b7-8bbb29f03da6';

cy.adgangsplatformenLogin({
authorizationCode,
accessToken,
userGuid,
});
cy.visit("/user");
cy.url().should("match", /user\/\d+/);
cy.visit('/user');
cy.url().should('match', /user\/\d+/);
});

// TODO: Figure out how to check failed logins when using cy.session().
it.skip("does not support login with users missing both uniqueId and CPR attribute.", () => {
it.skip('does not support login with users missing both uniqueId and CPR attribute.', () => {
// If a user do not have a CPR attribute, it is probably a test user.
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60-new-user";
const authorizationCode = '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc';
const accessToken = '447131b0a03fe0421204c54e5c21a60-new-user';

cy.adgangsplatformenLogin({
authorizationCode,
accessToken,
});
cy.contains(
"body",
"The website encountered an unexpected error. Please try again later."
'body',
'The website encountered an unexpected error. Please try again later.',
);
});

// When a user comes back from authentication with MitID, the user should
// not be able to do anything else other than registering or cancelling.
// Check that the header and footer sections is not vissible.
it("does not show header and footer section for unregistered user", () => {
it('does not show header and footer section for unregistered user', () => {
cy.setupAdgangsplatformenRegisterMappinngs({
authorizationCode: "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc",
accessToken: "447131b0a03fe0421204c54e5c21a60-new-user",
authorizationCode: '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc',
accessToken: '447131b0a03fe0421204c54e5c21a60-new-user',
userCPR: 1412749999,
});

cy.clearCookies();
cy.visit("/arrangementer");
cy.visit('/arrangementer');
// Open user menu.
cy.getBySel("header-menu-profile-button").click();
cy.getBySel('header-menu-profile-button').click();
// Click create profile.
cy.get(".modal-login__btn-create-profile").click();
cy.get("main#main-content")
.get(".paragraphs__item--user_registration_section__link")
cy.get('.modal-login__btn-create-profile').click();
cy.get('main#main-content')
.get('.paragraphs__item--user_registration_section__link')
.first()
.click();

cy.verifyToken({
tokenType: "unregistered-user",
token: "447131b0a03fe0421204c54e5c21a60-new-user",
tokenType: 'unregistered-user',
token: '447131b0a03fe0421204c54e5c21a60-new-user',
});

cy.get(".header").should("not.exist");
cy.get(".footer").should("not.exist");
cy.get('.header').should('not.exist');
cy.get('.footer').should('not.exist');
});

it("can register a new user - expose the right tokens for the react apps - and force logout.", () => {
it('can register a new user - expose the right tokens for the react apps - and force logout.', () => {
cy.setupAdgangsplatformenRegisterMappinngs({
authorizationCode: "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc",
accessToken: "447131b0a03fe0421204c54e5c21a60-new-user",
authorizationCode: '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc',
accessToken: '447131b0a03fe0421204c54e5c21a60-new-user',
userCPR: 1412749999,
});

cy.clearCookies();
cy.visit("/arrangementer");
cy.getBySel("header-menu-profile-button").click();
cy.get(".modal-login__btn-create-profile").click();
cy.get("main#main-content")
.get(".paragraphs__item--user_registration_section__link")
cy.visit('/arrangementer');
cy.getBySel('header-menu-profile-button').click();
cy.get('.modal-login__btn-create-profile').click();
cy.get('main#main-content')
.get('.paragraphs__item--user_registration_section__link')
.first()
.click();
cy.verifyToken({
tokenType: "unregistered-user",
token: "447131b0a03fe0421204c54e5c21a60-new-user",
tokenType: 'unregistered-user',
token: '447131b0a03fe0421204c54e5c21a60-new-user',
});

cy.get('[data-cy="phone-input"]').type("12345678");
cy.get('[data-cy="email-address-input"]').type("[email protected]");
cy.get('[data-cy="pincode-input"]').type("1234");
cy.get('[data-cy="pincode-confirm-input"]').type("1234");
cy.get("#branches-dropdown").select("DK-775100");
cy.get('[data-cy="phone-input"]').type('12345678');
cy.get('[data-cy="email-address-input"]').type('[email protected]');
cy.get('[data-cy="pincode-input"]').type('1234');
cy.get('[data-cy="pincode-confirm-input"]').type('1234');
cy.get('#branches-dropdown').select('DK-775100');
cy.get('[data-cy="complete-user-registration-button"]').click();
cy.get('[data-cy="button"]').click();
cy.origin("login.bib.dk", () => {
cy.url().should("to.match", /^https:\/\/login.bib.dk\/logout\?.*/);
cy.origin('login.bib.dk', () => {
cy.url().should('to.match', /^https:\/\/login.bib.dk\/logout\?.*/);
cy.url().should(
"to.match",
/.*redirect_uri=.*\/login%3Fcurrent-path%3D\/velkommen.*/
'to.match',
/.*redirect_uri=.*\/login%3Fcurrent-path%3D\/velkommen.*/,
);
});
});

it("can cancel user registration from the user registration page", () => {
it('can cancel user registration from the user registration page', () => {
cy.setupAdgangsplatformenRegisterMappinngs({
authorizationCode: "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc",
accessToken: "447131b0a03fe0421204c54e5c21a60-new-user",
authorizationCode: '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc',
accessToken: '447131b0a03fe0421204c54e5c21a60-new-user',
userCPR: 1412749999,
});

cy.clearCookies();
cy.visit("/arrangementer");
cy.getBySel("header-menu-profile-button").click();
cy.get(".modal-login__btn-create-profile").click();
cy.get("main#main-content")
.get(".paragraphs__item--user_registration_section__link")
cy.visit('/arrangementer');
cy.getBySel('header-menu-profile-button').click();
cy.get('.modal-login__btn-create-profile').click();
cy.get('main#main-content')
.get('.paragraphs__item--user_registration_section__link')
.first()
.click();
cy.verifyToken({
tokenType: "unregistered-user",
token: "447131b0a03fe0421204c54e5c21a60-new-user",
tokenType: 'unregistered-user',
token: '447131b0a03fe0421204c54e5c21a60-new-user',
});

cy.get('[data-cy="cancel-user-registration-button"]').click();

cy.request("/dpl-react/user-tokens").then((response) => {
cy.request('/dpl-react/user-tokens').then((response) => {
expect(response.body).not.contain(
'window.dplReact = window.dplReact || {};\nwindow.dplReact.setToken("user", "447131b0a03fe0421204c54e5c21a60-new-user")'
'window.dplReact = window.dplReact || {};\nwindow.dplReact.setToken("user", "447131b0a03fe0421204c54e5c21a60-new-user")',
);
expect(response.body).not.contain(
'window.dplReact = window.dplReact || {};\nwindow.dplReact.setToken("unregistered-user", "447131b0a03fe0421204c54e5c21a60-new-user")'
'window.dplReact = window.dplReact || {};\nwindow.dplReact.setToken("unregistered-user", "447131b0a03fe0421204c54e5c21a60-new-user")',
);
});
});
Expand Down
Loading

0 comments on commit 3b9ff15

Please sign in to comment.