|
| 1 | +/// <reference types="cypress" /> |
| 2 | + |
| 3 | +describe("API Public Registration", () => { |
| 4 | + it("Should allow family registration without authentication", () => { |
| 5 | + const testFamily = { |
| 6 | + Name: "Cypress Test Family", |
| 7 | + Address1: "123 Test Street", |
| 8 | + Address2: "", |
| 9 | + City: "Testville", |
| 10 | + State: "TS", |
| 11 | + Country: "US", |
| 12 | + Zip: "12345", |
| 13 | + HomePhone: "(555) 123-4567", |
| 14 | + Email: "test@example.com", |
| 15 | + people: [ |
| 16 | + { |
| 17 | + firstName: "John", |
| 18 | + lastName: "Tester", |
| 19 | + gender: 1, |
| 20 | + role: 1, |
| 21 | + email: "john@example.com", |
| 22 | + cellPhone: "(555) 987-6543", |
| 23 | + homePhone: "", |
| 24 | + workPhone: "", |
| 25 | + birthday: "01/15/1980", |
| 26 | + hideAge: false |
| 27 | + } |
| 28 | + ] |
| 29 | + }; |
| 30 | + |
| 31 | + cy.request({ |
| 32 | + method: "POST", |
| 33 | + url: "/api/public/register/family", |
| 34 | + body: testFamily, |
| 35 | + }).then((resp) => { |
| 36 | + expect(resp.status).to.eq(200); |
| 37 | + expect(resp.body).to.have.property('Id'); |
| 38 | + expect(resp.body.Name).to.eq(testFamily.Name); |
| 39 | + expect(resp.body.Address1).to.eq(testFamily.Address1); |
| 40 | + expect(resp.body.Email).to.eq(testFamily.Email); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + it("Should return validation error for invalid family data", () => { |
| 45 | + const invalidFamily = { |
| 46 | + Name: "", // Empty name should fail validation |
| 47 | + Address1: "", |
| 48 | + City: "", |
| 49 | + State: "", |
| 50 | + Country: "", |
| 51 | + Zip: "", |
| 52 | + HomePhone: "", |
| 53 | + Email: "", |
| 54 | + people: [] |
| 55 | + }; |
| 56 | + |
| 57 | + cy.request({ |
| 58 | + method: "POST", |
| 59 | + url: "/api/public/register/family", |
| 60 | + body: invalidFamily, |
| 61 | + failOnStatusCode: false |
| 62 | + }).then((resp) => { |
| 63 | + // Should return 400 Bad Request for validation errors |
| 64 | + expect(resp.status).to.be.oneOf([400, 401]); |
| 65 | + expect(resp.body).to.have.property('error'); |
| 66 | + }); |
| 67 | + }); |
| 68 | +}); |
0 commit comments