Skip to content

Commit 923f6de

Browse files
committed
Run e2e tests with go test
1 parent 13e63f8 commit 923f6de

12 files changed

+547
-54
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ cpu.out
7373
/tests/integration/indexers-pgsql
7474
/tests/integration/indexers-sqlite
7575
/tests/integration/indexers-mssql
76+
/tests/e2e/gitea-e2e-mysql
77+
/tests/e2e/gitea-e2e-mysql8
78+
/tests/e2e/gitea-e2e-pgsql
79+
/tests/e2e/gitea-e2e-sqlite
80+
/tests/e2e/gitea-e2e-mssql
81+
/tests/e2e/indexers-mysql
82+
/tests/e2e/indexers-mysql8
83+
/tests/e2e/indexers-pgsql
84+
/tests/e2e/indexers-sqlite
85+
/tests/e2e/indexers-mssql
7686
/tests/sqlite.ini
7787
/tests/mysql.ini
7888
/tests/mysql8.ini

Makefile

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,13 @@ clean:
242242
$(GO) clean -i ./...
243243
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
244244
integrations*.test \
245+
e2e*.test \
245246
tests/integration/gitea-integration-pgsql/ tests/integration/gitea-integration-mysql/ tests/integration/gitea-integration-mysql8/ tests/integration/gitea-integration-sqlite/ \
246247
tests/integration/gitea-integration-mssql/ tests/integration/indexers-mysql/ tests/integration/indexers-mysql8/ tests/integration/indexers-pgsql tests/integration/indexers-sqlite \
247248
tests/integration/indexers-mssql tests/mysql.ini tests/mysql8.ini tests/pgsql.ini tests/mssql.ini man/
249+
tests/e2e/gitea-integration-pgsql/ tests/e2e/gitea-integration-mysql/ tests/e2e/gitea-integration-mysql8/ tests/e2e/gitea-integration-sqlite/ \
250+
tests/e2e/gitea-integration-mssql/ tests/e2e/indexers-mysql/ tests/e2e/indexers-mysql8/ tests/e2e/indexers-pgsql tests/e2e/indexers-sqlite \
251+
tests/e2e/indexers-mssql
248252

249253
.PHONY: fmt
250254
fmt:
@@ -512,57 +516,61 @@ test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test gen
512516

513517
.PHONY: test-e2e%
514518
# Use only file logging for end-to-end tests
515-
test-e2e%: TEST_LOGGER ?= file TEST_TYPE ?= e2e
519+
test-e2e%: TEST_LOGGER ?= file
520+
test-e2e%: TEST_TYPE ?= e2e
516521

517522
.PHONY: test-e2e
518523
test-e2e: test-e2e-sqlite
519524

520-
.PHONY: test-e2e\#%
521-
test-e2e\#%: test-e2e-sqlite\#%
522-
# Kind of a hack to get makefile to accept passing arguement
523-
true
524-
525525
.PHONY: test-e2e-sqlite
526-
test-e2e-sqlite: TAGS+=sqlite sqlite_unlock_notify
527-
test-e2e-sqlite: build generate-ini-sqlite
526+
test-e2e-sqlite: e2e.sqlite.test generate-ini-sqlite
528527
npx playwright install $(PLAYWRIGHT_FLAGS)
529-
GITEA_ROOT=$(CURDIR) GITEA_URL="http://localhost:3003" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=tests/sqlite.ini ./tools/e2e/run_e2e.sh
528+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test
530529

531530
.PHONY: test-e2e-sqlite\#%
532-
test-e2e-sqlite\#%: TAGS+=sqlite sqlite_unlock_notify
533-
test-e2e-sqlite\#%: build generate-ini-sqlite
531+
test-e2e-sqlite\#%: e2e.sqlite.test generate-ini-sqlite
532+
npx playwright install $(PLAYWRIGHT_FLAGS)
533+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test -test.run $(subst .,/,$*)
534+
535+
.PHONY: test-e2e-mysql
536+
test-e2e-mysql: e2e.mysql.test generate-ini-mysql
537+
npx playwright install $(PLAYWRIGHT_FLAGS)
538+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test
539+
540+
.PHONY: test-e2e-mysql\#%
541+
test-e2e-mysql\#%: e2e.mysql.test generate-ini-mysql
534542
npx playwright install $(PLAYWRIGHT_FLAGS)
535-
GITEA_URL="http://localhost:3003" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/tests/sqlite.ini E2E_TESTS=$* ./tools/e2e/run_e2e.sh
543+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test -test.run $(subst .,/,$*)
536544

537545
.PHONY: test-e2e-mysql8
538-
test-e2e-mysql8: build generate-ini-mysql8
546+
test-e2e-mysql8: e2e.mysql8.test generate-ini-mysql8
539547
npx playwright install $(PLAYWRIGHT_FLAGS)
540-
GITEA_URL="http://localhost:3004" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/tests/mysql8.ini ./tools/e2e/run_e2e.sh
548+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql8.ini ./e2e.mysql8.test
541549

542550
.PHONY: test-e2e-mysql8\#%
543-
test-e2e-mysql8\#%: build generate-ini-mysql8
551+
test-e2e-mysql8\#%: e2e.mysql8.test generate-ini-mysql8
544552
npx playwright install $(PLAYWRIGHT_FLAGS)
545-
GITEA_URL="http://localhost:3004" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/tests/mysql8.ini E2E_TESTS=$* ./tools/e2e/run_e2e.sh
553+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql8.ini ./e2e.mysql8.test -test.run $(subst .,/,$*)
546554

547555
.PHONY: test-e2e-pgsql
548-
test-e2e-pgsql: build generate-ini-pgsql
556+
test-e2e-pgsql: e2e.pgsql.test generate-ini-pgsql
549557
npx playwright install $(PLAYWRIGHT_FLAGS)
550-
GITEA_URL="http://localhost:3002" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/tests/pgsql.ini ./tools/e2e/run_e2e.sh
558+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test
551559

552560
.PHONY: test-e2e-pgsql\#%
553-
test-e2e-pgsql\#%: build generate-ini-pgsql
561+
test-e2e-pgsql\#%: e2e.pgsql.test generate-ini-pgsql
554562
npx playwright install $(PLAYWRIGHT_FLAGS)
555-
GITEA_URL="http://localhost:3002" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/tests/pgsql.ini E2E_TESTS=$* ./tools/e2e/run_e2e.sh
563+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test -test.run $(subst .,/,$*)
556564

557565
.PHONY: test-e2e-mssql
558-
test-e2e-mssql: build generate-ini-mssql
566+
test-e2e-mssql: e2e.mssql.test generate-ini-mssql
559567
npx playwright install $(PLAYWRIGHT_FLAGS)
560-
GITEA_ROOT=$(CURDIR) GITEA_URL="http://localhost:3003" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/tests/mssql.ini ./tools/e2e/run_e2e.sh
568+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test
561569

562570
.PHONY: test-e2e-mssql\#%
563-
test-e2e-mssql\#%: build generate-ini-mssql
571+
test-e2e-mssql\#%: e2e.mssql.test generate-ini-mssql
564572
npx playwright install $(PLAYWRIGHT_FLAGS)
565-
GITEA_ROOT=$(CURDIR) GITEA_URL="http://localhost:3003" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/tests/mssql.ini E2E_TESTS=$* ./tools/e2e/run_e2e.sh
573+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run $(subst .,/,$*)
566574

567575
.PHONY: bench-sqlite
568576
bench-sqlite: integrations.sqlite.test generate-ini-sqlite
@@ -649,6 +657,21 @@ migrations.individual.mssql.test: $(GO_SOURCES)
649657
migrations.individual.sqlite.test: $(GO_SOURCES)
650658
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/models/migrations -o migrations.individual.sqlite.test -tags '$(TEST_TAGS)'
651659

660+
e2e.mysql.test: git-check $(GO_SOURCES)
661+
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql.test
662+
663+
e2e.mysql8.test: git-check $(GO_SOURCES)
664+
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql8.test
665+
666+
e2e.pgsql.test: git-check $(GO_SOURCES)
667+
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.pgsql.test
668+
669+
e2e.mssql.test: git-check $(GO_SOURCES)
670+
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mssql.test
671+
672+
e2e.sqlite.test: git-check $(GO_SOURCES)
673+
$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.sqlite.test -tags '$(TEST_TAGS)'
674+
652675
.PHONY: check
653676
check: test
654677

playwright.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// @ts-check
22
import {devices} from '@playwright/test';
33

4-
const BASE_URL = process.env.GITEA_URL ? process.env.GITEA_URL : 'http://localhost:3000';
4+
const BASE_URL = process.env.GITEA_URL ? process.env.GITEA_URL.replace(/\/$/g, '') : 'http://localhost:3000';
55

66
/**
77
* @see https://playwright.dev/docs/test-configuration
88
* @type {import('@playwright/test').PlaywrightTestConfig}
99
*/
1010
const config = {
11-
testDir: './tools/e2e/tests', // TODO: Change this to the ./web_src/ dir?
11+
testDir: './tests/e2e/',
1212
testMatch: /.*\.test\.e2e\.js/, // Match any .test.e2e.js files
1313

1414
/* Maximum time one test can run for. */

0 commit comments

Comments
 (0)