Skip to content

Commit

Permalink
Merge pull request #16 from Mindera/ALFMOB-50-i-os-replace-fake-produ…
Browse files Browse the repository at this point in the history
…ct-image-urls-with-real-urls

[ALFMOB-50] Replace fake product image urls with real urls
  • Loading branch information
reisdev authored Jan 7, 2025
2 parents 0942d1f + 4a50cf4 commit 88f6bb6
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,5 @@ fastlane/screenshots/**/*.png
fastlane/test_output
*.xcuserstate
Alfie/Alfie.xcodeproj/xcuserdata/*
Alfie/Packages/*/.swiftpm
Alfie/Packages/**/*/.swiftpm
Alfie/Packages/*/Package.resolved
8 changes: 4 additions & 4 deletions Alfie/Alfie/Views/ProductDetails/ProductDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -585,14 +585,14 @@ private enum Constants {
state: .success(.init(product: .fixture(), selectedVariant: .fixture())),
productName: "Nolita SW Signature Loafer",
productImageUrls: [
URL.fromString("https://www.alfieproj.com/productimages/thumb/2/2666503_22841458_13891527.jpg"),
URL.fromString("https://www.alfieproj.com/productimages/thumb/2/2666503_22841458_13891527.jpg"),
URL.fromString("https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"),
URL.fromString("https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"),
],
productDescription: "A short-sleeved dress in a slim fit by BOSS Womenswear. Featuring a wrap-over bodice and a tiered skirt, this V-neck dress is crafted in metallic fabric with lining underneath.", // swiftlint:disable:this line_length
colorSelectionConfiguration: .init(
items: [
.init(id: "1", name: "", type: .url(URL.fromString("https://www.alfieproj.com/productimages/thumb/3/2479864_22579704_13941430.jpg"))),
.init(id: "2", name: "", type: .url(URL.fromString("https://www.alfieproj.com/productimages/thumb/3/2479864_22005770_9866399.jpg"))),
.init(id: "1", name: "", type: .url(URL.fromString("URL.fromString(https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"))),
.init(id: "2", name: "", type: .url(URL.fromString("URL.fromString(https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"))),
.init(id: "3", name: "", type: .color(.green), isDisabled: true),
.init(id: "4", name: "", type: .color(.red)),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ final class MediaConverterTests: XCTestCase {
// MARK: Media Image

func test_image_valid_image() {
let image: Mock<Image> = .mock(alt: "Accessibility description",
url: "https://www.alfieproj.com/images/assetimages/footer/alfie.png")
let image: Mock<Image> = .mock(
alt: "Accessibility description",
url: "https://www.alfieproj.com/images/assetimages/footer/alfie.png"
)
let mockMedia = MediaFragment.from(image)

let media = mockMedia.convertToMedia()
Expand All @@ -21,7 +23,10 @@ final class MediaConverterTests: XCTestCase {

XCTAssertEqual(mediaImage.alt, "Accessibility description")
XCTAssertEqual(mediaImage.mediaContentType, .image)
XCTAssertEqual(mediaImage.url, URL(string: "https://www.alfieproj.com/images/assetimages/footer/alfie.png"))
XCTAssertEqual(
mediaImage.url,
URL(string: "https://www.alfieproj.com/images/assetimages/footer/alfie.png")
)
}

func test_image_with_unknown_content_type_fallback_to_image_media() {
Expand All @@ -47,13 +52,17 @@ final class MediaConverterTests: XCTestCase {
// MARK: Media Video

func test_video_valid_video() {
let video: Mock<Video> = .mock(alt: "Accessibility description",
previewImage: .mock(),
sources: [
.mock(format: .mp4,
mimeType: "video/mp4",
url: "https://www.alfieproj.com/video/assetvideos/alfie.mp4"),
])
let video: Mock<Video> = .mock(
alt: "Accessibility description",
previewImage: .mock(),
sources: [
.mock(
format: .mp4,
mimeType: "video/mp4",
url: "https://www.alfieproj.com/images/assetvideos/demo-video.mp4"
),
]
)
let mockMedia = MediaFragment.from(video)

let media = mockMedia.convertToMedia()
Expand All @@ -71,7 +80,10 @@ final class MediaConverterTests: XCTestCase {
XCTAssertEqual(mediaVideo.sources.count, 1)
XCTAssertEqual(source.format, .mp4)
XCTAssertEqual(source.mimeType, "video/mp4")
XCTAssertEqual(source.url, URL(string: "https://www.alfieproj.com/video/assetvideos/alfie.mp4"))
XCTAssertEqual(
source.url,
URL(string: "https://www.alfieproj.com/images/assetvideos/demo-video.mp4")
)
}

func test_video_missing_url_video_with_only_preview_image() {
Expand All @@ -89,9 +101,11 @@ final class MediaConverterTests: XCTestCase {
}

func test_video_unsupported_video_format_video_with_unknown_format() {
let source = Mock<VideoSource>(format: .unknown("mov"),
mimeType: "video/mov",
url: "https://www.alfieproj.com/video/assetvideos/alfie.mov")
let source = Mock<VideoSource>(
format: .unknown("mov"),
mimeType: "video/mov",
url: "https://www.alfieproj.com/images/assetvideos/demo-video.mov"
)
let video: Mock<Video> = .mock(alt: "Accessibility description",
previewImage: .mock(),
sources: [source])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import BFFGraphApi
import BFFGraphMocks

extension Mock<Image> {
static func mock(alt: String? = nil,
url: String = "https://www.alfieproj.com/images/assetimages/footer/alfie.png") -> Mock<Image> {
static func mock(
alt: String? = nil,
url: String = "https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"
) -> Mock<Image> {
Mock<Image>(alt: alt,
mediaContentType: .some(.case(.image)),
url: url)
Expand All @@ -23,9 +25,11 @@ extension Mock<Video> {
}

extension Mock<VideoSource> {
static func mock(format: VideoFormat = .mp4,
mimeType: String = "video/mp4",
url: String = "https://www.alfieproj.com/video/assetvideos/alfie.mp4") -> Mock<VideoSource> {
static func mock(
format: VideoFormat = .mp4,
mimeType: String = "video/mp4",
url: String = "https://videos.pexels.com/video-files/3912502/3912502-uhd_2560_1440_25fps.mp4"
) -> Mock<VideoSource> {
Mock<VideoSource>(format: .some(.case(format)),
mimeType: mimeType,
url: url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import Foundation
import Models

extension MediaImage {
public static func fixture(alt: String? = nil,
mediaContentType: MediaContentType = .image,
url: URL = URL(string: "https://www.alfieproj.com/images/assetimages/footer/alfie.png")!) -> MediaImage {
public static func fixture(
alt: String? = nil,
mediaContentType: MediaContentType = .image,
url: URL = URL(string: "https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1)")!
) -> MediaImage {
.init(alt: alt,
mediaContentType: mediaContentType,
url: url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ extension MediaVideo {
}

extension VideoSource {
public static func fixture(format: VideoFormat = .mp4,
mimeType: String = "video/mp4",
url: URL = URL(string: "https://www.alfieproj.com/video/assetvideos/alfie.mp4")!) -> VideoSource {
public static func fixture(
format: VideoFormat = .mp4,
mimeType: String = "video/mp4",
url: URL = URL(string: "https://videos.pexels.com/video-files/3912502/3912502-uhd_2560_1440_25fps.mp4")!
) -> VideoSource {
.init(format: format,
mimeType: mimeType,
url: url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ extension Product {
MediaImage(
alt: nil,
mediaContentType: .image,
url: URL.fromString("https://www.alfieproj.com/productimages/medium/1/2627014_22646926_13567396.jpg")
url: URL.fromString("https://images.pexels.com/photos/6858599/pexels-photo-6858599.jpeg?auto=compress&cs=tinysrgb&w=600")
)
),
]
Expand Down Expand Up @@ -116,7 +116,7 @@ extension Product {
MediaImage(
alt: nil,
mediaContentType: .image,
url: URL.fromString("https://www.alfieproj.com/productimages/medium/1/2641917_22732293_13656033.jpg")
url: URL.fromString("https://images.pexels.com/photos/27008317/pexels-photo-27008317/free-photo-of-an-elegant-woman-wearing-brown-heels-and-holding-a-brown-bag.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1")
)
),
]
Expand Down Expand Up @@ -156,7 +156,7 @@ extension Product {
MediaImage(
alt: nil,
mediaContentType: .image,
url: URL.fromString("https://www.alfieproj.com/productimages/medium/1/2612578_22583503_13491037.jpg")
url: URL.fromString("https://images.pexels.com/photos/4428388/pexels-photo-4428388.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1")
)
),
]
Expand Down Expand Up @@ -201,7 +201,7 @@ extension Product {
MediaImage(
alt: nil,
mediaContentType: .image,
url: URL.fromString("https://www.alfieproj.com/productimages/medium/1/2657108_22804950_13918038.jpg")
url: URL.fromString("https://images.pexels.com/photos/9558689/pexels-photo-9558689.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1")
)
),
]
Expand Down Expand Up @@ -238,7 +238,7 @@ extension Product {
MediaImage(
alt: nil,
mediaContentType: .image,
url: URL.fromString("https://www.alfieproj.com/productimages/medium/2/2584579_22478962_13351997.jpg")
url: URL.fromString("https://images.pexels.com/photos/14993680/pexels-photo-14993680/free-photo-of-young-woman-in-a-dress.png?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1")
)
),
]
Expand Down Expand Up @@ -278,7 +278,7 @@ extension Product {
MediaImage(
alt: nil,
mediaContentType: .image,
url: URL.fromString("https://www.alfieproj.com/productimages/medium/1/2593051_22512791_12951251.jpg")
url: URL.fromString("https://images.pexels.com/photos/10283296/pexels-photo-10283296.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1")
)
),
]
Expand Down Expand Up @@ -315,7 +315,7 @@ extension Product {
MediaImage(
alt: nil,
mediaContentType: .image,
url: URL.fromString("https://www.alfieproj.com/productimages/medium/1/2657932_22808834_13869761.jpg")
url: URL.fromString("https://images.pexels.com/photos/1124468/pexels-photo-1124468.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1")
)
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private enum Constants {
#Preview {
HorizontalProductCard(
viewModel: .init(
image: URL(string: "https://www.alfieproj.com/productimages/thumb/1/1262024_22313940_13558933.jpg"),
image: URL(string: "https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"),
designer: "Yves Saint Laurent",
name: "Rouge Pur Couture",
colorTitle: "Color:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private enum Constants {
viewModel: .init(
configuration: .init(size: .small),
productId: "1",
image: URL(string: "https://www.alfieproj.com/productimages/thumb/1/1262024_22313940_13558933.jpg"),
image: URL(string: "https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"),
designer: "Yves Saint Laurent",
name: "Rouge Pur Couture",
priceType: .formattedRange(lowerBound: 65, upperBound: 68, currencyCode: "AUD")
Expand All @@ -273,7 +273,7 @@ private enum Constants {
viewModel: .init(
configuration: .init(size: .medium),
productId: "2",
image: URL(string: "https://www.alfieproj.com/productimages/medium/1/1262024_22313940_13558933.jpg"),
image: URL(string: "https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"),
designer: "Yves Saint Laurent",
name: "Rouge Pur Couture",
priceType: .formattedRange(lowerBound: 65, upperBound: 68, currencyCode: "AUD")
Expand All @@ -286,7 +286,7 @@ private enum Constants {
viewModel: .init(
configuration: .init(size: .large),
productId: "3",
image: URL(string: "https://www.alfieproj.com/productimages/medium/1/1262024_22313940_13558933.jpg"),
image: URL(string: "https://images.pexels.com/photos/9077817/pexels-photo-9077817.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"),
designer: "Yves Saint Laurent",
name: "Rouge Pur Couture",
priceType: .formattedRange(lowerBound: 65, upperBound: 68, currencyCode: "AUD")
Expand Down

0 comments on commit 88f6bb6

Please sign in to comment.