Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): Projects Recycle bin #1169

Merged
merged 8 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 80 additions & 2 deletions server/e2e/gql_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,84 @@ func TestSortByUpdatedAt(t *testing.T) {

edges.Length().Equal(3)
edges.Element(0).Object().Value("node").Object().Value("name").Equal("project2-test") // 'project2' is first
edges.Element(1).Object().Value("node").Object().Value("name").Equal("project3-test")
edges.Element(2).Object().Value("node").Object().Value("name").Equal("project1-test")
}

// go test -v -run TestDeleteProjects ./e2e/...
hexaforce marked this conversation as resolved.
Show resolved Hide resolved

func TestDeleteProjects(t *testing.T) {

e := StartServer(t, &config.Config{
Origins: []string{"https://example.com"},
AuthSrv: config.AuthSrvConfig{
Disabled: true,
},
}, true, baseSeeder)

createProject(e, "project1-test")
project2ID := createProject(e, "project2-test")
createProject(e, "project3-test")

// Deleted 'project2'
requestBody := GraphQLRequest{
OperationName: "UpdateProject",
Query: `mutation UpdateProject($input: UpdateProjectInput!) {
updateProject(input: $input) {
project {
id
name
isDeleted
updatedAt
__typename
}
__typename
}
}`,
Variables: map[string]any{
"input": map[string]any{
"projectId": project2ID,
"deleted": true,
},
},
}

e.POST("/api/graphql").
WithHeader("Origin", "https://example.com").
WithHeader("X-Reearth-Debug-User", uID.String()).
WithHeader("Content-Type", "application/json").
WithJSON(requestBody).
Expect().
Status(http.StatusOK).
JSON()

// check
requestBody = GraphQLRequest{
OperationName: "GetDeletedProjects",
Query: `
query GetDeletedProjects($teamId: ID!) {
deletedProjects(teamId: $teamId) {
nodes {
id
name
isDeleted
}
totalCount
}
}`,
Variables: map[string]any{
"teamId": wID,
},
}
deletedProjects := e.POST("/api/graphql").
WithHeader("Origin", "https://example.com").
WithHeader("X-Reearth-Debug-User", uID.String()).
WithHeader("Content-Type", "application/json").
WithJSON(requestBody).
Expect().
Status(http.StatusOK).
JSON().
Object().Value("data").Object().Value("deletedProjects").Object()

deletedProjects.Value("totalCount").Equal(1)
deletedProjects.Value("nodes").Array().Length().Equal(1)
deletedProjects.Value("nodes").Array().First().Object().Value("name").Equal("project2-test")
}
6 changes: 4 additions & 2 deletions server/gql/project.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Project implements Node {
enableGa: Boolean!
trackingId: String!
starred: Boolean!
isDeleted: Boolean!
hexaforce marked this conversation as resolved.
Show resolved Hide resolved
}

type ProjectAliasAvailability {
Expand Down Expand Up @@ -80,6 +81,7 @@ input UpdateProjectInput {
trackingId: String
sceneId: ID
starred: Boolean
deleted: Boolean
}

input PublishProjectInput {
Expand Down Expand Up @@ -140,13 +142,13 @@ type ProjectEdge {
extend type Query {
projects(
teamId: ID!
includeArchived: Boolean
pagination: Pagination
keyword: String
sort: ProjectSort
): ProjectConnection!
): ProjectConnection! # not included deleted projects
hexaforce marked this conversation as resolved.
Show resolved Hide resolved
checkProjectAlias(alias: String!): ProjectAliasAvailability!
starredProjects(teamId: ID!): ProjectConnection!
deletedProjects(teamId: ID!): ProjectConnection!
hexaforce marked this conversation as resolved.
Show resolved Hide resolved
}

extend type Mutation {
Expand Down
Loading
Loading