diff options
author | Kyle D <kdumontnu@gmail.com> | 2022-09-02 15:18:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-02 15:18:23 -0400 |
commit | c8ded77680db7344c8dc1ccee76bce0b4e02e103 (patch) | |
tree | bc63678ef62dc71ce68b29eeaf019c45cdb12034 /integrations/api_wiki_test.go | |
parent | 5710ff343c9f16119ddbff06044e5d61388baa22 (diff) | |
download | gitea-c8ded77680db7344c8dc1ccee76bce0b4e02e103.tar.gz gitea-c8ded77680db7344c8dc1ccee76bce0b4e02e103.zip |
Kd/ci playwright go test (#20123)
* Add initial playwright config
* Simplify Makefile
* Simplify Makefile
* Use correct config files
* Update playwright settings
* Fix package-lock file
* Don't use test logger for e2e tests
* fix frontend lint
* Allow passing TEST_LOGGER variable
* Init postgres database
* use standard gitea env variables
* Update playwright
* update drone
* Move empty env var to commands
* Cleanup
* Move integrations to subfolder
* tests integrations to tests integraton
* Run e2e tests with go test
* Fix linting
* install CI deps
* Add files to ESlint
* Fix drone typo
* Don't log to console in CI
* Use go test http server
* Add build step before tests
* Move shared init function to common package
* fix drone
* Clean up tests
* Fix linting
* Better mocking for page + version string
* Cleanup test generation
* Remove dependency on gitea binary
* Fix linting
* add initial support for running specific tests
* Add ACCEPT_VISUAL variable
* don't require git-lfs
* Add initial documentation
* Review feedback
* Add logged in session test
* Attempt fixing drone race
* Cleanup and bump version
* Bump deps
* Review feedback
* simplify installation
* Fix ci
* Update install docs
Diffstat (limited to 'integrations/api_wiki_test.go')
-rw-r--r-- | integrations/api_wiki_test.go | 251 |
1 files changed, 0 insertions, 251 deletions
diff --git a/integrations/api_wiki_test.go b/integrations/api_wiki_test.go deleted file mode 100644 index 3b768b94d8..0000000000 --- a/integrations/api_wiki_test.go +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2021 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package integrations - -import ( - "encoding/base64" - "fmt" - "net/http" - "testing" - - api "code.gitea.io/gitea/modules/structs" - - "github.com/stretchr/testify/assert" -) - -func TestAPIGetWikiPage(t *testing.T) { - defer prepareTestEnv(t)() - - username := "user2" - session := loginUser(t, username) - - urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/page/Home", username, "repo1") - - req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) - var page *api.WikiPage - DecodeJSON(t, resp, &page) - - assert.Equal(t, &api.WikiPage{ - WikiPageMetaData: &api.WikiPageMetaData{ - Title: "Home", - HTMLURL: page.HTMLURL, - SubURL: "Home", - LastCommit: &api.WikiCommit{ - ID: "2c54faec6c45d31c1abfaecdab471eac6633738a", - Author: &api.CommitUser{ - Identity: api.Identity{ - Name: "Ethan Koenig", - Email: "ethantkoenig@gmail.com", - }, - Date: "2017-11-27T04:31:18Z", - }, - Committer: &api.CommitUser{ - Identity: api.Identity{ - Name: "Ethan Koenig", - Email: "ethantkoenig@gmail.com", - }, - Date: "2017-11-27T04:31:18Z", - }, - Message: "Add Home.md\n", - }, - }, - ContentBase64: base64.RawStdEncoding.EncodeToString( - []byte("# Home page\n\nThis is the home page!\n"), - ), - CommitCount: 1, - Sidebar: "", - Footer: "", - }, page) -} - -func TestAPIListWikiPages(t *testing.T) { - defer prepareTestEnv(t)() - - username := "user2" - session := loginUser(t, username) - - urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/pages", username, "repo1") - - req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) - - var meta []*api.WikiPageMetaData - DecodeJSON(t, resp, &meta) - - dummymeta := []*api.WikiPageMetaData{ - { - Title: "Home", - HTMLURL: meta[0].HTMLURL, - SubURL: "Home", - LastCommit: &api.WikiCommit{ - ID: "2c54faec6c45d31c1abfaecdab471eac6633738a", - Author: &api.CommitUser{ - Identity: api.Identity{ - Name: "Ethan Koenig", - Email: "ethantkoenig@gmail.com", - }, - Date: "2017-11-27T04:31:18Z", - }, - Committer: &api.CommitUser{ - Identity: api.Identity{ - Name: "Ethan Koenig", - Email: "ethantkoenig@gmail.com", - }, - Date: "2017-11-27T04:31:18Z", - }, - Message: "Add Home.md\n", - }, - }, - { - Title: "Page With Image", - HTMLURL: meta[1].HTMLURL, - SubURL: "Page-With-Image", - LastCommit: &api.WikiCommit{ - ID: "0cf15c3f66ec8384480ed9c3cf87c9e97fbb0ec3", - Author: &api.CommitUser{ - Identity: api.Identity{ - Name: "Gabriel Silva Simões", - Email: "simoes.sgabriel@gmail.com", - }, - Date: "2019-01-25T01:41:55Z", - }, - Committer: &api.CommitUser{ - Identity: api.Identity{ - Name: "Gabriel Silva Simões", - Email: "simoes.sgabriel@gmail.com", - }, - Date: "2019-01-25T01:41:55Z", - }, - Message: "Add jpeg.jpg and page with image\n", - }, - }, - { - Title: "Page With Spaced Name", - HTMLURL: meta[2].HTMLURL, - SubURL: "Page-With-Spaced-Name", - LastCommit: &api.WikiCommit{ - ID: "c10d10b7e655b3dab1f53176db57c8219a5488d6", - Author: &api.CommitUser{ - Identity: api.Identity{ - Name: "Gabriel Silva Simões", - Email: "simoes.sgabriel@gmail.com", - }, - Date: "2019-01-25T01:39:51Z", - }, - Committer: &api.CommitUser{ - Identity: api.Identity{ - Name: "Gabriel Silva Simões", - Email: "simoes.sgabriel@gmail.com", - }, - Date: "2019-01-25T01:39:51Z", - }, - Message: "Add page with spaced name\n", - }, - }, - { - Title: "Unescaped File", - HTMLURL: meta[3].HTMLURL, - SubURL: "Unescaped-File", - LastCommit: &api.WikiCommit{ - ID: "0dca5bd9b5d7ef937710e056f575e86c0184ba85", - Author: &api.CommitUser{ - Identity: api.Identity{ - Name: "6543", - Email: "6543@obermui.de", - }, - Date: "2021-07-19T16:42:46Z", - }, - Committer: &api.CommitUser{ - Identity: api.Identity{ - Name: "6543", - Email: "6543@obermui.de", - }, - Date: "2021-07-19T16:42:46Z", - }, - Message: "add unescaped file\n", - }, - }, - } - - assert.Equal(t, dummymeta, meta) -} - -func TestAPINewWikiPage(t *testing.T) { - for _, title := range []string{ - "New page", - "&&&&", - } { - defer prepareTestEnv(t)() - username := "user2" - session := loginUser(t, username) - token := getTokenForLoggedInUser(t, session) - - urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/new?token=%s", username, "repo1", token) - - req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateWikiPageOptions{ - Title: title, - ContentBase64: base64.StdEncoding.EncodeToString([]byte("Wiki page content for API unit tests")), - Message: "", - }) - session.MakeRequest(t, req, http.StatusCreated) - } -} - -func TestAPIEditWikiPage(t *testing.T) { - defer prepareTestEnv(t)() - username := "user2" - session := loginUser(t, username) - token := getTokenForLoggedInUser(t, session) - - urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/page/Page-With-Spaced-Name?token=%s", username, "repo1", token) - - req := NewRequestWithJSON(t, "PATCH", urlStr, &api.CreateWikiPageOptions{ - Title: "edited title", - ContentBase64: base64.StdEncoding.EncodeToString([]byte("Edited wiki page content for API unit tests")), - Message: "", - }) - session.MakeRequest(t, req, http.StatusOK) -} - -func TestAPIListPageRevisions(t *testing.T) { - defer prepareTestEnv(t)() - username := "user2" - session := loginUser(t, username) - - urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/revisions/Home", username, "repo1") - - req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) - - var revisions *api.WikiCommitList - DecodeJSON(t, resp, &revisions) - - dummyrevisions := &api.WikiCommitList{ - WikiCommits: []*api.WikiCommit{ - { - ID: "2c54faec6c45d31c1abfaecdab471eac6633738a", - Author: &api.CommitUser{ - Identity: api.Identity{ - Name: "Ethan Koenig", - Email: "ethantkoenig@gmail.com", - }, - Date: "2017-11-27T04:31:18Z", - }, - Committer: &api.CommitUser{ - Identity: api.Identity{ - Name: "Ethan Koenig", - Email: "ethantkoenig@gmail.com", - }, - Date: "2017-11-27T04:31:18Z", - }, - Message: "Add Home.md\n", - }, - }, - Count: 1, - } - - assert.Equal(t, dummyrevisions, revisions) -} |