Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
reearth-bot committed Nov 15, 2023
2 parents aefa4d0 + e3ed8c0 commit ef33daa
Show file tree
Hide file tree
Showing 183 changed files with 3,791 additions and 1,576 deletions.
17 changes: 14 additions & 3 deletions server/e2e/gql_storytelling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func fetchSceneForStories(e *httpexpect.Expect, sID string) (GraphQLRequest, *ht
}
}
}
bgColor
}
__typename
}
Expand Down Expand Up @@ -180,11 +181,12 @@ func createStory(e *httpexpect.Expect, sID, name string, index int) (GraphQLRequ
func updateStory(e *httpexpect.Expect, storyID, sID string) (GraphQLRequest, *httpexpect.Value) {
requestBody := GraphQLRequest{
OperationName: "UpdateStory",
Query: `mutation UpdateStory($sceneId: ID!, $storyId: ID!, $title: String!, $index: Int) {
updateStory( input: {sceneId: $sceneId, storyId: $storyId, title: $title, index: $index} ) {
Query: `mutation UpdateStory($sceneId: ID!, $storyId: ID!, $title: String!, $index: Int, $bgColor: String) {
updateStory( input: {sceneId: $sceneId, storyId: $storyId, title: $title, index: $index, bgColor: $bgColor} ) {
story {
id
title
bgColor
__typename
}
__typename
Expand All @@ -195,6 +197,7 @@ func updateStory(e *httpexpect.Expect, storyID, sID string) (GraphQLRequest, *ht
"sceneId": sID,
"title": "test2",
"index": 0,
"bgColor": "newBG",
},
}

Expand Down Expand Up @@ -780,6 +783,14 @@ func TestStoryCRUD(t *testing.T) {
// update story
_, _ = updateStory(e, storyID, sID)

// fetch scene and check story
_, res = fetchSceneForStories(e, sID)
storiesRes = res.Object().
Value("data").Object().
Value("node").Object().
Value("stories").Array()
storiesRes.First().Object().ValueEqual("bgColor", "newBG")

_, _ = deleteStory(e, storyID, sID)
}

Expand Down Expand Up @@ -1037,7 +1048,7 @@ func TestStoryPublishing(t *testing.T) {
_, err = buf.ReadFrom(rc)
assert.NoError(t, err)

pub := regexp.MustCompile(fmt.Sprintf(`{"schemaVersion":1,"id":"%s","publishedAt":".*","property":{"tiles":\[{"id":".*"}]},"plugins":{},"layers":null,"widgets":\[],"widgetAlignSystem":null,"tags":\[],"clusters":\[],"story":{"id":"%s","property":{},"pages":\[{"id":"%s","property":{},"blocks":\[{"id":"%s","property":{"default":{"text":"test value"},"panel":{"padding":{"top":2,"bottom":3,"left":0,"right":1}}},"plugins":null,"extensionId":"%s","pluginId":"%s"}],"swipeable":true,"swipeableLayers":\[],"layers":\[]}]},"nlsLayers":null,"layerStyles":null,"coreSupport":true}`, sID, storyID, pageID, blockID, extensionId, pluginId))
pub := regexp.MustCompile(fmt.Sprintf(`{"schemaVersion":1,"id":"%s","publishedAt":".*","property":{"tiles":\[{"id":".*"}]},"plugins":{},"layers":null,"widgets":\[],"widgetAlignSystem":null,"tags":\[],"clusters":\[],"story":{"id":"%s","property":{},"pages":\[{"id":"%s","property":{},"title":"test","blocks":\[{"id":"%s","property":{"default":{"text":"test value"},"panel":{"padding":{"top":2,"bottom":3,"left":0,"right":1}}},"plugins":null,"extensionId":"%s","pluginId":"%s"}],"swipeable":true,"swipeableLayers":\[],"layers":\[]}],"position":"left","bgColor":""},"nlsLayers":null,"layerStyles":null,"coreSupport":true}`, sID, storyID, pageID, blockID, extensionId, pluginId))
assert.Regexp(t, pub, buf.String())

resString := e.GET("/p/test-alias/data.json").
Expand Down
2 changes: 2 additions & 0 deletions server/gql/storytelling.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Story implements Node {
sceneId: ID!
scene: Scene
panelPosition: Position!
bgColor: String

isBasicAuthActive: Boolean!
basicAuthUsername: String!
Expand Down Expand Up @@ -68,6 +69,7 @@ input UpdateStoryInput {
title: String
index: Int
panelPosition: Position
bgColor: String

# publishment
isBasicAuthActive: Boolean
Expand Down
83 changes: 82 additions & 1 deletion server/internal/adapter/gql/generated.go

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

5 changes: 5 additions & 0 deletions server/internal/adapter/gql/gqlmodel/convert_storytelling.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func ToStory(s *storytelling.Story) *Story {
UpdatedAt: s.UpdatedAt(),
PublishedAt: s.PublishedAt(),
PanelPosition: ToStoryPosition(s.PanelPosition()),
BgColor: ToStoryBgColor(s.BgColor()),

IsBasicAuthActive: s.IsBasicAuthActive(),
BasicAuthUsername: s.BasicAuthUsername(),
Expand Down Expand Up @@ -113,6 +114,10 @@ func ToStoryPosition(v storytelling.Position) Position {
return ""
}

func ToStoryBgColor(bg string) *string {
return &bg
}

func FromStoryPositionRef(v *Position) *storytelling.Position {
if v == nil {
return nil
Expand Down
6 changes: 6 additions & 0 deletions server/internal/adapter/gql/gqlmodel/convert_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func valueInterfaceToGqlValue(v interface{}) interface{} {
North: v2.North,
South: v2.South,
}
case []any:
gqlArray := make([]any, len(v2))
for i, item := range v2 {
gqlArray[i] = valueInterfaceToGqlValue(item)
}
return gqlArray
}
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions server/internal/adapter/gql/gqlmodel/models_gen.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (r *mutationResolver) UpdateStory(ctx context.Context, input gqlmodel.Updat
Title: input.Title,
Index: input.Index,
PanelPosition: gqlmodel.FromStoryPositionRef(input.PanelPosition),
BgColor: input.BgColor,

IsBasicAuthActive: input.IsBasicAuthActive,
BasicAuthUsername: input.BasicAuthUsername,
Expand Down
3 changes: 3 additions & 0 deletions server/internal/infrastructure/mongo/mongodoc/storytelling.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type StorytellingDocument struct {
UpdatedAt time.Time
Index int
PanelPosition string
BgColor string

IsBasicAuthActive bool
BasicAuthUsername string
Expand Down Expand Up @@ -72,6 +73,7 @@ func NewStorytelling(s *storytelling.Story) (*StorytellingDocument, string) {
UpdatedAt: s.UpdatedAt(),
Index: 1,
PanelPosition: string(s.PanelPosition()),
BgColor: s.BgColor(),

IsBasicAuthActive: s.IsBasicAuthActive(),
BasicAuthUsername: s.BasicAuthUsername(),
Expand Down Expand Up @@ -179,6 +181,7 @@ func (d *StorytellingDocument) Model() (*storytelling.Story, error) {
Alias(d.Alias).
Status(storytelling.PublishmentStatus(d.Status)).
PanelPosition(storytelling.Position(d.PanelPosition)).
BgColor(d.BgColor).
PublishedAt(d.PublishedAt).
UpdatedAt(d.UpdatedAt).
Pages(storytelling.NewPageList(pages)).
Expand Down
4 changes: 4 additions & 0 deletions server/internal/usecase/interactor/storytelling.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func (i *Storytelling) Update(ctx context.Context, inp interfaces.UpdateStoryInp
story.SetPanelPosition(*inp.PanelPosition)
}

if inp.BgColor != nil {
story.SetBgColor(*inp.BgColor)
}

oldAlias := story.Alias()
if inp.Alias != nil && *inp.Alias != oldAlias {
if err := story.UpdateAlias(*inp.Alias); err != nil {
Expand Down
1 change: 1 addition & 0 deletions server/internal/usecase/interfaces/story.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type UpdateStoryInput struct {
Title *string
Index *int
PanelPosition *storytelling.Position
BgColor *string

IsBasicAuthActive *bool
BasicAuthUsername *string
Expand Down
Loading

0 comments on commit ef33daa

Please sign in to comment.