Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/dining-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- '.github/workflows/dining-ui.yml'
- '.maestro/dining.yaml'
- '.maestro/dining/**'
- 'Koin/Presentation/Dining/**'
- 'Koin/Presentation/Home/Home/SubViews/DiningView/**'

Expand Down Expand Up @@ -70,7 +71,7 @@ jobs:
echo 'Stage simulator app not found' >&2
exit 1

- name: Verify guest dining entry and meal change
- name: Verify guest dining entry, meal and date results
env:
MAESTRO_VERSION: '2.2.0'
run: |
Expand Down
26 changes: 16 additions & 10 deletions .maestro/dining.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
appId: com.bcsdlab.koin.stage
name: Guest dining entry and meal content change
name: Guest dining entry, meal and date content changes
---
- launchApp:
clearState: true
Expand All @@ -16,17 +16,23 @@ name: Guest dining entry and meal content change
- extendedWaitUntil:
visible: '아침'
timeout: 30000
- runScript: dining/expectations.js
- tapOn:
id: dining-date-${output.baselineDate}
- tapOn: '아침'
- extendedWaitUntil:
visible:
id: dining-menu-0
timeout: 30000
- evalScript: ${output.expected = output.breakfast}
- runFlow: dining/assert-result.yaml
- takeScreenshot: dining-breakfast
- tapOn: '저녁'
- extendedWaitUntil:
visible:
id: dining-menu-2
timeout: 30000
- evalScript: ${output.expected = output.dinner}
- runFlow: dining/assert-result.yaml
- assertNotVisible:
id: dining-menu-0
id: dining-menu-0-${output.baselineDate}
- takeScreenshot: dining-dinner
- tapOn:
id: dining-date-${output.alternateDate}
- evalScript: ${output.expected = output.alternateDinner}
- runFlow: dining/assert-result.yaml
- assertNotVisible:
id: dining-menu-2-${output.baselineDate}
- takeScreenshot: dining-date-dinner
25 changes: 25 additions & 0 deletions .maestro/dining/assert-result.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
appId: com.bcsdlab.koin.stage
---
- assertVisible:
id: dining-date-${output.expected.date}
selected: true
# The page is identified by the completed request's date, not the picker's date.
- extendedWaitUntil:
visible:
id: ${output.expected.page}
timeout: 30000
- runFlow:
when:
true: ${output.expected.empty}
commands:
- assertVisible: '오늘은 식단이 없어요\.'
- runFlow:
when:
true: ${!output.expected.empty}
commands:
- scrollUntilVisible:
element:
id: ${output.expected.dish}
text: ${output.expected.text}
direction: DOWN
timeout: 15000
46 changes: 46 additions & 0 deletions .maestro/dining/expectations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Both UTC dates are inside the device's seven-day picker, even across time zones.
const today = new Date();
const baseline = today.toISOString().slice(0, 10);
today.setUTCDate(today.getUTCDate() - 1);
const alternate = today.toISOString().slice(0, 10);

function dateKey(date) {
return date.slice(2).replace(/-/g, '');
}

function fetchDay(date) {
const response = http.get('https://api.stage.koreatech.in/dinings?date=' + dateKey(date));
if (!response.ok) throw new Error('Stage dining ' + date + ': HTTP ' + response.status);
const rows = json(response.body);
if (!Array.isArray(rows) || rows.some(row => row.date !== date)) {
throw new Error('Unexpected dining response for ' + date);
}
return rows;
}

function result(rows, date, type, index) {
const places = ['A코너', 'B코너', 'C코너', '능수관', '2캠퍼스'];
const cards = rows.filter(row => row.type === type && places.includes(row.place) &&
!(row.menu && row.menu[0] === '미운영'));
const key = dateKey(date);
const expected = { date: key, page: 'dining-menu-' + index + '-' + key, empty: cards.length === 0 };
if (expected.empty) return expected;

// Check an actual dish on the first operating card with menu text, not a tab or footer.
cards.sort((a, b) => places.indexOf(a.place) - places.indexOf(b.place));
for (const card of cards) {
const offset = (card.menu || []).findIndex(name => name.trim().length > 0);
if (offset < 0) continue;
expected.dish = 'dining-dish-' + card.id + '-' + offset;
expected.text = '^' + card.menu[offset].replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '$';
return expected;
}
throw new Error('Operating cards have no menu text: ' + date + ' ' + type);
}

const baselineRows = fetchDay(baseline);
output.baselineDate = dateKey(baseline);
output.alternateDate = dateKey(alternate);
output.breakfast = result(baselineRows, baseline, 'BREAKFAST', 0);
output.dinner = result(baselineRows, baseline, 'DINNER', 2);
output.alternateDinner = result(fetchDay(alternate), alternate, 'DINNER', 2);
1 change: 1 addition & 0 deletions Koin/Domain/Model/Dining/DiningList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation

struct DiningList: Equatable {
let date: Date
let diningType: DiningType
var items: [DiningItem]
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ final class DefaultFetchDiningListUseCase: FetchDiningListUseCase {
DiningType.allCases.map { type in
let items = self?.filterByDiningType(diningList, type: type) ?? []
return DiningList(
date: date,
diningType: type,
items: self?.sortDiningList(items) ?? []
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct DiningDateRowView: View {
}
}
.buttonStyle(.plain)
.accessibilityIdentifier("dining-date-\(configuration.date.formatDateToYYMMDD())")
.accessibilityAddTraits(configuration.isSelected ? .isSelected : [])
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct DiningMenuListView: View {
.padding(.vertical, 20)
}
.scrollIndicators(.hidden)
.accessibilityIdentifier("dining-menu-\(list.diningType.index)")
.accessibilityIdentifier("dining-menu-\(list.diningType.index)-\(list.date.formatDateToYYMMDD())")
.background{
if list.items.isEmpty {
DiningEmptyView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,13 @@ extension DiningMenuRowView {
],
spacing: 0
) {
ForEach(Array(item.menu.enumerated()), id: \.offset) { _, menu in
ForEach(Array(item.menu.enumerated()), id: \.offset) { index, menu in
Text(menu)
.font(.appFont(.pretendardRegular, size: 14))
.foregroundStyle(Color.appColor(.neutral800))
.padding(.vertical, 4)
.lineLimit(1)
.accessibilityIdentifier("dining-dish-\(item.id)-\(index)")
}
}
}
Expand Down
Loading