Files
simplex-chat/apps/ios/SimpleX Snapshots/check-previews.py
T
Evgeny @ SimpleX Chat 70b9cf66f4 ios: previews of chat preview and badge billing render fixed dates (#7913)
* ios: snapshot tests render all previews at fixed dates

* ios: previews of your servers and terminal render without errors

* ios: snapshots fill the screen height for lists, skip device migration

* ios: snapshots show the sample user, secondary chat preview has items

* ios: snapshots skip previews of live prices, profiles and console

* ci: references of all iOS previews

* ci: snapshot docs state window height, exclusions and timing

* ios: snapshots skip previews with a blinking caret or a spinner

* ios: snapshots end editing and stop animations, restoring 8 previews

* ci: references of the restored cursor and spinner previews

* ios: sample contact and badge billing footer take fixed preview dates

* ci: references of chat preview and badge billing previews

* ios: chat item previews clip items to bubbles as the chat view does

* ci: references of chat item previews with bubbles

* ci: references of badge previews as rendered after the merge
2026-10-28 05:25:49 +00:00

31 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
import re
import sys
from pathlib import Path
EXCLUDED = {
"AppearanceSettings_Previews",
"BadgesChooseBadgeView_Previews",
"MigrateFromDevice_Previews",
"NewChatView_Previews",
"ServersSummaryView_Previews",
"TerminalView_Previews",
"UserProfilesView_Previews",
}
tests = Path(__file__).with_name("SnapshotTests.swift")
ios = tests.parents[1]
listed = set(re.findall(r"SnapshotScene\((\w+)\.self", tests.read_text()))
errors = []
for path in sorted(ios.rglob("*.swift")):
source = path.read_text()
name = path.relative_to(ios.parent.parent)
for preview in re.findall(r"^[ \t]*struct[ \t]+(\w+)[ \t]*:[ \t]*PreviewProvider\b", source, re.M):
if preview not in listed and preview not in EXCLUDED:
errors.append(f"{name}: {preview} is not in previewScenes() of {tests.name}")
if re.search(r"^[ \t]*#Preview\b", source, re.M):
errors.append(f"{name}: #Preview is not rendered, write a PreviewProvider and add it to previewScenes() of {tests.name}")
print("\n".join(errors) or f"{len(listed)} previews are rendered, {len(EXCLUDED)} are excluded")
sys.exit(1 if errors else 0)