|
| 1 | +describe('The Home Page', function() { |
| 2 | + it('Successfull rendering', function() { |
| 3 | + cy.visit('http://localhost:3000/') |
| 4 | + }) |
| 5 | + |
| 6 | + it('Check Submit Button', function() { |
| 7 | + cy.visit('http://localhost:3000/') |
| 8 | + cy.contains('Submit Booking').click() |
| 9 | + }); |
| 10 | + }); |
| 11 | + |
| 12 | +describe("Test blur events", () => { |
| 13 | + it('Successfull rendering', function() { |
| 14 | + cy.visit('http://localhost:3000/') |
| 15 | + }) |
| 16 | + |
| 17 | + it("Customer Name blur (Text field)", () => { |
| 18 | + cy.get('input[name=customer_name]').focus().blur(); |
| 19 | + cy.contains("The Customer Name field is required.") |
| 20 | + }); |
| 21 | + |
| 22 | + it("Phone number blur (Text field)", () => { |
| 23 | + cy.get('input[name=phone_number]').focus().blur(); |
| 24 | + cy.contains("The phone number field is required."); |
| 25 | + }); |
| 26 | + |
| 27 | + it("Email address blur (Text field)", () => { |
| 28 | + cy.get('input[name=email_address]').focus().blur(); |
| 29 | + cy.contains("The email address field is required."); |
| 30 | + }); |
| 31 | + |
| 32 | + it("Pickup Date blur (Date field)", () => { |
| 33 | + cy.get('input[name=pickup_time]').focus().blur(); |
| 34 | + cy.contains("The pickup time field is required."); |
| 35 | + }); |
| 36 | + |
| 37 | + it("Pickup Place blur (Dropdown)", () => { |
| 38 | + cy.get('select[name=pickup_place]').focus().blur(); |
| 39 | + cy.contains("The pickup place field is required."); |
| 40 | + }); |
| 41 | + |
| 42 | + it("Drop Place blur (Combo box)", () => { |
| 43 | + cy.get('input[name=dropoff_place]').focus().blur(); |
| 44 | + cy.contains("The dropoff place field is required."); |
| 45 | + }); |
| 46 | + |
| 47 | + it("Special instructions blur (Textarea)", () => { |
| 48 | + cy.get('textarea').focus().blur(); |
| 49 | + cy.contains("The comments field is required."); |
| 50 | + }); |
| 51 | +}); |
| 52 | + |
| 53 | +describe("Test change event", () => { |
| 54 | + it('Successfull rendering', function() { |
| 55 | + cy.visit('http://localhost:3000/') |
| 56 | + }); |
| 57 | + |
| 58 | + it("Customer Name change event (Text field)", () => { |
| 59 | + cy.get('input[name=customer_name]').focus().blur(); |
| 60 | + cy.get('input[name=customer_name]').type("gokulakannan").blur(); |
| 61 | + cy.contains("The Customer Name field is required.").should('not.exist'); |
| 62 | + }); |
| 63 | + |
| 64 | + it("Phone number change (Text field)", () => { |
| 65 | + cy.get('input[name=phone_number]').focus().blur(); |
| 66 | + cy.get('input[name=phone_number]').type(9876543210).blur(); |
| 67 | + cy.contains("The phone number field is required.").should('not.exist'); |
| 68 | + }); |
| 69 | + |
| 70 | + it("Email address blur (Text field)", () => { |
| 71 | + cy.get('input[name=email_address]').focus().blur(); |
| 72 | + cy.get('input[name=email_address]').type("[email protected]").blur(); |
| 73 | + cy.contains("The email address field is required.").should('not.exist'); |
| 74 | + }); |
| 75 | + |
| 76 | + it("Pickup Date blur (Date field)", () => { |
| 77 | + cy.get('input[name=pickup_time]').focus().blur(); |
| 78 | + cy.get('input[name=pickup_time]').type("2019-11-27").blur(); |
| 79 | + cy.contains("The pickup time field is required.").should('not.exist'); |
| 80 | + }); |
| 81 | + |
| 82 | + it("Pickup Place blur (Dropdown)", () => { |
| 83 | + cy.get('select[name=pickup_place]').focus().blur(); |
| 84 | + cy.get('select[name=pickup_place]').select('town_hall'); |
| 85 | + // cy.contains("The pickup place field is required.").should('not.exist'); |
| 86 | + }); |
| 87 | + |
| 88 | + it("Drop Place blur (Combo box)", () => { |
| 89 | + cy.get('input[name=dropoff_place]').focus().blur(); |
| 90 | + cy.get('input[name=dropoff_place]').type("Airport").blur(); |
| 91 | + cy.contains("The dropoff place field is required.").should('not.exist'); |
| 92 | + }); |
| 93 | + |
| 94 | + it("Special instructions blur (Textarea)", () => { |
| 95 | + cy.get('textarea').focus().blur(); |
| 96 | + cy.get('textarea').type("Use react form input validator for testing").blur(); |
| 97 | + cy.contains("The comments field is required.").should('not.exist'); |
| 98 | + }); |
| 99 | +}); |
| 100 | + |
| 101 | +describe("Fill form fields", () => { |
| 102 | + it('Successfull rendering', function() { |
| 103 | + cy.visit('http://localhost:3000/') |
| 104 | + }); |
| 105 | + |
| 106 | + it("Type customer name (Text field)", () => { |
| 107 | + cy.get('input[name=customer_name]').type("gokulakannan").blur(); |
| 108 | + }); |
| 109 | + |
| 110 | + it("Type phone number (Text field)", () => { |
| 111 | + cy.get('input[name=phone_number]').type(9876543210).blur(); |
| 112 | + }); |
| 113 | + |
| 114 | + it("Type email address (Text field)", () => { |
| 115 | + cy.get('input[name=email_address]').type("[email protected]").blur(); |
| 116 | + }); |
| 117 | + |
| 118 | + it("Select Taxi (Radio button)", () => { |
| 119 | + cy.get('[type="radio"]').first().check() |
| 120 | + }); |
| 121 | + |
| 122 | + it("Check extras (Checkbox)", () => { |
| 123 | + cy.get('[type="checkbox"]').check(['baby', 'wheelchair']) |
| 124 | + }); |
| 125 | + |
| 126 | + it("Select pickup Date (Date field)", () => { |
| 127 | + cy.get('input[name=pickup_time]').type("2019-11-27").blur(); |
| 128 | + }); |
| 129 | + |
| 130 | + it("Select pickup Place (Dropdown)", () => { |
| 131 | + cy.get('select[name=pickup_place]').select('town_hall') |
| 132 | + }); |
| 133 | + |
| 134 | + it("Choose drop Place (Combo box)", () => { |
| 135 | + cy.get('input[name=dropoff_place]').type("Airport").blur(); |
| 136 | + }); |
| 137 | + |
| 138 | + it("Type Special instructions (Textarea)", () => { |
| 139 | + cy.get('textarea').type("Use react form input validator for testing").blur(); |
| 140 | + cy.contains("The comments field is required.").should('not.exist'); |
| 141 | + }); |
| 142 | +}); |
| 143 | + |
| 144 | +describe("Test validation rules in form fields", () => { |
| 145 | + beforeEach("Render home page", () => { |
| 146 | + cy.visit('http://localhost:3000/'); |
| 147 | + }) |
| 148 | + describe("Customer name (required)", () => { |
| 149 | + it("Empty fields should display error message", () => { |
| 150 | + cy.get('input[name=customer_name]').focus().blur(); |
| 151 | + cy.contains("The Customer Name field is required."); |
| 152 | + }); |
| 153 | + |
| 154 | + it("Valid data should not display error message", () => { |
| 155 | + cy.get('input[name=customer_name]').focus().blur(); |
| 156 | + cy.get('input[name=customer_name]').type("gokulakannan").blur(); |
| 157 | + cy.contains("The Customer Name field is required.").should('not.exist'); |
| 158 | + }); |
| 159 | + }); |
| 160 | + |
| 161 | + describe("Phone number (numeric, min, max)", () => { |
| 162 | + it("Invalid alphabet phone number should display error message", () => { |
| 163 | + cy.get('input[name=phone_number]').type("test").blur(); |
| 164 | + cy.contains("The phone number must be a number."); |
| 165 | + }); |
| 166 | + |
| 167 | + it("Min length phone number should display error message", () => { |
| 168 | + cy.get('input[name=phone_number]').type(321).blur(); |
| 169 | + cy.contains("The phone number field must be between 10 and 12 digits."); |
| 170 | + }); |
| 171 | + |
| 172 | + it("Max length phone number should display error message", () => { |
| 173 | + cy.get('input[name=phone_number]').type(321).blur(); |
| 174 | + cy.contains("The phone number field must be between 10 and 12 digits."); |
| 175 | + }); |
| 176 | + |
| 177 | + it("Valid phone number should not display error message", () => { |
| 178 | + cy.get('input[name=phone_number]').type(9876543210).blur(); |
| 179 | + cy.contains("The phone number must be a number.").should('not.exist'); |
| 180 | + }); |
| 181 | + }); |
| 182 | + |
| 183 | + describe("Email address (email)", () => { |
| 184 | + it("Invalid email address should display error message", () => { |
| 185 | + cy.get('input[name=email_address]').type("test").blur(); |
| 186 | + cy.contains("The email address format is invalid."); |
| 187 | + }); |
| 188 | + |
| 189 | + it("Valid email address should not display error message", () => { |
| 190 | + cy.get('input[name=email_address]').type("[email protected]").blur(); |
| 191 | + cy.contains("The email address format is invalid.").should('not.exist'); |
| 192 | + }); |
| 193 | + }); |
| 194 | +}) |
0 commit comments