VRFS-3190 : Fix band tests, add new tests for new tabs / cleanup

This commit is contained in:
Steven Miers 2015-06-16 17:55:55 -05:00
parent cfda14e16e
commit e6d1980495
3 changed files with 104 additions and 95 deletions

View File

@ -31,15 +31,15 @@
var friendInput=null
var bandType=null
var bandStatus=null
var concertCount=null
var concertCount=null
var $screen=$("#band-setup")
var $samples = $screen.find(".account-profile-samples")
var $selectedInstruments=[]
var accountProfileSamples = new JK.AccountProfileSamples(app, $screen, loadBandCallback, rest.updateBand)
accountProfileSamples.initialize()
var accountProfileSamples = new JK.AccountProfileSamples(app, $screen, loadBandCallback, rest.updateBand)
accountProfileSamples.initialize()
function navBack() {
if (currentStep>0) {
@ -49,13 +49,13 @@
})
}
}
function navCancel() {
resetForm()
resetForm()
window.history.go(-1)
return false
}
function navNext() {
if (currentStep<STEPS_COUNT-1) {
saveBand(function(band) {
@ -66,41 +66,41 @@
saveBand(function(band) {
resetForm()
showProfile(band.id);
})
})
}
}
function renderCurrentPage() {
function renderCurrentPage() {
$screen.find($(".band-step")).addClass("hidden")
$("#band-setup-step-" + currentStep).removeClass("hidden")
if(currentStep==0) {
if(currentStep==0) {
$("#btn-band-setup-back").addClass("hidden")
$("#btn-band-setup-next").removeClass("hidden").html("SAVE & NEXT")
} else if(currentStep<STEPS_COUNT-1) {
$("#btn-band-setup-next").removeClass("hidden").html("SAVE & NEXT")
} else if(currentStep<STEPS_COUNT-1) {
// if(currentStep==SAMPLE_STEP) {
// accountProfileSamples.renderPlayer(band)
// }
$("#btn-band-setup-back").removeClass("hidden")
$("#btn-band-setup-next").removeClass("hidden").html("SAVE & NEXT")
} else {
$("#btn-band-setup-next").removeClass("hidden").html("SAVE & NEXT")
} else {
$("#btn-band-setup-back").removeClass("hidden")
$("#btn-band-setup-next").removeClass("hidden").html("SAVE & FINISH")
}
renderOptionalControls()
}
function renderOptionalControls(e) {
function renderOptionalControls(e) {
if(e){e.stopPropagation()}
// Is new member selected?
// Is new member selected?
if ($screen.find($('input[name="add_new_members"]:checked')).val()=="yes") {
$screen.find($(".new-member-dependent")).removeClass("hidden")
} else {
$screen.find($(".new-member-dependent")).addClass("hidden")
}
// Is paid gigs selected?
if ($('input[name="paid_gigs"]:checked').val()=="yes") {
// Is paid gigs selected?
if ($('input[name="paid_gigs"]:checked').val()=="yes") {
$screen.find($(".paid-gigs-dependent")).removeClass("hidden")
} else {
$screen.find($(".paid-gigs-dependent")).addClass("hidden")
@ -108,7 +108,7 @@
return false;
}
function isNewBand() {
function isNewBand() {
return bandId==null || typeof(bandId)=='undefined' || bandId.length == 0;
}
@ -143,17 +143,17 @@
// website
$('#band-website').val('');
$("#new-member-no").iCheck('check').attr('checked', 'checked')
$("#paid-gigs-no").iCheck('check').attr('checked', 'checked')
$("#free-gigs-no").iCheck('check').attr('checked', 'checked')
$('#touring-option').val('no')
$("#play-commitment").val('1')
$("#hourly-rate").val("0.0")
$("#gig-minimum").val("0.0")
resetGenres();
$("#gig-minimum").val("0.0")
resetGenres();
renderDesiredExperienceLabel([])
$(friendInput)
@ -202,8 +202,8 @@
if(state) $("#band-region").closest('div.field').addClass('error').end().after(state);
if(city) $("#band-city").closest('div.field').addClass('error').end().after(city);
if(biography) $("#band-biography").closest('div.field').addClass('error').end().after(biography);
if(website) $("#band-website").closest('div.field').addClass('error').end().after(website);
if(genres) $("#band-genres").closest('div.field').addClass('error').end().after(genres);
if(website) $("#band-website").closest('div.field').addClass('error').end().after(website);
if(genres) $("#band-genres").closest('div.field').addClass('error').end().after(genres);
}
function buildBand() {
@ -224,23 +224,23 @@
band.paid_gigs = $('input[name="paid_gigs"]:checked').val()=="yes"
band.free_gigs=$('input[name="free_gigs"]:checked').val()=="yes"
band.touring_option=$('#touring-option').val()=="yes"
band.play_commitment=$("#play-commitment").val()
band.hourly_rate=$("#hourly-rate").val()
band.gig_minimum=$("#gig-minimum").val()
if (currentStep==GENRE_STEP) {
band.genres = getSelectedGenres();
band.validate_genres = true
} else {
band.validate_genres = false
}
$.each($selectedInstruments, function(index, instrument) {
var h = {}
h.instrument_id = instrument.id
h.proficiency_level = instrument.level
band.instruments.push(h)
band.instruments.push(h)
})
if(!isNewBand()) {
@ -298,28 +298,30 @@
}
function saveBand(saveBandSuccessFn) {
unbindNavButtons()
var band = buildBand()
removeErrors()
var band = buildBand()
var saveBandFn = (isNewBand()) ? rest.createBand : rest.updateBand
saveBandFn(band)
.done(function (response) {
.done(function (response) {
bandId = response.id
saveInvitations()
if(saveBandSuccessFn) {
saveBandSuccessFn(band)
}
})
.fail(function (jqXHR) {
.fail(function (jqXHR) {
if(jqXHR.status == 422) {
renderErrors(JSON.parse(jqXHR.responseText))
} else {
app.notifyServerError(jqXHR, "Unable to create band")
}
})
.always(function (jqXHR) {
bindNavButtons()
})
})
.always(function (jqXHR) {
bindNavButtons()
})
}
function createBandInvitations(bandId, onComplete) {
@ -355,9 +357,9 @@
var stepNum = data['d'].substring(4)
if(stepNum) {
currentStep=stepNum
delete data['d'];
delete data['d'];
}
}
}
resetForm();
}
@ -367,9 +369,9 @@
if (!isNewBand()) {
$("#band-change-photo").html('Upload band photo.');
$('.band-photo').removeClass("hidden")
// retrieve and initialize band profile data points
loadBandDetails();
loadBandDetails();
} else {
loadGenres();
@ -391,7 +393,7 @@
}
function loadBandDetails() {
rest.getBand(bandId).done(function (band) {
$("#band-name").val(band.name);
@ -401,7 +403,7 @@
bandType.val(band.band_type)
bandStatus.val(band.band_status)
concertCount.val(band.concert_count)
if (band.add_new_members){
$("#new-member-no").iCheck('check').attr('checked', 'checked')
} else {
@ -424,7 +426,7 @@
$("#play-commitment").val(band.play_commitment)
$("#hourly-rate").val(band.hourly_rate)
$("#gig-minimum").val(band.gig_minimum)
// Initialize avatar
if (band.photo_url) {
$("#band-avatar").attr('src', band.photo_url);
@ -450,7 +452,7 @@
renderDesiredExperienceLabel($selectedInstruments)
accountProfileSamples.renderPlayer(band)
accountProfileSamples.renderPlayer(band)
});
}
@ -582,7 +584,7 @@
} else {
context.JK.dropdown($city);
}
}
}
function addInvitation(value, data) {
if ($('#selected-band-invitees div[user-id=' + data + ']').length === 0) {
@ -602,27 +604,27 @@
context.location = '/client#/band/setup/photo/' + bandId;
return false;
}
function removeInvitation(evt) {
delete selectedFriendIds[$(evt.currentTarget).parent().attr('user-id')];
$(evt.currentTarget).closest('.invitation').remove();
}
function bindNavButtons() {
function bindNavButtons() {
$('#btn-band-setup-back').on("click", function (e) {
e.stopPropagation()
e.stopPropagation()
navBack()
return false
})
$('#btn-band-setup-cancel').on("click", function (e) {
e.stopPropagation()
e.stopPropagation()
navCancel()
return false
})
$('#btn-band-setup-next').on("click", function (e) {
e.stopPropagation()
e.stopPropagation()
navNext()
return false
})
@ -636,9 +638,9 @@
$('#btn-band-setup-back').off("click")
$('#btn-band-setup-cancel').off("click")
$('#btn-band-setup-next').off("click")
$('#btn-band-setup-back').addClass("disabled")
$('#btn-band-setup-cancel').addClass("disabled")
$('#btn-band-setup-next').addClass("disabled")
$('#btn-band-setup-back').addClass("disabled")
$('#btn-band-setup-cancel').addClass("disabled")
$('#btn-band-setup-next').addClass("disabled")
}
function events() {
@ -649,8 +651,8 @@
// friend input focus
$('#band-invitee-input').focus(function () {
$(this).val('');
});
});
$('#band-country').on('change', function (evt) {
evt.stopPropagation();
loadRegions();
@ -682,22 +684,22 @@
$('a#choose-desired-experience').on("click", chooseExperience)
$('#band-setup').on('ifToggled', 'input[type="radio"].dependent-master', renderOptionalControls);
$(friendInput).focus(function() { $(this).val(''); })
}
function chooseExperience(e) {
e.stopPropagation()
ui.launchInstrumentSelectorDialog("new member(s)", $selectedInstruments, function(selectedInstruments) {
$selectedInstruments = selectedInstruments
function chooseExperience(e) {
e.stopPropagation()
ui.launchInstrumentSelectorDialog("new member(s)", $selectedInstruments, function(selectedInstruments) {
$selectedInstruments = selectedInstruments
renderDesiredExperienceLabel($selectedInstruments)
return false
})
return false
return false
}
function loadBandCallback() {
return (isNewBand()) ? {} : rest.getBand(bandId)
return (isNewBand()) ? {} : rest.getBand(bandId)
}
function initialize(invitationDialogInstance, friendSelectorDialog) {
@ -716,7 +718,7 @@
bandType=$("#band-type")
bandStatus=$("#band-status")
concertCount=$("#concert-count")
app.bindScreen('band/setup', screenBindings)
$screen.find('input[type=radio]').iCheck({
@ -725,11 +727,11 @@
inheritClass: true
})
profileUtils.initializeHelpBubbles()
profileUtils.initializeHelpBubbles()
}
this.initialize = initialize;
this.afterShow = afterShow;
return this;
};
};
})(window, jQuery);

View File

@ -29,11 +29,7 @@
label for="band-name"
| Band Name:
input#band-name type="text" maxlength="1024" value=""
/ td#tdBandWebsite[]
/ .field
/ label for="band-website"
/ | Web Site:
/ input#band-website[type="text" maxlength="4000" value=""]
tr
td.band-country
.field.band-field
@ -175,7 +171,7 @@
= render "clients/profile_edit_presence_controls"
#band-setup-step-4.band-step.content-wrapper
h2 invite members
h2 set up band: invite members
br
#band-setup-invite-musicians
br
@ -201,14 +197,6 @@
= image_tag("content/icon_google.png", :size => "24x24", :align => "absmiddle")
.right.mt5.ml5
| Google+
/ br clear="all"
/ .right
/ a#btn-band-setup-back.button-grey
/ | BACK
/ |   
/ a#btn-band-setup-save.button-orange
/ | CREATE BAND
/ .clearall
br clear="all"
.right

View File

@ -25,27 +25,45 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
expect(page).to have_selector('#band-setup-title')
end
def fill_out_band_setup_form(band, biography, params={})
def fill_out_band_setup_form(band, biography, country="United States", region="Texas", city="Austin", params={})
navigate_band_setup unless URI.parse(current_url).fragment == '/band/setup/new'
params['band-name'] ||= band || "Default band name"
params['band-biography'] ||= biography || "Default band biography"
within('#band-setup-form') do
params.each do |field, value|
fill_in field, with: "#{value}"
fill_in field, with: value
end
# Move to experience pane:
#first('#band-genres input[type="checkbox"]').trigger(:click)
end
jk_select(country, '#band-country')
jk_select(region, '#band-region')
jk_select(city, '#band-city')
sleep 1 # work around race condition
find('#btn-band-setup-next').trigger(:click)
find('h2', text: 'Step 2: Add Band Members')
find('h2', text: 'set up band: musical experience')
end
def complete_band_setup_form(band, biography, params={})
fill_out_band_setup_form(band, biography, params)
find('#btn-band-setup-save').trigger(:click)
def complete_band_setup_form(band, biography, country="United States", region="Texas", city="Austin", params={})
fill_out_band_setup_form(band, biography, country, region, city, params)
find(:css, "#african").set(true)
find('#btn-band-setup-next').trigger(:click)
find('h2', text: 'set up band: current interests')
find('#btn-band-setup-next').trigger(:click)
find('h2', text: 'set up band: online presence & performance samples')
find('#btn-band-setup-next').trigger(:click)
find('h2', text: 'set up band: invite members')
# Save
find('#btn-band-setup-next').trigger(:click)
sleep(1)
end
context "band profile - new band setup" do
@ -71,16 +89,18 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
find('#btn-band-setup-next').trigger(:click)
expect(page).to have_selector('#band-setup .band-name .error-text li', text: "can't be blank")
expect(page).to have_selector('#band-setup .band-biography .error-text li', text: "can't be blank")
#expect(page).to have_selector('#band-setup .band-genres .error-text li', text: "At least 1 genre is required.")
complete_band_setup_form("Band name", "Band biography")
complete_band_setup_form("Test Band name", "Test Band biography")
expect(page).to have_selector('#band-profile-name', text: "Band name")
expect(page).to have_selector('#band-profile-biography', text: "Band biography")
expect(page).to have_selector('#band-profile-name', text: "Test Band name")
expect(page).to have_selector('#band-profile-biography', text: "Test Band biography")
end
it "limits genres to 3" do
pending "Move this to experience pane"
#expect(page).to have_selector('#band-setup .band-genres .error-text li', text: "At least 1 genre is required.")
genres = Genre.limit(4)
navigate_band_setup
within('#band-setup-form') do
@ -136,8 +156,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
band_attributes = {
name: 'Radical D00dz',
biography: 'Just a bunch of EXTREME dudes who ROCK professionally!!',
# website: 'www.radicald00dz.com', # not displayed - VRFS-1617
# country: 'US', # not displayed
country: 'US',
city: 'Lubbock',
state: 'TX'
}
@ -188,7 +207,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
find("tr[user-id='#{friend.id}']").trigger(:click)
expect(page).to have_selector("tr.selected[user-id='#{friend.id}']")
find('#btn-save-friends').trigger(:click)
find('#btn-band-setup-save').trigger(:click)
find('#btn-band-setup-next').trigger(:click)
sleep 1 # ensure the transaction commits..
find('#band-profile-members-link').trigger(:click)