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:
Miguel Cabrerizo
2024-05-13 16:01:50 +02:00
committed by GitHub
parent 6942324741
commit 15d5338b91
61 changed files with 1000 additions and 286 deletions

View File

@@ -43,10 +43,13 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
args: args{
ctx: context.Background(),
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
res: res{
@@ -66,7 +69,9 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
"PrivacyLink",
"HelpLink",
"support@example.com",
),
"DocsLink",
"CustomLink",
"CustomLinkText"),
),
),
),
@@ -75,10 +80,13 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
res: res{
@@ -98,6 +106,9 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
"PrivacyLink",
"HelpLink",
"support@example.com",
"DocsLink",
"CustomLink",
"CustomLinkText",
),
),
),
@@ -106,10 +117,13 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
res: res{
@@ -118,10 +132,13 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
AggregateID: "org1",
ResourceOwner: "org1",
},
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
},
@@ -136,10 +153,13 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "wrong email",
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "wrong email",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
res: res{
@@ -159,6 +179,9 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
"",
"",
"",
"",
"",
"",
),
),
),
@@ -167,10 +190,13 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "",
PrivacyLink: "",
HelpLink: "",
SupportEmail: "",
TOSLink: "",
PrivacyLink: "",
HelpLink: "",
SupportEmail: "",
DocsLink: "",
CustomLink: "",
CustomLinkText: "",
},
},
res: res{
@@ -179,10 +205,13 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
AggregateID: "org1",
ResourceOwner: "org1",
},
TOSLink: "",
PrivacyLink: "",
HelpLink: "",
SupportEmail: "",
TOSLink: "",
PrivacyLink: "",
HelpLink: "",
SupportEmail: "",
DocsLink: "",
CustomLink: "",
CustomLinkText: "",
},
},
},
@@ -235,10 +264,13 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
args: args{
ctx: context.Background(),
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
res: res{
@@ -257,10 +289,13 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
res: res{
@@ -280,6 +315,9 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
"PrivacyLink",
"HelpLink",
"support@example.com",
"DocsLink",
"CustomLink",
"CustomLinkText",
),
),
),
@@ -289,10 +327,13 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
TOSLink: "TOSLink",
PrivacyLink: "PrivacyLink",
HelpLink: "HelpLink",
SupportEmail: "support@example.com",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
res: res{
@@ -305,10 +346,13 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLinkChange",
PrivacyLink: "PrivacyLinkChange",
HelpLink: "HelpLinkChange",
SupportEmail: "wrong email",
TOSLink: "TOSLinkChange",
PrivacyLink: "PrivacyLinkChange",
HelpLink: "HelpLinkChange",
SupportEmail: "wrong email",
DocsLink: "DocsLink",
CustomLink: "CustomLink",
CustomLinkText: "CustomLinkText",
},
},
res: res{
@@ -328,11 +372,14 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
"PrivacyLink",
"HelpLink",
"support@example.com",
"DocsLink",
"CustomLink",
"CustomLinkText",
),
),
),
expectPush(
newPrivacyPolicyChangedEvent(context.Background(), "org1", "TOSLinkChange", "PrivacyLinkChange", "HelpLinkChange", "support2@example.com"),
newPrivacyPolicyChangedEvent(context.Background(), "org1", "TOSLinkChange", "PrivacyLinkChange", "HelpLinkChange", "support2@example.com", "DocsLinkChange", "CustomLinkChange", "CustomLinkTextChange"),
),
),
},
@@ -340,10 +387,13 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "TOSLinkChange",
PrivacyLink: "PrivacyLinkChange",
HelpLink: "HelpLinkChange",
SupportEmail: "support2@example.com",
TOSLink: "TOSLinkChange",
PrivacyLink: "PrivacyLinkChange",
HelpLink: "HelpLinkChange",
SupportEmail: "support2@example.com",
DocsLink: "DocsLinkChange",
CustomLink: "CustomLinkChange",
CustomLinkText: "CustomLinkTextChange",
},
},
res: res{
@@ -352,10 +402,13 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
AggregateID: "org1",
ResourceOwner: "org1",
},
TOSLink: "TOSLinkChange",
PrivacyLink: "PrivacyLinkChange",
HelpLink: "HelpLinkChange",
SupportEmail: "support2@example.com",
TOSLink: "TOSLinkChange",
PrivacyLink: "PrivacyLinkChange",
HelpLink: "HelpLinkChange",
SupportEmail: "support2@example.com",
DocsLink: "DocsLinkChange",
CustomLink: "CustomLinkChange",
CustomLinkText: "CustomLinkTextChange",
},
},
},
@@ -372,11 +425,14 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
"PrivacyLink",
"HelpLink",
"support@example.com",
"DocsLink",
"CustomLink",
"CustomLinkText",
),
),
),
expectPush(
newPrivacyPolicyChangedEvent(context.Background(), "org1", "", "", "", ""),
newPrivacyPolicyChangedEvent(context.Background(), "org1", "", "", "", "", "", "", ""),
),
),
},
@@ -384,10 +440,13 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
ctx: context.Background(),
orgID: "org1",
policy: &domain.PrivacyPolicy{
TOSLink: "",
PrivacyLink: "",
HelpLink: "",
SupportEmail: "",
TOSLink: "",
PrivacyLink: "",
HelpLink: "",
SupportEmail: "",
DocsLink: "",
CustomLink: "",
CustomLinkText: "",
},
},
res: res{
@@ -396,10 +455,13 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
AggregateID: "org1",
ResourceOwner: "org1",
},
TOSLink: "",
PrivacyLink: "",
HelpLink: "",
SupportEmail: "",
TOSLink: "",
PrivacyLink: "",
HelpLink: "",
SupportEmail: "",
DocsLink: "",
CustomLink: "",
CustomLinkText: "",
},
},
},
@@ -484,6 +546,9 @@ func TestCommandSide_RemovePrivacyPolicy(t *testing.T) {
"PrivacyLink",
"HelpLink",
"support@example.com",
"DocsLink",
"CustomLink",
"CustomLinkText",
),
),
),
@@ -523,7 +588,7 @@ func TestCommandSide_RemovePrivacyPolicy(t *testing.T) {
}
}
func newPrivacyPolicyChangedEvent(ctx context.Context, orgID string, tosLink, privacyLink, helpLink, supportEmail string) *org.PrivacyPolicyChangedEvent {
func newPrivacyPolicyChangedEvent(ctx context.Context, orgID string, tosLink, privacyLink, helpLink, supportEmail, docsLink, customLink, customLinkText string) *org.PrivacyPolicyChangedEvent {
event, _ := org.NewPrivacyPolicyChangedEvent(ctx,
&org.NewAggregate(orgID).Aggregate,
[]policy.PrivacyPolicyChanges{
@@ -531,6 +596,9 @@ func newPrivacyPolicyChangedEvent(ctx context.Context, orgID string, tosLink, pr
policy.ChangePrivacyLink(privacyLink),
policy.ChangeHelpLink(helpLink),
policy.ChangeSupportEmail(domain.EmailAddress(supportEmail)),
policy.ChangeDocsLink(docsLink),
policy.ChangeCustomLink(customLink),
policy.ChangeCustomLinkText(customLinkText),
},
)
return event