test: assert playoff recreation matchups
This commit is contained in:
parent
b930ff574f
commit
bcc93099bf
|
|
@ -130,7 +130,7 @@ module TurniereE2E
|
||||||
|
|
||||||
created_key = created_keys.fetch(index)
|
created_key = created_keys.fetch(index)
|
||||||
checkpoints[created_key] = summarize_tournament(tournament).merge(
|
checkpoints[created_key] = summarize_tournament(tournament).merge(
|
||||||
playoff_team_names: playoff_team_names(tournament)
|
playoff_matchups: playoff_matchups(tournament)
|
||||||
)
|
)
|
||||||
return result(session: session, tournament: tournament, checkpoints: checkpoints, stop_at: stop_at) if stop_at == created_key
|
return result(session: session, tournament: tournament, checkpoints: checkpoints, stop_at: stop_at) if stop_at == created_key
|
||||||
|
|
||||||
|
|
@ -711,11 +711,17 @@ module TurniereE2E
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def playoff_team_names(tournament)
|
def playoff_matchups(tournament)
|
||||||
playoff_matches(tournament)
|
entry_stage = tournament.fetch(:stages)
|
||||||
.flat_map { |match| match.fetch(:match_scores).map { |score| score.dig(:team, :name) } }
|
.reject { |stage| stage.fetch(:level) == -1 }
|
||||||
.uniq
|
.max_by { |stage| stage.fetch(:level) }
|
||||||
.sort
|
entry_stage.fetch(:matches)
|
||||||
|
.sort_by { |match| match.fetch(:position) }
|
||||||
|
.map do |match|
|
||||||
|
match.fetch(:match_scores)
|
||||||
|
.map { |score| score.dig(:team, :name) }
|
||||||
|
.sort
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_tournament_profile!(tournament_id)
|
def fetch_tournament_profile!(tournament_id)
|
||||||
|
|
|
||||||
|
|
@ -248,8 +248,8 @@ RSpec.describe 'Tournament follower sync HTTP E2E' do
|
||||||
|
|
||||||
source = fetch_tournament(client: source_anonymous_client, tournament_id: source.fetch(:id))
|
source = fetch_tournament(client: source_anonymous_client, tournament_id: source.fetch(:id))
|
||||||
follower = wait_for_tournament_sync!(source_tournament_id: source.fetch(:id), follower_tournament_id: follower.fetch(:id))
|
follower = wait_for_tournament_sync!(source_tournament_id: source.fetch(:id), follower_tournament_id: follower.fetch(:id))
|
||||||
expect(playoff_team_names(source)).to eq(round.fetch(:expected_playoff_team_names))
|
expect(playoff_matchups(source)).to eq(round.fetch(:expected_playoff_matchups))
|
||||||
expect(playoff_team_names(follower)).to eq(round.fetch(:expected_playoff_team_names))
|
expect(playoff_matchups(follower)).to eq(round.fetch(:expected_playoff_matchups))
|
||||||
expect(tournament_signature(follower)).to eq(tournament_signature(source))
|
expect(tournament_signature(follower)).to eq(tournament_signature(source))
|
||||||
|
|
||||||
next if index == rounds.size - 1
|
next if index == rounds.size - 1
|
||||||
|
|
@ -534,7 +534,10 @@ RSpec.describe 'Tournament follower sync HTTP E2E' do
|
||||||
'G2-S1' => 3,
|
'G2-S1' => 3,
|
||||||
'G2-S2' => 1
|
'G2-S2' => 1
|
||||||
},
|
},
|
||||||
expected_playoff_team_names: %w[G1-S1 G2-S1]
|
expected_playoff_matchups: [
|
||||||
|
%w[G1-S1 G2-S2],
|
||||||
|
%w[G1-S2 G2-S1]
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scores_by_team_name: {
|
scores_by_team_name: {
|
||||||
|
|
@ -543,7 +546,10 @@ RSpec.describe 'Tournament follower sync HTTP E2E' do
|
||||||
'G2-S1' => 0,
|
'G2-S1' => 0,
|
||||||
'G2-S2' => 4
|
'G2-S2' => 4
|
||||||
},
|
},
|
||||||
expected_playoff_team_names: %w[G1-S2 G2-S2]
|
expected_playoff_matchups: [
|
||||||
|
%w[G1-S2 G2-S1],
|
||||||
|
%w[G1-S1 G2-S2]
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scores_by_team_name: {
|
scores_by_team_name: {
|
||||||
|
|
@ -552,7 +558,10 @@ RSpec.describe 'Tournament follower sync HTTP E2E' do
|
||||||
'G2-S1' => 2,
|
'G2-S1' => 2,
|
||||||
'G2-S2' => 5
|
'G2-S2' => 5
|
||||||
},
|
},
|
||||||
expected_playoff_team_names: %w[G1-S1 G2-S2]
|
expected_playoff_matchups: [
|
||||||
|
%w[G1-S1 G2-S1],
|
||||||
|
%w[G1-S2 G2-S2]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
@ -590,13 +599,17 @@ RSpec.describe 'Tournament follower sync HTTP E2E' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def playoff_team_names(tournament)
|
def playoff_matchups(tournament)
|
||||||
tournament.fetch(:stages)
|
entry_stage = tournament.fetch(:stages)
|
||||||
.select { |stage| stage.fetch(:level) >= 0 }
|
.select { |stage| stage.fetch(:level) >= 0 }
|
||||||
.flat_map { |stage| stage.fetch(:matches) }
|
.max_by { |stage| stage.fetch(:level) }
|
||||||
.flat_map { |match| match.fetch(:match_scores).map { |score| seed_label(score.dig(:team, :name)) } }
|
entry_stage.fetch(:matches)
|
||||||
.uniq
|
.sort_by { |match| match.fetch(:position) }
|
||||||
.sort
|
.map do |match|
|
||||||
|
match.fetch(:match_scores)
|
||||||
|
.map { |score| seed_label(score.dig(:team, :name)) }
|
||||||
|
.sort
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def seed_label(team_name)
|
def seed_label(team_name)
|
||||||
|
|
|
||||||
|
|
@ -65,12 +65,21 @@ RSpec.describe 'Tournament lifecycle HTTP E2E' do
|
||||||
result = runner.run_group_stage_playoff_recreation
|
result = runner.run_group_stage_playoff_recreation
|
||||||
checkpoints = result.fetch(:checkpoints)
|
checkpoints = result.fetch(:checkpoints)
|
||||||
|
|
||||||
expect(checkpoints.fetch(:first_playoffs_created).fetch(:playoff_team_names)).to eq(%w[G1-S1 G2-S1])
|
expect(checkpoints.fetch(:first_playoffs_created).fetch(:playoff_matchups)).to eq([
|
||||||
|
%w[G1-S1 G2-S2],
|
||||||
|
%w[G1-S2 G2-S1]
|
||||||
|
])
|
||||||
expect(checkpoints.fetch(:first_playoffs_deleted).fetch(:stage_summaries).map { |stage| stage.fetch(:level) }).to eq([-1])
|
expect(checkpoints.fetch(:first_playoffs_deleted).fetch(:stage_summaries).map { |stage| stage.fetch(:level) }).to eq([-1])
|
||||||
expect(checkpoints.fetch(:first_playoffs_deleted).fetch(:stage_summaries).first.fetch(:state)).to eq('in_progress')
|
expect(checkpoints.fetch(:first_playoffs_deleted).fetch(:stage_summaries).first.fetch(:state)).to eq('in_progress')
|
||||||
expect(checkpoints.fetch(:second_playoffs_created).fetch(:playoff_team_names)).to eq(%w[G1-S2 G2-S2])
|
expect(checkpoints.fetch(:second_playoffs_created).fetch(:playoff_matchups)).to eq([
|
||||||
|
%w[G1-S2 G2-S1],
|
||||||
|
%w[G1-S1 G2-S2]
|
||||||
|
])
|
||||||
expect(checkpoints.fetch(:second_playoffs_deleted).fetch(:stage_summaries).map { |stage| stage.fetch(:level) }).to eq([-1])
|
expect(checkpoints.fetch(:second_playoffs_deleted).fetch(:stage_summaries).map { |stage| stage.fetch(:level) }).to eq([-1])
|
||||||
expect(checkpoints.fetch(:third_playoffs_created).fetch(:playoff_team_names)).to eq(%w[G1-S1 G2-S2])
|
expect(checkpoints.fetch(:third_playoffs_created).fetch(:playoff_matchups)).to eq([
|
||||||
|
%w[G1-S1 G2-S1],
|
||||||
|
%w[G1-S2 G2-S2]
|
||||||
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue