Files
sodalive-ios/work/tests/check-gift-detail-talk-inquiry.sh
T

40 lines
1.9 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
ruby - "$root" <<'RUBY'
root = ARGV.fetch(0)
source_root = File.join(root, 'SodaLive/Sources')
read = lambda do |path|
File.read(File.join(source_root, path))
.gsub(%r{"(?:\\.|[^"\\])*"|//[^\n]*|/\*.*?\*/}m) { |token| token.start_with?('"') ? token : '' }
.gsub(/\s+/, ' ').gsub(/\s*([(),:])\s*/, '\1').strip
end
check = lambda do |condition, message|
abort "RED gift-detail TALK inquiry: #{message}" unless condition
end
service = read.call('MyPage/ServiceCenter/ServiceCenterView.swift')
gift_sources = [
'V2/Gift/Detail/Components/GiftDetailActionBar.swift',
'V2/Gift/Detail/Components/ReceivedGiftDetailContentView.swift',
'V2/Gift/Detail/Components/GiftCancelCompleteView.swift'
].map { |path| [path, read.call(path)] }
helper = 'enum ServiceCenterInquiry { static func openTalk(){ UIApplication.shared.open(URL(string:"http://pf.kakao.com/_lkxgxhG/chat")!)} }'
check.call(service.include?(helper), 'ServiceCenterInquiry.openTalk must own the existing Kakao TALK action')
check.call(service.scan('ServiceCenterInquiry.openTalk()').length == 1, 'ServiceCenter TALK button must call the shared action once')
check.call(service.scan('http://pf.kakao.com/_lkxgxhG/chat').length == 1, 'Kakao TALK URL must have one source of truth')
gift_sources.each do |path, source|
check.call(source.scan('ServiceCenterInquiry.openTalk()').length == 1, "#{path} must call the shared action once")
check.call(!source.include?('GiftConstants.inquiryStep'), "#{path} must not navigate to the in-app service center")
check.call(!source.include?('.serviceCenter'), "#{path} must not navigate directly to the in-app service center")
check.call(!source.include?('http://pf.kakao.com/_lkxgxhG/chat'), "#{path} must not duplicate the TALK URL")
end
puts 'PASS gift-detail TALK inquiry: ServiceCenter and all three Gift actions share one TALK action'
RUBY