From 89cb24245688956e7afbc097ce87f70f91ee9d50 Mon Sep 17 00:00:00 2001 From: Niklas Berglund Date: Mon, 10 Jun 2024 14:09:53 +0200 Subject: [PATCH] Fix for failing iOS screenshot tests --- .github/workflows/ios-screenshots-creation.yml | 5 ++++- .github/workflows/ios-screenshots-tests.yml | 7 +++++-- ios/Configurations/Screenshots.xcconfig.template | 3 --- ios/MullvadVPNUITests/Networking/PartnerAPIClient.swift | 2 +- ios/MullvadVPNUITests/Pages/SelectLocationPage.swift | 3 +++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ios-screenshots-creation.yml b/.github/workflows/ios-screenshots-creation.yml index 4b7e6a3692d8..057aa8553e9c 100644 --- a/.github/workflows/ios-screenshots-creation.yml +++ b/.github/workflows/ios-screenshots-creation.yml @@ -12,6 +12,7 @@ jobs: env: SOURCE_PACKAGES_PATH: .spm TEST_ACCOUNT: ${{ secrets.IOS_TEST_ACCOUNT_NUMBER }} + PARTNER_API_TOKEN: ${{ secrets.STAGEMOLE_PARTNER_AUTH }} steps: - name: Checkout repository uses: actions/checkout@v3 @@ -43,7 +44,9 @@ jobs: cp PacketTunnel.xcconfig.template PacketTunnel.xcconfig cp Screenshots.xcconfig.template Screenshots.xcconfig cp Api.xcconfig.template Api.xcconfig - sed -i "" "s/MULLVAD_ACCOUNT_TOKEN = /MULLVAD_ACCOUNT_TOKEN = $TEST_ACCOUNT/g" Screenshots.xcconfig + sed -i "" \ + "/PARTNER_API_TOKEN =/ s#= .*#= $PARTNER_API_TOKEN#" \ + UITests.xcconfig working-directory: ios/Configurations - name: Bundle diff --git a/.github/workflows/ios-screenshots-tests.yml b/.github/workflows/ios-screenshots-tests.yml index 7bc5cd670df6..89993921b328 100644 --- a/.github/workflows/ios-screenshots-tests.yml +++ b/.github/workflows/ios-screenshots-tests.yml @@ -14,12 +14,13 @@ on: workflow_dispatch: jobs: test: - if: github.event.pull_request.merged + if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch' name: Screenshot tests runs-on: macos-13-xlarge env: SOURCE_PACKAGES_PATH: .spm TEST_ACCOUNT: ${{ secrets.IOS_TEST_ACCOUNT_NUMBER }} + PARTNER_API_TOKEN: ${{ secrets.STAGEMOLE_PARTNER_AUTH }} steps: - name: Checkout repository uses: actions/checkout@v3 @@ -60,7 +61,9 @@ jobs: cp Screenshots.xcconfig.template Screenshots.xcconfig cp Api.xcconfig.template Api.xcconfig cp UITests.xcconfig.template UITests.xcconfig - sed -i "" "s/MULLVAD_ACCOUNT_TOKEN = /MULLVAD_ACCOUNT_TOKEN = $TEST_ACCOUNT/g" Screenshots.xcconfig + sed -i "" \ + "/PARTNER_API_TOKEN =/ s#= .*#= $PARTNER_API_TOKEN#" \ + UITests.xcconfig working-directory: ios/Configurations - name: Install xcbeautify diff --git a/ios/Configurations/Screenshots.xcconfig.template b/ios/Configurations/Screenshots.xcconfig.template index 025de82739ee..e885dd21d0fb 100644 --- a/ios/Configurations/Screenshots.xcconfig.template +++ b/ios/Configurations/Screenshots.xcconfig.template @@ -5,6 +5,3 @@ PROVISIONING_PROFILE_SPECIFIER[config=Debug][sdk=*][arch=*] = Screenshots Development PROVISIONING_PROFILE_SPECIFIER[config=Staging][sdk=*][arch=*] = Screenshots Development PROVISIONING_PROFILE_SPECIFIER[config=MockRelease][sdk=*][arch=*] = Screenshots Development - -// Mullvad account number used when taking screenshots -MULLVAD_ACCOUNT_TOKEN = diff --git a/ios/MullvadVPNUITests/Networking/PartnerAPIClient.swift b/ios/MullvadVPNUITests/Networking/PartnerAPIClient.swift index 67d1d7acdddb..2a26d5bf9993 100644 --- a/ios/MullvadVPNUITests/Networking/PartnerAPIClient.swift +++ b/ios/MullvadVPNUITests/Networking/PartnerAPIClient.swift @@ -107,7 +107,7 @@ class PartnerAPIClient { XCTFail("Failed to deserialize JSON response") } } else { - XCTFail("Request failed") + XCTFail("Request failed with status code \(response.statusCode)") } completionHandlerInvokedExpectation.fulfill() diff --git a/ios/MullvadVPNUITests/Pages/SelectLocationPage.swift b/ios/MullvadVPNUITests/Pages/SelectLocationPage.swift index 8c87309a04fd..95b9416c1c59 100644 --- a/ios/MullvadVPNUITests/Pages/SelectLocationPage.swift +++ b/ios/MullvadVPNUITests/Pages/SelectLocationPage.swift @@ -68,6 +68,9 @@ class SelectLocationPage: Page { } @discardableResult func tapCustomListEllipsisButton() -> Self { + // This wait should not be needed, but is due to the issues we are having with the ellipsis button + _ = app.buttons[.openCustomListsMenuButton].waitForExistence(timeout: BaseUITestCase.shortTimeout) + let customListEllipsisButtons = app.buttons .matching(identifier: AccessibilityIdentifier.openCustomListsMenuButton.rawValue).allElementsBoundByIndex