mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:37:32 +00:00
feat(cnsl): docs link can be customized and custom button is available (#7840)
* feat: customize doc link and additional custom link * feat: add e2e tests * fix: update docs * fix: add @peintnermax changes about cache * fix: golangci-lint complains preparation.PrepareCommands --------- Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
104
e2e/cypress/e2e/settings/external-links-settings.cy.ts
Normal file
104
e2e/cypress/e2e/settings/external-links-settings.cy.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { ensureExternalLinksSettingsSet } from 'support/api/external-links-settings';
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
|
||||
describe('instance external link settings', () => {
|
||||
const externalLinkSettingsPath = `/instance?id=privacypolicy`;
|
||||
|
||||
const tosLink = 'https://zitadel.com/docs/legal/terms-of-service';
|
||||
const privacyPolicyLink = 'https://zitadel.com/docs/legal/privacy-policy';
|
||||
const helpLink = '';
|
||||
const supportEmail = '';
|
||||
const customLink = '';
|
||||
const customLinkText = '';
|
||||
const docsLink = 'https://zitadel.com/docs';
|
||||
|
||||
beforeEach(`ensure they are set`, () => {
|
||||
apiAuth().then((apiCallProperties) => {
|
||||
ensureExternalLinksSettingsSet(apiCallProperties, tosLink, privacyPolicyLink, docsLink);
|
||||
cy.visit(externalLinkSettingsPath);
|
||||
});
|
||||
});
|
||||
|
||||
it(`should have default settings`, () => {
|
||||
cy.get('[formcontrolname="tosLink"]').should('value', tosLink);
|
||||
cy.get('[formcontrolname="privacyLink"]').should('value', privacyPolicyLink);
|
||||
cy.get('[formcontrolname="helpLink"]').should('value', helpLink);
|
||||
cy.get('[formcontrolname="supportEmail"]').should('value', supportEmail);
|
||||
cy.get('[formcontrolname="customLink"]').should('value', customLink);
|
||||
cy.get('[formcontrolname="customLinkText"]').should('value', customLinkText);
|
||||
cy.get('[formcontrolname="docsLink"]').should('value', docsLink);
|
||||
});
|
||||
|
||||
it(`should update external links`, () => {
|
||||
cy.get('[formcontrolname="tosLink"]').clear().type('tosLink2');
|
||||
cy.get('[formcontrolname="privacyLink"]').clear().type('privacyLink2');
|
||||
cy.get('[formcontrolname="helpLink"]').clear().type('helpLink');
|
||||
cy.get('[formcontrolname="supportEmail"]').clear().type('support@example.com');
|
||||
cy.get('[formcontrolname="customLink"]').clear().type('customLink');
|
||||
cy.get('[formcontrolname="customLinkText"]').clear().type('customLinkText');
|
||||
cy.get('[formcontrolname="docsLink"]').clear().type('docsLink');
|
||||
cy.get('[data-e2e="save-button"]').click();
|
||||
cy.shouldConfirmSuccess();
|
||||
});
|
||||
|
||||
it(`should return to default values`, () => {
|
||||
cy.get('[formcontrolname="tosLink"]').should('value', tosLink);
|
||||
cy.get('[formcontrolname="privacyLink"]').should('value', privacyPolicyLink);
|
||||
cy.get('[formcontrolname="helpLink"]').should('value', helpLink);
|
||||
cy.get('[formcontrolname="supportEmail"]').should('value', supportEmail);
|
||||
cy.get('[formcontrolname="customLink"]').should('value', customLink);
|
||||
cy.get('[formcontrolname="customLinkText"]').should('value', customLinkText);
|
||||
cy.get('[formcontrolname="docsLink"]').should('value', docsLink);
|
||||
});
|
||||
});
|
||||
|
||||
describe('instance external link settings', () => {
|
||||
const externalLinkSettingsPath = `/org-settings?id=privacypolicy`;
|
||||
|
||||
const tosLink = 'https://zitadel.com/docs/legal/terms-of-service';
|
||||
const privacyPolicyLink = 'https://zitadel.com/docs/legal/privacy-policy';
|
||||
const helpLink = '';
|
||||
const supportEmail = '';
|
||||
const customLink = '';
|
||||
const customLinkText = '';
|
||||
const docsLink = 'https://zitadel.com/docs';
|
||||
|
||||
beforeEach(() => {
|
||||
cy.context().as('ctx');
|
||||
cy.visit(externalLinkSettingsPath);
|
||||
});
|
||||
|
||||
it(`should have default settings`, () => {
|
||||
cy.get('[formcontrolname="tosLink"]').should('value', tosLink);
|
||||
cy.get('[formcontrolname="privacyLink"]').should('value', privacyPolicyLink);
|
||||
cy.get('[formcontrolname="helpLink"]').should('value', helpLink);
|
||||
cy.get('[formcontrolname="supportEmail"]').should('value', supportEmail);
|
||||
cy.get('[formcontrolname="customLink"]').should('value', customLink);
|
||||
cy.get('[formcontrolname="customLinkText"]').should('value', customLinkText);
|
||||
cy.get('[formcontrolname="docsLink"]').should('value', docsLink);
|
||||
});
|
||||
|
||||
it(`should update external links`, () => {
|
||||
cy.get('[formcontrolname="tosLink"]').clear().type('tosLink2');
|
||||
cy.get('[formcontrolname="privacyLink"]').clear().type('privacyLink2');
|
||||
cy.get('[formcontrolname="helpLink"]').clear().type('helpLink');
|
||||
cy.get('[formcontrolname="supportEmail"]').clear().type('support@example.com');
|
||||
cy.get('[formcontrolname="customLink"]').clear().type('customLink');
|
||||
cy.get('[formcontrolname="customLinkText"]').clear().type('customLinkText');
|
||||
cy.get('[formcontrolname="docsLink"]').clear().type('docsLink');
|
||||
cy.get('[data-e2e="save-button"]').click();
|
||||
cy.shouldConfirmSuccess();
|
||||
});
|
||||
|
||||
it(`should return to default values`, () => {
|
||||
cy.get('[data-e2e="reset-button"]').click();
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('[formcontrolname="tosLink"]').should('value', tosLink);
|
||||
cy.get('[formcontrolname="privacyLink"]').should('value', privacyPolicyLink);
|
||||
cy.get('[formcontrolname="helpLink"]').should('value', helpLink);
|
||||
cy.get('[formcontrolname="supportEmail"]').should('value', supportEmail);
|
||||
cy.get('[formcontrolname="customLink"]').should('value', customLink);
|
||||
cy.get('[formcontrolname="customLinkText"]').should('value', customLinkText);
|
||||
cy.get('[formcontrolname="docsLink"]').should('value', docsLink);
|
||||
});
|
||||
});
|
32
e2e/cypress/support/api/external-links-settings.ts
Normal file
32
e2e/cypress/support/api/external-links-settings.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ensureSetting } from './ensure';
|
||||
import { API } from './types';
|
||||
|
||||
export function ensureExternalLinksSettingsSet(api: API, tosLink: string, privacyPolicyLink: string, docsLink: string) {
|
||||
return ensureSetting(
|
||||
api,
|
||||
`${api.adminBaseURL}/policies/privacy`,
|
||||
(body: any) => {
|
||||
const result = {
|
||||
sequence: body.policy?.details?.sequence,
|
||||
id: body.policy.id,
|
||||
entity: null,
|
||||
};
|
||||
|
||||
if (
|
||||
body.policy &&
|
||||
body.policy.tosLink === tosLink &&
|
||||
body.policy.privacyLink === privacyPolicyLink &&
|
||||
body.policy.docsLink === docsLink
|
||||
) {
|
||||
return { ...result, entity: body.policy };
|
||||
}
|
||||
return result;
|
||||
},
|
||||
`${api.adminBaseURL}/policies/privacy`,
|
||||
{
|
||||
tosLink,
|
||||
privacyLink: privacyPolicyLink,
|
||||
docsLink,
|
||||
},
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user