Skip to content

Commit

Permalink
RUMM-664 Shopist CI setup is done
Browse files Browse the repository at this point in the history
  • Loading branch information
buranmert committed Aug 18, 2020
1 parent 644a406 commit 52694bf
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 31 deletions.
23 changes: 23 additions & 0 deletions Shopist/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
all: setup

define ORG2_SECRETS
RUM_APPLICATION_ID=${RUM_APPLICATION_ID}\n
DATADOG_CLIENT_TOKEN=${DATADOG_CLIENT_TOKEN}\n
SHOPIST_BASE_URL=${SHOPIST_BASE_URL}\n
endef
export ORG2_SECRETS

define DEMO_SECRETS
RUM_APPLICATION_ID=${DEMO_RUM_APPLICATION_ID}\n
DATADOG_CLIENT_TOKEN=${DEMO_DATADOG_CLIENT_TOKEN}\n
SHOPIST_BASE_URL=${DEMO_SHOPIST_BASE_URL}\n
endef
export DEMO_SECRETS

setup:
ifeq (${IS_DEMO}, true)
@echo "Running demo scenarios..."
@echo $$DEMO_SECRETS > ../xcconfigs/Shopist.local.xcconfig;
else
@echo $$ORG2_SECRETS > ../xcconfigs/Shopist.local.xcconfig;
endif
4 changes: 4 additions & 0 deletions Shopist/Shopist/Scenes/CategoriesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ internal final class CategoriesViewController: ListViewController {
let category = categories[index]
cell.text = category.title
cell.setImage(url: category.cover)

if index == (categories.count - 1) {
cell.accessibilityIdentifier = "lastCell"
}
}

override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
Expand Down
6 changes: 6 additions & 0 deletions Shopist/Shopist/Scenes/ProductsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ internal final class ProductsViewController: ListViewController {
}
cell.text = text
cell.setImage(url: item.cover)

if index == (items.count - 1) {
cell.accessibilityIdentifier = "lastCell"
} else {
cell.accessibilityIdentifier = "someCell"
}
}

override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
Expand Down
51 changes: 45 additions & 6 deletions Shopist/ShopistUITests/ShopistUITests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-2020 Datadog, Inc.
*/
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-2020 Datadog, Inc.
*/

import XCTest

Expand All @@ -11,8 +11,47 @@ class ShopistUITests: XCTestCase {
continueAfterFailure = false
}

func testAppCanBeLaunched() {
func testRunFullCheckoutFlow() {
let sessionCount = 3
let app = XCUIApplication()
app.launch()
for sessionIndex in 0...sessionCount {
app.launch()

app.collectionViews.firstMatch.goToOffScreenCell("lastCell")?.tap()
app.collectionViews.firstMatch.goToOffScreenCell("lastCell")?.tap()

let navBar = app.navigationBars.firstMatch
navBar.buttons["cart.badge.plus"].tap()
navBar.buttons["cart"].tap()

let cardButton = app.navigationBars["Cart"].buttons["creditcard"]
cardButton.tap()
if !app.alerts.firstMatch.waitForExistence(timeout: 5.0) {
fatalError("Alert should show up!")
}
app.alerts.firstMatch.buttons.firstMatch.tap()

if sessionIndex == sessionCount {
Thread.sleep(forTimeInterval: 5.0)
}
app.terminate()
}
}
}

private extension XCUIElement {
func goToOffScreenCell(_ identifier: String) -> XCUIElement? {
if !cells.element(boundBy: 1).waitForExistence(timeout: 5.0) {
fatalError("No cells exists in \(String(describing: self))")
}
var swipeCount = 0
while !self.cells[identifier].exists {
swipeCount += 1
if swipeCount >= 5 {
break
}
self.swipeUp()
}
return self.cells[identifier]
}
}
38 changes: 38 additions & 0 deletions Shopist/bitrise-shopist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
format_version: '8'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other

# To customize how workflows are run on different triggers,
# go to Workflow Editor on Bitrise.io.

workflows:
shopist_demo:
envs:
- IS_DEMO: true
after_run:
- run_shopist_scenarios
shopist_org2:
envs:
- IS_DEMO: false
after_run:
- run_shopist_scenarios

run_shopist_scenarios:
description: |-
Runs Shopist demo scenarios on iOS Simulator
steps:
- script@1.1.6:
title: Generate secrets for Shopist app
inputs:
- content: |-
#!/usr/bin/env zsh
set -e
cd Shopist && make
- xcode-test@2.4.5:
title: Run UI tests for Shopist - iOS Simulator
inputs:
- scheme: Shopist
- simulator_device: iPhone 11 Pro
- project_path: Shopist.xcodeproj
- xcpretty_test_options: --color --report html --output "${BITRISE_DEPLOY_DIR}/Shopist-UI-tests.html"
21 changes: 0 additions & 21 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ workflows:
- run_linter
- run_unit_tests
- run_integration_tests
- run_ui_tests
- check_dependency_managers
- _deploy_artifacts

Expand Down Expand Up @@ -110,26 +109,6 @@ workflows:
- destination: platform=OS X,arch=x86_64
- project_path: instrumented-tests/http-server-mock/HTTPServerMock.xcodeproj

run_ui_tests:
description: |-
Runs UI tests for Shopist app on iOS Simulator.
steps:
- script@1.1.6:
title: Generate client token for Shopist
inputs:
- content: |-
#!/usr/bin/env bash
set -e
echo 'DATADOG_CLIENT_TOKEN="fake-client-token-for-shopist"' > xcconfigs/Datadog.local.xcconfig
- xcode-test@2.4.5:
title: Run UI tests for Shopist - iOS Simulator
inputs:
- scheme: Shopist
- simulator_device: iPhone 11
- generate_code_coverage_files: 'yes'
- project_path: Shopist/Shopist.xcodeproj
- xcpretty_test_options: --color --report html --output "${BITRISE_DEPLOY_DIR}/Shopist-UI-tests.html"

run_integration_tests:
description: |-
Runs integration tests from Datadog.xcworkspace.
Expand Down
7 changes: 3 additions & 4 deletions xcconfigs/Shopist.xcconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "Datadog.xcconfig"

// TODO: RUMM-664 temporary value, otherwise test cases fail in CI
RUM_APPLICATION_ID=12345 // use your own RUM Application ID obtained on datadoghq.com
RUM_APPLICATION_ID= // use your own RUM Application ID obtained on datadoghq.com
DATADOG_CLIENT_TOKEN= // use your own Client Token, generated for RUM_APPLICATION_ID
SHOPIST_BASE_URL=some.url
#include? "Shopist.local.xcconfig" // overrides SHOPIST_BASE_URL
SHOPIST_BASE_URL=some.url // use Shopist endpoint without protocol
#include? "Shopist.local.xcconfig"

0 comments on commit 52694bf

Please sign in to comment.