Skip to content

Commit

Permalink
Add News Items locators
Browse files Browse the repository at this point in the history
  • Loading branch information
d4r1091 committed May 16, 2024
1 parent e3503f4 commit ba0c1ec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Client/Ecosia/UI/NTP/News/NTPNewsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,16 @@ final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell {
func configure(_ model: NewsModel, images: Images, row: Int, totalCount: Int) {
let titleString = model.text.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression)
title.text = titleString
title.accessibilityIdentifier = "news_item_title_\(row)"
let publishDateString = RelativeDateTimeFormatter().localizedString(for: model.publishDate, relativeTo: .init())
bottomLabel.text = publishDateString
bottomLabel.accessibilityIdentifier = "news_item_published_date_\(row)"
bottomIcon.isHidden = true
highlightLabel.isHidden = true

imageUrl = model.imageUrl
image.image = nil
image.accessibilityIdentifier = "news_item_image_\(row)"
images.load(self, url: model.imageUrl) { [weak self] in
guard self?.imageUrl == $0.url else { return }
self?.updateImage($0.data)
Expand All @@ -200,6 +203,7 @@ final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell {
applyTheme()

isAccessibilityElement = true
accessibilityIdentifier = "news_item"
accessibilityLabel = "\(titleString); \(publishDateString)"
accessibilityTraits = .link
shouldGroupAccessibilityChildren = true
Expand Down

0 comments on commit ba0c1ec

Please sign in to comment.