Files
mip/tests/drawingtests.rb
2008-02-12 18:33:56 +00:00

167 lines
9.7 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#---
#This unit test checks the drawings screen.
#---
class Test_04_drawings_screen < Test::Unit::TestCase
#
#Test we can logon to the system using the webmip administrator users login credentials and check that
#all the columns required for the report appears with the button to create a new drawings record
#
def test_01_drawing_screen_appears
@@ie.goto(LOGIN)
#now we'll need to login
login(DEFAULT, DEFAULT_PWD)
menu('Administration')
menu('Drawings')
#assert(@@ie.contains_text('Drawings'),'The drawing screen did not appear')
#assert(@@ie.contains_text('Code'),'The drawing code column did not appear')
#assert(@@ie.contains_text('Description'),'The drawing description column did not appear')
#assert(@@ie.contains_text('no data found'),'Some data must have appeared, expected to find no records')
assert(@@ie.button(:id, 'create').exists?,'The create button was not available')
end
#
#Check that the Create/Edit Drawing form can be accessed using the Create button on the Drawings report,
#all the required columns appears on the screen along with create and cancel buttons
# assert(@@ie.select_list(:id, 'P5_COLUMN_NAMES').exists?,'The column headings field was not available')
#
def test_02_create_drawing_screen_appears
@@ie.button(:id, 'create').click
@@ie.wait
assert(@@ie.contains_text('Create/Edit Drawings'),'The create/edit drawing screen did not appear')
assert(@@ie.text_field(:id, 'P53_CODE').exists?,'The drawings code field is not available')
assert(@@ie.text_field(:id, 'P53_DESCRIPTION').exists?,'The drawings description field is not available')
assert(@@ie.button(:id, 'create').exists?,'The create button was not available')
assert(@@ie.button(:id, 'cancel').exists?,'The cancel button was not available')
end
#
#Check that the Create/Edit Drawing form allows data to be inserted to create a new drawing
#Check that the new drawing record appears in the report
#
def test_03_create_drawing
@@ie.text_field(:id, 'P53_CODE').set("D1")
@@ie.text_field(:id, 'P53_DESCRIPTION').set("Drawing for housing")
@@ie.button(:id, 'create').click
@@ie.wait
assert(@@ie.contains_text('Drawings'),'The drawing screen did not appear')
assert(@@ie.contains_text('D1'),'The new record with drawing code D1 did not appear')
assert(@@ie.contains_text('Drawing for housing'),'The description for D1, Drawing for housing did not appear')
@@ie.button(:id, 'create').click
@@ie.wait
assert(@@ie.contains_text('Create/Edit Drawings'),'The create/edit drawing screen did not appear')
assert(@@ie.text_field(:id, 'P53_CODE').exists?,'The drawings code field is not available')
assert(@@ie.text_field(:id, 'P53_DESCRIPTION').exists?,'The drawings description field is not available')
assert(@@ie.button(:id, 'create').exists?,'The create button was not available')
assert(@@ie.button(:id, 'cancel').exists?,'The cancel button was not available')
@@ie.text_field(:id, 'P53_CODE').set("D2")
@@ie.text_field(:id, 'P53_DESCRIPTION').set("Drawing for module")
@@ie.button(:id, 'create').click
@@ie.wait
assert(@@ie.contains_text('Drawings'),'The drawing screen did not appear')
assert(@@ie.contains_text('D2'),'The new record with drawing code D2 did not appear')
assert(@@ie.contains_text('Drawing for module'),'The description for D2, Drawing for module did not appear')
end
#
#Check that the D1 code links to the Create/Edit Drawing form and the form appears with the correct data
#in the fields. Check that the drawing description can be updated and the updated record appears in the Drawings report
#
def test_04_update_drawing
@@ie.link(:text, 'D1').click
assert(@@ie.text_field(:id, 'P53_CODE').verify_contains('D1'),'The drawing code field did not contain value D1')
assert(@@ie.text_field(:id, 'P53_DESCRIPTION').verify_contains('Drawing for housing'),'The drawing description field did not contain value Drawing for housing')
assert(@@ie.button(:id, 'cancel').exists?,'The cancel button was not available')
assert(@@ie.button(:id, 'delete').exists?,'The delete button was not available')
assert(@@ie.button(:id, 'apply_changes').exists?,'The Apply Changes button was not available')
assert(@@ie.button(:id, 'upload').exists?,'The file upload/replace button was not available')
@@ie.button(:id, 'upload').click
@@ie.wait
assert(@@ie.contains_text('Upload File'),'The file upload screen did not appear')
assert(@@ie.button(:id, 'P41_FILE_UPLOAD').exists?,'The file upload field was not available')
#
#Upload a file to the drawing and check that we get a success message
#
filetoupload = 'c:\\ruby\\LICENSE.txt'
@@ie.file_field(:id, 'P41_FILE_UPLOAD').set(filetoupload)
@@ie.button(:id, 'upload').click
@@ie.wait
assert(@@ie.button(:id, 'upload').exists?,'The file upload/replace button was not available')
assert(@@ie.contains_text('Create/Edit Drawings'),'The edit/create drawing screen did not appear')
assert(@@ie.contains_text('Drawing uploaded'),'The success message Drawing uploaded did not appear')
#set description and save
@@ie.text_field(:id, 'P53_DESCRIPTION').set('Drawing for base')
@@ie.button(:id, 'apply_changes').click
@@ie.wait
assert(@@ie.contains_text('Drawings'),'The drawing screen did not appear')
assert(@@ie.contains_text('D1'),'The record with drawing code D1 did not appear')
assert(@@ie.contains_text('Drawing for base'),'The updated description Drawing for base did not appear')
end
#The following is commented out because the javascript dialog box cannot be clicked on some machines
#and on those that it does work it will only work if run from the dos prompt, there for the integrated
#test will not be able to complete the test automatically
#
#Check that the drawing D2 can be deleted and that the record is no longer displayed in the report
#
# def test_05_delete_drawing
# @@ie.link(:text, 'D2').click
# assert(@@ie.text_field(:id, 'P53_CODE').verify_contains('D2'),'The drawing code is not D2')
# assert(@@ie.text_field(:id, 'P53_DESCRIPTION').verify_contains('Drawing for module'),'The description is not drawing for module')
# assert(@@ie.button(:id, 'cancel').exists?,'The cancel button was not available')
# assert(@@ie.button(:id, 'delete').exists?,'The delete button was not available')
# assert(@@ie.button(:id, 'apply_changes').exists?,'The Apply Changes button was not available')
# @@ie.button(:id, 'delete').click
# @@ie.wait
# assert_nil(@@ie.contains_text('D2'),'The drawing code D2 did appear')
# end
#
#Check that the existing drawing code cannot be updated
#
def test_06_update_drawing_code
@@ie.link(:text, 'D1').click
assert(@@ie.text_field(:id, 'P53_CODE').verify_contains('D1'),'The drawing code field did not contain value D1')
assert(@@ie.text_field(:id, 'P53_DESCRIPTION').verify_contains('Drawing for base'),'The drawing description field did not contain value Drawing for housing')
assert(@@ie.button(:id, 'cancel').exists?,'The cancel button was not available')
assert(@@ie.button(:id, 'delete').exists?,'The delete button was not available')
assert(@@ie.button(:id, 'apply_changes').exists?,'The Apply Changes button was not available')
@@ie.text_field(:id, 'P53_CODE').set("D2")
@@ie.button(:id, 'apply_changes').click
@@ie.wait
assert(@@ie.contains_text('ORA-20001'),'We did not get that nasty ORA-20001 error we were expecting')
assert(@@ie.contains_text('DRAWINGS'),'Did not reference the DRAWINGS table in the error message')
@@ie.link(:text, 'OK').click
@@ie.wait
@@ie.button(:id, 'cancel').click
@@ie.wait
end
#
#Check that a drawing record with child records cannot be deleted
#~
#~ def test_07_delete_drawing_child
#~ @@ie.link(:text, 'lphhcompac').click
#~ assert(@@ie.text_field(:id, 'P13_CODE').verify_contains('lphhcompac'),'The drawing code is not lphhcompac')
#~ assert(@@ie.text_field(:id, 'P13_DESCRIPTION').verify_contains('MODULE'),'The description is not module')
#~ assert(@@ie.button(:id, 'cancel').exists?,'The cancel button was not available')
#~ assert(@@ie.button(:id, 'delete').exists?,'The delete button was not available')
#~ assert(@@ie.button(:id, 'apply_changes').exists?,'The Apply Changes button was not available')
#~ @@ie.button(:id, 'delete').click
#~ @@ie.wait
#~ assert(@@ie.contains_text('lphhcompac'),'The record with drawing code lphhcompac did not appear')
#~ end
#
#Check that a duplicate drawing record cannot be recorded
#
def test_08_create_duplicate
assert(@@ie.button(:id, 'create').exists?,'The create button was not available')
@@ie.button(:id, 'create').click
assert(@@ie.contains_text('Create/Edit Drawings'),'The create/edit drawing screen did not appear')
assert(@@ie.text_field(:id, 'P53_CODE').exists?,'The drawings code field is not available')
assert(@@ie.text_field(:id, 'P53_DESCRIPTION').exists?,'The drawings description field is not available')
assert(@@ie.button(:id, 'create').exists?,'The create button was not available')
assert(@@ie.button(:id, 'cancel').exists?,'The cancel button was not available')
@@ie.text_field(:id, 'P53_CODE').set("D1")
@@ie.text_field(:id, 'P53_DESCRIPTION').set("HOUSING")
@@ie.button(:id, 'create').click
@@ie.wait
assert(@@ie.contains_text('Error'),'An error was not generated')
assert(@@ie.contains_text('ORA-00001: unique constraint (MIP_TEST.DRWG_PK) violated'),'Expected a nasty oracle error message(ORA-00001) but did not get it')
end
#
end