Skip to content

Commit 507b89b

Browse files
authored
Add basic feature test for problem browsing (#300)
This page relies on a lot of ApplicationPresenter / StrongPresenter features which I am trying to write out, so seemed worthwhile having a small test for faster iterate.
2 parents 912e0b2 + c6ca244 commit 507b89b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require "spec_helper"
2+
3+
feature "Problem browsing" do
4+
let(:user) { FactoryBot.create(:superadmin) }
5+
let!(:problem) { FactoryBot.create(:problem) }
6+
7+
scenario "Admin browses and view problems" do
8+
login_as user, scope: :user
9+
10+
visit "/problems"
11+
12+
headers = find(".main_table > thead > tr").all("th").map(&:text)
13+
rows = find(".main_table > tbody").all("tr").map { |r| r.all("td").map(&:text) }
14+
expect(headers).to eq(["", "Name", "Input", "Output", "Memory Limt", "Time Limit", "Owner", "Progress", "", ""])
15+
expect(rows.length).to eq(Problem.count)
16+
17+
expect(rows[0]).to eq(["", problem.name, problem.input, problem.output, "1 MB", "1.0 s", "System", "", "Edit", "Destroy"])
18+
end
19+
end

0 commit comments

Comments
 (0)