Verified Commit f347bf1c authored by José M. Requena Plens's avatar José M. Requena Plens Committed by GitLab
Browse files

feat(broadcast_messages): add the Color field to BroadcastMessage

Changelog: Improvements
parent ab6093d6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ type BroadcastMessage struct {
	Message            string             `json:"message"`
	StartsAt           *time.Time         `json:"starts_at"`
	EndsAt             *time.Time         `json:"ends_at"`
	Color              string             `json:"color"`
	Font               string             `json:"font"`
	ID                 int64              `json:"id"`
	Active             bool               `json:"active"`
@@ -123,6 +124,7 @@ type CreateBroadcastMessageOptions struct {
	Message            *string            `url:"message" json:"message"`
	StartsAt           *time.Time         `url:"starts_at,omitempty" json:"starts_at,omitempty"`
	EndsAt             *time.Time         `url:"ends_at,omitempty" json:"ends_at,omitempty"`
	Color              *string            `url:"color,omitempty" json:"color,omitempty"`
	Font               *string            `url:"font,omitempty" json:"font,omitempty"`
	TargetAccessLevels []AccessLevelValue `url:"target_access_levels,omitempty" json:"target_access_levels,omitempty"`
	TargetPath         *string            `url:"target_path,omitempty" json:"target_path,omitempty"`
@@ -149,6 +151,7 @@ type UpdateBroadcastMessageOptions struct {
	Message            *string            `url:"message,omitempty" json:"message,omitempty"`
	StartsAt           *time.Time         `url:"starts_at,omitempty" json:"starts_at,omitempty"`
	EndsAt             *time.Time         `url:"ends_at,omitempty" json:"ends_at,omitempty"`
	Color              *string            `url:"color,omitempty" json:"color,omitempty"`
	Font               *string            `url:"font,omitempty" json:"font,omitempty"`
	TargetAccessLevels []AccessLevelValue `url:"target_access_levels,omitempty" json:"target_access_levels,omitempty"`
	TargetPath         *string            `url:"target_path,omitempty" json:"target_path,omitempty"`
+31 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ func TestListBroadcastMessages(t *testing.T) {
		Message:            "Some Message",
		StartsAt:           &wantedFirstStartsAt,
		EndsAt:             &wantedFirstEndsAt,
		Color:              "#E75E40",
		Font:               "#FFFFFF",
		ID:                 1,
		Active:             false,
@@ -85,6 +86,7 @@ func TestListBroadcastMessages(t *testing.T) {
		Message:            "SomeMessage2",
		StartsAt:           &wantedSecondStartsAt,
		EndsAt:             &wantedSecondEndsAt,
		Color:              "#AA33EE",
		Font:               "#224466",
		ID:                 2,
		Active:             true,
@@ -130,6 +132,7 @@ func TestGetBroadcastMessages(t *testing.T) {
		Message:            "Some Message",
		StartsAt:           &wantedStartsAt,
		EndsAt:             &wantedEndsAt,
		Color:              "#E75E40",
		Font:               "#FFFFFF",
		ID:                 1,
		Active:             false,
@@ -151,6 +154,18 @@ func TestCreateBroadcastMessages(t *testing.T) {

	mux.HandleFunc("/api/v4/broadcast_messages", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, http.MethodPost)
		testBodyJSON(t, r, map[string]any{
			"message":              "Some Message",
			"starts_at":            "2017-06-26T06:00:00Z",
			"ends_at":              "2017-06-27T12:59:00Z",
			"color":                "#E75E40",
			"font":                 "#FFFFFF",
			"target_access_levels": []any{float64(10), float64(30)},
			"target_path":          "*/welcome",
			"broadcast_type":       "banner",
			"dismissable":          false,
			"theme":                "indigo",
		})
		fmt.Fprintf(w, `{
			"message": "Some Message",
			"starts_at": "2017-06-26T06:00:00.000Z",
@@ -171,6 +186,7 @@ func TestCreateBroadcastMessages(t *testing.T) {
		Message:            new("Some Message"),
		StartsAt:           &wantedStartsAt,
		EndsAt:             &wantedEndsAt,
		Color:              new("#E75E40"),
		Font:               new("#FFFFFF"),
		TargetAccessLevels: []AccessLevelValue{GuestPermissions, DeveloperPermissions},
		TargetPath:         new("*/welcome"),
@@ -187,6 +203,7 @@ func TestCreateBroadcastMessages(t *testing.T) {
		Message:            "Some Message",
		StartsAt:           &wantedStartsAt,
		EndsAt:             &wantedEndsAt,
		Color:              "#E75E40",
		Font:               "#FFFFFF",
		ID:                 42,
		Active:             false,
@@ -209,6 +226,18 @@ func TestUpdateBroadcastMessages(t *testing.T) {

	mux.HandleFunc("/api/v4/broadcast_messages/1", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, http.MethodPut)
		testBodyJSON(t, r, map[string]any{
			"message":              "Some Message Updated",
			"starts_at":            "2017-06-26T06:00:00Z",
			"ends_at":              "2017-06-27T12:59:00Z",
			"color":                "#E75E40",
			"font":                 "#FFFFFF",
			"target_access_levels": []any{float64(10), float64(30)},
			"target_path":          "*/welcome",
			"broadcast_type":       "banner",
			"dismissable":          false,
			"theme":                "indigo",
		})
		fmt.Fprintf(w, `{
			"message": "Some Message Updated",
			"starts_at": "2017-06-26T06:00:00.000Z",
@@ -229,6 +258,7 @@ func TestUpdateBroadcastMessages(t *testing.T) {
		Message:            new("Some Message Updated"),
		StartsAt:           &wantedStartsAt,
		EndsAt:             &wantedEndsAt,
		Color:              new("#E75E40"),
		Font:               new("#FFFFFF"),
		TargetAccessLevels: []AccessLevelValue{GuestPermissions, DeveloperPermissions},
		TargetPath:         new("*/welcome"),
@@ -245,6 +275,7 @@ func TestUpdateBroadcastMessages(t *testing.T) {
		Message:            "Some Message Updated",
		StartsAt:           &wantedStartsAt,
		EndsAt:             &wantedEndsAt,
		Color:              "#E75E40",
		Font:               "#FFFFFF",
		ID:                 42,
		Active:             false,