When(/^I begin to create a volume$/) do
  on(Workstation::ArtistBuilderPage).create_volume
end

When(/^I create a new artist$/) do
  @timestamped_name = "test_artist_#{Time.stamp}"
  on(Workstation::ArtistBuilderPage).create_artist
  on(Workstation::AddArtistModal).create_artist(@timestamped_name)
end

Then(/^I should be on the edit artist page$/) do
  on(Workstation::ArtistPage) do |page|
    page.artist_name_element.element.wait_until(&:present?)
    expect(page.artist_name).to include(@timestamped_name)
  end
end

When(/^I create a volume$/) do
  name = "TestVolume#{Time.stamp}"
  puts "using name \"#{name}\""
  on(Workstation::CreateVolumeModal).create_volume(name)
  @timestamped_name = name
end

# Label should be label NAME not number:

Then(/^I should see the Artist Builder profile$/) do
  on(Workstation::ArtistPage).verify_artist_name_created(@timestamped_name)
end

When(/^I attempt to create a volume with no name$/) do
  on(Workstation::ArtistBuilderPage).create_volume
  on(Workstation::CreateVolumeModal).submit_element.when_present.click
end

Then(/^I should see a validation error$/) do
  on(Workstation::AddArtistModal) do |page|
    actual = page.artist_name_error_element.when_present.text
    expect(actual).to include "Missing Name"
  end
end
