Skip to content

Commit

Permalink
Add setup for bootcamp system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iHiD authored and dem4ron committed Jan 28, 2025
1 parent dd779f4 commit e463a9c
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 18 deletions.
8 changes: 7 additions & 1 deletion app/models/bootcamp/exercise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def readonly_ranges

private
def file_contents(filename)
File.read(Rails.root / "bootcamp_content/projects/#{project.slug}/exercises/#{slug}/#{filename}")
File.read(root_dir / "projects/#{project.slug}/exercises/#{slug}/#{filename}")
end

def root_dir
return Rails.root / "test/repos/bootcamp_content" if Rails.env.test?

Rails.root / "bootcamp_content"
end
end
5 changes: 0 additions & 5 deletions app/views/layouts/bootcamp-ui.haml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@
%meta{ name: "turbo-prefetch", content: "false" }
%meta{ name: "user-id", content: current_user&.id }
%link{ href: "/manifest.json", rel: "manifest" }
%link{ href: "/icon.png", rel: "icon", type: "image/png" }
%link{ href: "/icon.svg", rel: "icon", type: "image/svg+xml" }
%link{ href: "/icon.png", rel: "apple-touch-icon" }
-# = javascript_include_tag "application", "data-turbo-track": "reload", type: "module", crossorigin: :anonymous
= javascript_include_tag "bootcamp-ui-js", "data-turbo-track": "reload", type: "module", crossorigin: :anonymous
%body{ class: body_class }
Expand Down
5 changes: 5 additions & 0 deletions test/factories/bootcamp/exercises.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
description { "Exercise Description" }
level_idx { (Bootcamp::Level.first || create(:bootcamp_level)).idx }
end

trait :penguin do
slug { "penguin" }
project { Bootcamp::Project.find_by(slug: "drawing") || create(:bootcamp_project, slug: "drawing") }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"idx": 4,
"title": "Penguin",
"description": "Make the penguin symmetrical",
"project_type": "draw",
"level": 1,
"concepts": [],
"tests_type": "state",
"readonly_ranges": [],
"tasks": [
{
"name": "Draw the scene",
"tests": [
{
"slug": "draw-scence",
"name": "Make the penguin symmetrical.",
"description_html": "Fix all the TODO comments to make the penguin symmetrical.",
"function": "main",
"checks": [
{
"name": "getRectangleAt(0, 0, 100, 100)",
"matcher": "toExist",
"error_html": "The sky has gone wrong."
},
{
"name": "getRectangleAt(0, 70, 100, 30)",
"matcher": "toExist",
"error_html": "The ground has gone wrong."
},
{
"name": "getEllipseAt(28, 55, 10, 25)",
"matcher": "toExist",
"error_html": "The left wing doesn't seem right."
},
{
"name": "getEllipseAt(72, 55, 10, 25)",
"matcher": "toExist",
"error_html": "The right wing doesn't seem right."
},
{
"name": "getEllipseAt(50, 53, 25, 40)",
"matcher": "toExist",
"error_html": "The outer body has gone wrong."
},
{
"name": "getEllipseAt(50, 50, 21, 39)",
"matcher": "toExist",
"error_html": "The inner body has gone wrong."
},
{
"name": "getCircleAt(50, 31, 23)",
"matcher": "toExist",
"error_html": "The head has gone wrong."
},
{
"name": "getEllipseAt(41, 32, 11, 14)",
"matcher": "toExist",
"error_html": "The left side of the face doesn't look right."
},
{
"name": "getEllipseAt(59, 32, 11, 14)",
"matcher": "toExist",
"error_html": "The right side of the face doesn't look right."
},
{
"name": "getEllipseAt(50, 40, 16, 11)",
"matcher": "toExist",
"error_html": "The lower part of the face doesn't look right."
},
{
"name": "getCircleAt(42, 33, 3)",
"matcher": "toExist",
"error_html": "The left eye seems off."
},
{
"name": "getCircleAt(43, 34, 1)",
"matcher": "toExist",
"error_html": "The left iris seems off."
},
{
"name": "getCircleAt(58, 33, 3)",
"matcher": "toExist",
"error_html": "The right eye seems off."
},
{
"name": "getCircleAt(57, 34, 1)",
"matcher": "toExist",
"error_html": "The right iris seems off."
},
{
"name": "getEllipseAt(40, 93, 7, 4)",
"matcher": "toExist",
"error_html": "The left foot's gone astray."
},
{
"name": "getEllipseAt(60, 93, 7, 4)",
"matcher": "toExist",
"error_html": "The right foot's not right."
},
{
"name": "getTriangleAt(46, 38, 54, 38, 50, 47)",
"matcher": "toExist",
"error_html": "The nose isn't right."
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Light blue background
fill_color_hex("#ADD8E6")
rectangle(0, 0, 100, 100)

// Ground
fill_color_hex("#ffffff") // Ice ground
rectangle(0, 70, 100, 30) // Ice ground

// Penguin wings
fill_color_hex("#000000") // Black
ellipse(28, 55, 10, 25) // Left wing
ellipse(72, 55, 10, 25) // Right wing

// Penguin body
fill_color_hex("#000000") // Black for the body
ellipse(50, 53, 25, 40) // Outer body (oval shape)
fill_color_hex("#ffffff") // White for the belly
ellipse(50, 50, 21, 39) // Inner belly (oval shape)

// Penguin head
fill_color_hex("#000000") // Black
circle(50, 31, 23) // Head (circle)
fill_color_hex("#ffffff") // White for the face
ellipse(41, 32, 11, 14) // Left part of the face
ellipse(59, 32, 11, 14) // Right part of the face
ellipse(50, 40, 16, 11) // Lower part of the face

// Penguin eyes
fill_color_hex("#000000") // Black
circle(42, 33, 3) // Left eye
fill_color_hex("#ffffff") // White
circle(43, 34, 1) // Left iris

fill_color_hex("#000000") // Black
circle(58, 33, 3) // Right eye
fill_color_hex("#ffffff") // White
circle(57, 34, 1) // Right iris

// Feet
fill_color_hex("#FFA500")
ellipse(40, 93, 7, 4)
ellipse(60, 93, 7, 4)
triangle(46, 38, 54, 38, 50, 47)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

This is fun!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Follow the `TODO` comments to make the penguin symmetrical.

As you get each bit right, tidy up the comments by removing the `TODO` and replacing it with a nicer comment.

Use the "Check Scenarios" button regularly, and have fun!
15 changes: 3 additions & 12 deletions test/system/bootcamp/editor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@
module Bootcamp
class EditorTest < ApplicationSystemTestCase
test "shows to basic user" do
email = "#{SecureRandom.uuid}@test.com"
ubd = create :user_bootcamp_data, email:, paid_at: Time.current
user = create(:user, email:)
project = create :bootcamp_project
exercise = create :bootcamp_exercise, bootcamp_project: project

# Always does this once by default anyway
User::Bootcamp::SubscribeToOnboardingEmails.expects(:defer).with(ubd).twice

User::Bootstrap.(user)
assert user.reload.bootcamp_attendee?
user = create(:user, bootcamp_attendee: true)
exercise = create :bootcamp_exercise, :penguin

use_capybara_host do
sign_in!(user)
visit bootcamp_project_exercise_url(project, exercise)
visit bootcamp_project_exercise_url(exercise.project, exercise)

assert_text "Welcome to the Exercism Bootcamp!"
end
Expand Down

0 comments on commit e463a9c

Please sign in to comment.