diff options
Diffstat (limited to 'cypress')
| -rw-r--r-- | cypress/e2e/event.cy.ts | 201 | ||||
| -rw-r--r-- | cypress/fixtures/example.json | 6 | ||||
| -rw-r--r-- | cypress/support/commands.ts | 2 | ||||
| -rw-r--r-- | cypress/support/e2e.ts | 4 | ||||
| -rw-r--r-- | cypress/tsconfig.json | 14 | 
5 files changed, 115 insertions, 112 deletions
diff --git a/cypress/e2e/event.cy.ts b/cypress/e2e/event.cy.ts index 10266b7..833a3c9 100644 --- a/cypress/e2e/event.cy.ts +++ b/cypress/e2e/event.cy.ts @@ -1,115 +1,118 @@  const eventData = { -  eventName: "Your Event Name", -  eventLocation: "Event Location", -  timezone: "Europe/London", -  eventDescription: "Event Description", -  eventURL: "https://example.com", -  imagePath: "path/to/your/image.jpg", // If you have an image to upload -  hostName: "Your Name", -  creatorEmail: "test@example.com", -  eventGroupCheckbox: false, -  eventGroupID: "YourEventGroupID", -  eventGroupEditToken: "YourEventGroupEditToken", -  interactionCheckbox: true, -  joinCheckbox: true, -  maxAttendeesCheckbox: true, -  maxAttendees: 10, -  eventStart: "", -  eventEnd: "", +    eventName: "Your Event Name", +    eventLocation: "Event Location", +    timezone: "Europe/London", +    eventDescription: "Event Description", +    eventURL: "https://example.com", +    imagePath: "path/to/your/image.jpg", // If you have an image to upload +    hostName: "Your Name", +    creatorEmail: "test@example.com", +    eventGroupCheckbox: false, +    eventGroupID: "YourEventGroupID", +    eventGroupEditToken: "YourEventGroupEditToken", +    interactionCheckbox: true, +    joinCheckbox: true, +    maxAttendeesCheckbox: true, +    maxAttendees: 10, +    eventStart: "", +    eventEnd: "",  };  describe("Events", () => { -  beforeEach(() => { -    cy.clearLocalStorage(); +    beforeEach(() => { +        cy.clearLocalStorage(); -    cy.visit("/new"); -    cy.get("#showNewEventFormButton").click(); +        cy.visit("/new"); +        cy.get("#showNewEventFormButton").click(); -    cy.get("#eventName").type(eventData.eventName); -    cy.get("#eventLocation").type(eventData.eventLocation); -    cy.get("#eventStart").click(); -    // This opens a datepicker, so find the first non-disabled day and click it -    cy.get(".datepicker--cell-day:not(.-disabled-)").first().click(); -    cy.get("#eventStart").invoke("val").as("eventStart"); -    // Click away from the datepicker to close it -    cy.get("#eventName").click(); -    cy.get("#eventEnd").click(); -    // This opens a datepicker, so find the last non-disabled day and click it -    cy.get(".datepicker--cell-day:not(.-disabled-)").last().click(); -    cy.get("#eventEnd").invoke("val").as("eventEnd"); -    // Click away from the datepicker to close it -    cy.get("#eventName").click(); -    // #timezone is a Select2 dropdown, so select the option you want -    cy.get("#timezone").select(eventData.timezone, { force: true }); +        cy.get("#eventName").type(eventData.eventName); +        cy.get("#eventLocation").type(eventData.eventLocation); +        cy.get("#eventStart").click(); +        // This opens a datepicker, so find the first non-disabled day and click it +        cy.get(".datepicker--cell-day:not(.-disabled-)").first().click(); +        cy.get("#eventStart").invoke("val").as("eventStart"); +        // Click away from the datepicker to close it +        cy.get("#eventName").click(); +        cy.get("#eventEnd").click(); +        // This opens a datepicker, so find the last non-disabled day and click it +        cy.get(".datepicker--cell-day:not(.-disabled-)").last().click(); +        cy.get("#eventEnd").invoke("val").as("eventEnd"); +        // Click away from the datepicker to close it +        cy.get("#eventName").click(); +        // #timezone is a Select2 dropdown, so select the option you want +        cy.get("#timezone").select(eventData.timezone, { force: true }); -    cy.get("#eventDescription").type(eventData.eventDescription); -    cy.get("#eventURL").type(eventData.eventURL); -    // Upload an image -    // if (eventData.imagePath) { -    //   cy.get("#eventImageUpload").attachFile(eventData.imagePath); -    // } +        cy.get("#eventDescription").type(eventData.eventDescription); +        cy.get("#eventURL").type(eventData.eventURL); +        // Upload an image +        // if (eventData.imagePath) { +        //   cy.get("#eventImageUpload").attachFile(eventData.imagePath); +        // } -    cy.get("#hostName").type(eventData.hostName); -    cy.get("#creatorEmail").type(eventData.creatorEmail); +        cy.get("#hostName").type(eventData.hostName); +        cy.get("#creatorEmail").type(eventData.creatorEmail); -    // Check checkboxes based on eventData -    if (eventData.eventGroupCheckbox) { -      cy.get("#eventGroupCheckbox").check(); -      cy.get("#eventGroupID").type(eventData.eventGroupID); -      cy.get("#eventGroupEditToken").type(eventData.eventGroupEditToken); -    } +        // Check checkboxes based on eventData +        if (eventData.eventGroupCheckbox) { +            cy.get("#eventGroupCheckbox").check(); +            cy.get("#eventGroupID").type(eventData.eventGroupID); +            cy.get("#eventGroupEditToken").type(eventData.eventGroupEditToken); +        } -    if (eventData.interactionCheckbox) { -      cy.get("#interactionCheckbox").check(); -    } +        if (eventData.interactionCheckbox) { +            cy.get("#interactionCheckbox").check(); +        } -    if (eventData.joinCheckbox) { -      cy.get("#joinCheckbox").check(); -    } +        if (eventData.joinCheckbox) { +            cy.get("#joinCheckbox").check(); +        } -    if (eventData.maxAttendeesCheckbox) { -      cy.get("#maxAttendeesCheckbox").check(); -      cy.get("#maxAttendees").type(eventData.maxAttendees.toString()); -    } +        if (eventData.maxAttendeesCheckbox) { +            cy.get("#maxAttendeesCheckbox").check(); +            cy.get("#maxAttendees").type(eventData.maxAttendees.toString()); +        } -    // Submit the form -    cy.get("#newEventFormSubmit").click(); -  }); -  it("creates a new event", function () { -    // Check that all the data is correct -    cy.get(".p-name").should("have.text", eventData.eventName); -    cy.get(".p-location").should("have.text", eventData.eventLocation); -    cy.get(".p-summary").should("contain.text", eventData.eventDescription); -    cy.get("#hosted-by").should( -      "contain.text", -      `Hosted by ${eventData.hostName}` -    ); -    cy.get("#attendees-alert").should("contain.text", "10 spots remaining"); -    let [startDate, startTime] = this.eventStart.split(", "); -    let [endDate, endTime] = this.eventEnd.split(", "); -    // Remove leading zeroes from the times -    startTime = startTime.replace(/^0+/, ""); -    endTime = endTime.replace(/^0+/, ""); -    cy.get(".dt-duration").should("contain.text", startDate); -    cy.get(".dt-duration").should("contain.text", endDate); -    cy.get(".dt-duration").should("contain.text", startTime); -    cy.get(".dt-duration").should("contain.text", endTime); -  }); +        // Submit the form +        cy.get("#newEventFormSubmit").click(); +    }); +    it("creates a new event", function () { +        // Check that all the data is correct +        cy.get(".p-name").should("have.text", eventData.eventName); +        cy.get(".p-location").should("have.text", eventData.eventLocation); +        cy.get(".p-summary").should("contain.text", eventData.eventDescription); +        cy.get("#hosted-by").should( +            "contain.text", +            `Hosted by ${eventData.hostName}`, +        ); +        cy.get("#attendees-alert").should("contain.text", "10 spots remaining"); +        let [startDate, startTime] = this.eventStart.split(", "); +        let [endDate, endTime] = this.eventEnd.split(", "); +        // Remove leading zeroes from the times +        startTime = startTime.replace(/^0+/, ""); +        endTime = endTime.replace(/^0+/, ""); +        cy.get(".dt-duration").should("contain.text", startDate); +        cy.get(".dt-duration").should("contain.text", endDate); +        cy.get(".dt-duration").should("contain.text", startTime); +        cy.get(".dt-duration").should("contain.text", endTime); +    }); -  it("allows you to attend an event", function () { -    cy.get("button#attendEvent").click(); -    cy.get("#attendeeName").type("Test Attendee"); -    cy.get("#attendeeNumber").clear().type("2"); -    cy.get("form#attendEventForm").submit(); -    cy.get("#attendees-alert").should("contain.text", "8 spots remaining"); -    cy.get(".attendeesList").should("contain.text", "Test Attendee (2 people)"); -  }); +    it("allows you to attend an event", function () { +        cy.get("button#attendEvent").click(); +        cy.get("#attendeeName").type("Test Attendee"); +        cy.get("#attendeeNumber").clear().type("2"); +        cy.get("form#attendEventForm").submit(); +        cy.get("#attendees-alert").should("contain.text", "8 spots remaining"); +        cy.get(".attendeesList").should( +            "contain.text", +            "Test Attendee (2 people)", +        ); +    }); -  it("allows you to comment on an event", function () { -    cy.get("#commentAuthor").type("Test Author"); -    cy.get("#commentContent").type("Test Comment"); -    cy.get("#postComment").click(); -    cy.get(".comment").should("contain.text", "Test Author"); -    cy.get(".comment").should("contain.text", "Test Comment"); -  }); +    it("allows you to comment on an event", function () { +        cy.get("#commentAuthor").type("Test Author"); +        cy.get("#commentContent").type("Test Comment"); +        cy.get("#postComment").click(); +        cy.get(".comment").should("contain.text", "Test Author"); +        cy.get(".comment").should("contain.text", "Test Comment"); +    });  }); diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json index 02e4254..519902d 100644 --- a/cypress/fixtures/example.json +++ b/cypress/fixtures/example.json @@ -1,5 +1,5 @@  { -  "name": "Using fixtures to represent data", -  "email": "hello@cypress.io", -  "body": "Fixtures are a great way to mock data for responses to routes" +    "name": "Using fixtures to represent data", +    "email": "hello@cypress.io", +    "body": "Fixtures are a great way to mock data for responses to routes"  } diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 698b01a..95857ae 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -34,4 +34,4 @@  //       visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>  //     }  //   } -// }
\ No newline at end of file +// } diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index f80f74f..6a173d6 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -14,7 +14,7 @@  // ***********************************************************  // Import commands.js using ES2015 syntax: -import './commands' +import "./commands";  // Alternatively you can use CommonJS syntax: -// require('./commands')
\ No newline at end of file +// require('./commands') diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index 83fb87e..dc61836 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -1,8 +1,8 @@  { -  "compilerOptions": { -    "target": "es5", -    "lib": ["es5", "dom"], -    "types": ["cypress", "node"] -  }, -  "include": ["**/*.ts"] -}
\ No newline at end of file +    "compilerOptions": { +        "target": "es5", +        "lib": ["es5", "dom"], +        "types": ["cypress", "node"] +    }, +    "include": ["**/*.ts"] +}  | 
