test: make tests more stable

This commit is contained in:
Stefan Hausotte 2026-05-07 19:07:40 +02:00
parent ea9c9825e0
commit 2e07f6da4d
6 changed files with 28 additions and 16 deletions

View file

@ -639,7 +639,7 @@
repositoryURL = "https://codeberg.org/secana/ForgejoKit.git";
requirement = {
kind = exactVersion;
version = 0.4.0;
version = 0.5.0;
};
};
DEC49F6B2F3D00C700E7DD54 /* XCRemoteSwiftPackageReference "textual" */ = {

View file

@ -1,13 +1,13 @@
{
"originHash" : "77593b3d1d15a38120b458d94630878788bf310a5ba20ad73152ac15af983852",
"originHash" : "931ec0beeaf4e6a5eaa0afab6f815f97bc126bda7a2c9f001c10de58585e766f",
"pins" : [
{
"identity" : "forgejokit",
"kind" : "remoteSourceControl",
"location" : "https://codeberg.org/secana/ForgejoKit.git",
"state" : {
"revision" : "3030629b368cfde9e352dc9cfea2cbf1b58dcf04",
"version" : "0.4.0"
"revision" : "b87e4980a041557ab4328d4948d311550991525b",
"version" : "0.5.0"
}
},
{

View file

@ -14,10 +14,10 @@ final class ActionsUITests: ForgejoReadOnlyUITestBase {
func testActionsTabRendersWhenAvailable() throws {
navigateToRepoDetail("test-repo")
let tabPicker = app.otherElements["repo-detail-tab-picker"]
let tabPicker = app.segmentedControls["repo-detail-tab-picker"]
XCTAssertTrue(tabPicker.waitForExistence(timeout: 10), "Tab picker should appear")
let actionsTab = app.buttons["Actions"]
let actionsTab = tabPicker.buttons["Actions"]
try XCTSkipUnless(
actionsTab.waitForExistence(timeout: 3),
"Actions tab not exposed on this seed repo (has_actions disabled)",
@ -25,22 +25,25 @@ final class ActionsUITests: ForgejoReadOnlyUITestBase {
actionsTab.tap()
// Status filter picker should render (All/Running/Success/Failed).
let statusPicker = app.otherElements["workflow-run-status-picker"]
XCTAssertTrue(statusPicker.waitForExistence(timeout: 5), "Workflow run status picker should render")
XCTAssertTrue(app.buttons["All"].exists, "All filter button should render")
// Status filter (All/Running/Success/Failed) should render.
// The picker itself is an HStack, which doesn't surface as an XCUI element,
// so probe a uniquely-named child button instead of the wrapper identifier.
let runningButton = app.buttons["Running"]
XCTAssertTrue(runningButton.waitForExistence(timeout: 5), "Workflow run status picker should render")
XCTAssertTrue(app.buttons["Success"].exists, "Success filter button should render")
XCTAssertTrue(app.buttons["Failed"].exists, "Failed filter button should render")
}
@MainActor
func testActionsTabAbsentForRepoWithoutActions() throws {
navigateToRepoDetail("test-repo-2")
let tabPicker = app.otherElements["repo-detail-tab-picker"]
let tabPicker = app.segmentedControls["repo-detail-tab-picker"]
XCTAssertTrue(tabPicker.waitForExistence(timeout: 10))
// If the repo has has_actions: false (the default), the Actions tab must not appear.
// This guards the availableTabs filter from showing actions on every repo.
let actionsTab = app.buttons["Actions"]
let actionsTab = tabPicker.buttons["Actions"]
if actionsTab.waitForExistence(timeout: 2) {
// If Actions IS present, the seed has been updated to enable actions on this repo.
// The remaining assertions don't apply; nothing to verify here for the negative case.

View file

@ -1,13 +1,13 @@
{
"originHash" : "6925739b095ee90912b50df5d7f72a20c934e3a08983bcca294a8831f90689cd",
"originHash" : "ad0278ea26d22664abc63e2a8738d50505e72b2630016004bbf661b0e4222998",
"pins" : [
{
"identity" : "forgejokit",
"kind" : "remoteSourceControl",
"location" : "https://codeberg.org/secana/ForgejoKit.git",
"state" : {
"revision" : "a73f04462372ec2976e0ef673dd1ee17c3a7239d",
"version" : "0.2.0"
"revision" : "b87e4980a041557ab4328d4948d311550991525b",
"version" : "0.5.0"
}
}
],

View file

@ -8,7 +8,7 @@ let package = Package(
.macOS(.v15),
],
dependencies: [
.package(url: "https://codeberg.org/secana/ForgejoKit.git", from: "0.2.0"),
.package(url: "https://codeberg.org/secana/ForgejoKit.git", from: "0.5.0"),
],
targets: [
.executableTarget(

View file

@ -92,6 +92,15 @@ struct Seeder {
)
}
// Forgejo 15 enables actions on every new repo by default. Disable it on test-repo-2 so
// `ActionsUITests.testActionsTabAbsentForRepoWithoutActions` exercises the negative path.
print("Disabling actions on test-repo-2...")
try await withRetry(maxAttempts: 5, delay: .seconds(2), operation: "disable actions") {
_ = try await repoService.editRepository(
owner: adminUser, repo: "test-repo-2", hasActions: false,
)
}
print("Updating html-readme-repo README...")
let readmeSHA: String = try await withRetry(maxAttempts: 5, delay: .seconds(2), operation: "fetch README") {
let file = try await repoService.fetchFileContent(