-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Hide live preview input and button #3968
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Add a Project Submission' do | ||
let(:lesson) { create(:lesson, :project) } | ||
|
||
before do | ||
Flipper.enable(:v2_project_submissions) | ||
end | ||
|
@@ -12,6 +10,7 @@ | |
end | ||
|
||
context 'when a user is signed in' do | ||
let(:lesson) { create(:lesson, :project) } | ||
let(:user) { create(:user) } | ||
let(:another_user) { create(:user) } | ||
|
||
|
@@ -55,8 +54,33 @@ | |
end | ||
end | ||
|
||
context 'when lesson does not allow previews' do | ||
let(:lesson) { create(:lesson, :project, has_live_preview: false) } | ||
let(:user) { create(:user) } | ||
|
||
before do | ||
sign_in(user) | ||
visit lesson_path(lesson) | ||
end | ||
|
||
it 'adds the submission without a preview' do | ||
Pages::ProjectSubmissions::Form | ||
.new(has_live_preview: false) | ||
.open | ||
.fill_in | ||
.submit | ||
|
||
within(:test_id, 'submissions-list') do | ||
expect(page).to have_content(user.username) | ||
expect(page).to have_link('View code') | ||
expect(page).not_to have_link('Live preview') | ||
Comment on lines
+66
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't done thing kind of thing much before, but it intrigues me. Do you find it generally helpful? Is there a risk of drifting away from reality, since there's such a test specific interface? Or is it more about convenience in this case? Curious to hear your thoughts in general on the goals / benefits / downsides of an approach like this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry @ChargrilledChook, I'm probably being very dense lol. But is this about the page object or the line you commented on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries and my bad, re-reading my comment it is a bit cryptic / stream of consciousness 😅 You're spot on though, I'm referring to the page object There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries @ChargrilledChook , happy to explain the approach I've been using them for a few years at work / on side projects. Heavily inspired by Thoughtbot / Evil Martians and hating having to spend a lot of time figuring out what large specs were actually doing lol. Two biggest benefits for me:
I haven't had too many issues with things drifting. But definitely see how they could. I think the trick is not to overuse them. If everything is a page object, you'd be jumping from file to file and absolutely hating the test suite. These articles were a big help when I first started using them: |
||
end | ||
end | ||
end | ||
|
||
context 'when a user is not signed in' do | ||
it 'they cannot add a project submission' do | ||
lesson = create(:lesson, :project) | ||
visit lesson_path(lesson) | ||
|
||
expect(page).not_to have_button('Add Solution') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mega nit: Demeter
A delegated
previewable?
or similar method might be a nice minor addition to the project submission model? I was going to suggest doing it in the component, but we're calling the same logic from the form tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
previewable
is a much better name. What do you think about us renaming the db column to that? we'd get those nice predicate methods for free.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah mint even better, love that ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a follow up issue to rename it #4003
Best to do it after the react version gets the 🪓