summaryrefslogtreecommitdiff
path: root/cypress/e2e
diff options
context:
space:
mode:
Diffstat (limited to 'cypress/e2e')
-rw-r--r--cypress/e2e/event.cy.ts174
-rw-r--r--cypress/e2e/group.cy.ts69
2 files changed, 207 insertions, 36 deletions
diff --git a/cypress/e2e/event.cy.ts b/cypress/e2e/event.cy.ts
index 3536806..1160586 100644
--- a/cypress/e2e/event.cy.ts
+++ b/cypress/e2e/event.cy.ts
@@ -1,10 +1,9 @@
const eventData = {
eventName: "Your Event Name",
eventLocation: "Event Location",
- timezone: "Europe/London",
+ timezone: "America/New York",
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,
@@ -14,40 +13,28 @@ const eventData = {
joinCheckbox: true,
maxAttendeesCheckbox: true,
maxAttendees: 10,
- eventStart: "",
- eventEnd: "",
+ eventStart: "2030-01-01T00:00",
+ eventEnd: "2030-01-01T01:00",
};
describe("Events", () => {
beforeEach(() => {
- cy.clearLocalStorage();
-
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 });
+ // These are datetime-local inputs
+ cy.get("#eventStart").type(eventData.eventStart);
+ cy.get("#eventEnd").type(eventData.eventEnd);
+
+ cy.get(".select2-container").click();
+ cy.get(".select2-results__option")
+ .contains(eventData.timezone)
+ .click({ 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("#hostName").type(eventData.hostName);
cy.get("#creatorEmail").type(eventData.creatorEmail);
@@ -74,6 +61,16 @@ describe("Events", () => {
// Submit the form
cy.get("#newEventFormSubmit").click();
+
+ // Wait for the new page to load
+ cy.url().should("not.include", "/new");
+
+ // Get the new event ID from the URL
+ cy.url().then((url) => {
+ const [eventID, editToken] = url.split("/").pop().split("?");
+ cy.wrap(eventID).as("eventID");
+ cy.wrap(editToken).as("editToken");
+ });
});
it("creates a new event", function () {
// Check that all the data is correct
@@ -82,30 +79,25 @@ describe("Events", () => {
cy.get(".p-summary").should("contain.text", eventData.eventDescription);
cy.get("#hosted-by").should(
"contain.text",
- `Hosted by ${eventData.hostName}`
+ `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);
+ cy.get(".dt-duration").should(
+ "contain.text",
+ "Tuesday 1 January 2030 from 12:00 am to 1:00 am (EST)",
+ );
});
it("allows you to attend an event", function () {
cy.get("button#attendEvent").click();
cy.get("#attendeeName").type("Test Attendee");
- cy.get("#attendeeNumber").clear();
+ cy.get("#attendeeNumber").focus().clear();
cy.get("#attendeeNumber").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)"
+ "Test Attendee (2 people)",
);
});
@@ -116,4 +108,114 @@ describe("Events", () => {
cy.get(".comment").should("contain.text", "Test Author");
cy.get(".comment").should("contain.text", "Test Comment");
});
+
+ it("displays the ActivityPub featured post", function () {
+ cy.log(this.eventID);
+
+ cy.request({
+ url: `/${this.eventID}/featured`,
+ headers: {
+ Accept: "application/activity+json",
+ },
+ }).then((response) => {
+ expect(response.body).to.have.property("@context");
+ expect(response.body).to.have.property("id");
+ expect(response.body).to.have.property("type");
+ expect(response.body).to.have.property("orderedItems");
+ expect(response.body.orderedItems)
+ .to.be.an("array")
+ .and.to.have.lengthOf(1);
+ const featuredPost = response.body.orderedItems[0];
+ expect(featuredPost).to.have.property("@context");
+ expect(featuredPost).to.have.property("id");
+ expect(featuredPost).to.have.property("type");
+ expect(featuredPost).to.have.property("name");
+ expect(featuredPost).to.have.property("content");
+ expect(featuredPost).to.have.property("attributedTo");
+ });
+ });
+
+ it("responds correctly to ActivityPub webfinger requests", function () {
+ cy.request({
+ url: `/.well-known/webfinger?resource=acct:${
+ this.eventID
+ }@${Cypress.env("CYPRESS_DOMAIN")}`,
+ headers: {
+ Accept: "application/activity+json",
+ },
+ }).then((response) => {
+ expect(response.body).to.have.property("subject");
+ expect(response.body).to.have.property("links");
+ expect(response.body.links)
+ .to.be.an("array")
+ .and.to.have.lengthOf(1);
+ const link = response.body.links[0];
+ expect(link).to.have.property("rel");
+ expect(link).to.have.property("type");
+ expect(link).to.have.property("href");
+ });
+ });
+
+ it("edits an event", function () {
+ cy.get("#editEvent").click();
+
+ // The edit form is the same as the new form, so we can just re-use the same selectors
+ // but we need to clear the fields first
+ cy.get("#editEventForm #eventName").focus().clear();
+ cy.get("#editEventForm #eventLocation").focus().clear();
+ cy.get("#editEventForm #eventStart").focus().clear();
+ cy.get("#editEventForm #eventEnd").focus().clear();
+ cy.get("#editEventForm #eventDescription").focus().clear();
+ cy.get("#editEventForm #eventURL").focus().clear();
+ cy.get("#editEventForm #hostName").focus().clear();
+ cy.get("#editEventForm #creatorEmail").focus().clear();
+ cy.get("#editEventForm #maxAttendees").focus().clear();
+
+ cy.get("#editEventForm #eventName").type("Edited Event Name");
+ cy.get("#editEventForm #eventLocation").type("Edited Event Location");
+ // These are datetime-local inputs
+ cy.get("#editEventForm #eventStart").type("2030-12-01T00:00");
+ cy.get("#editEventForm #eventEnd").type("2030-12-01T01:00");
+
+ cy.get("#editEventForm .select2-container").click();
+ cy.get(".select2-results__option")
+ .contains("Australia/Sydney")
+ .click({ force: true });
+
+ cy.get("#editEventForm #eventDescription").type(
+ "Edited Event Description",
+ );
+ cy.get("#editEventForm #eventURL").type("https://edited.example.com");
+ cy.get("#editEventForm #hostName").type("Edited Name");
+ cy.get("#editEventForm #creatorEmail").type("edited@example.com");
+
+ cy.get("#editEventForm #maxAttendeesCheckbox").uncheck();
+
+ cy.get("#editEventForm #interactionCheckbox").uncheck();
+
+ cy.get("#editEventForm #joinCheckbox").uncheck();
+
+ // Submit the form
+ cy.get("#editEventForm").submit();
+
+ // Wait for the modal to not be visible
+ cy.get("#editModal").should("not.be.visible");
+
+ // Check that all the data is correct
+ cy.get(".p-name").should("have.text", "Edited Event Name");
+ cy.get(".p-location").should("have.text", "Edited Event Location");
+ cy.get(".p-summary").should("contain.text", "Edited Event Description");
+ cy.get("#hosted-by").should("contain.text", "Hosted by Edited Name");
+ cy.get(".dt-duration").should(
+ "contain.text",
+ "Sunday 1 December 2030 from 12:00 am to 1:00 am",
+ );
+ cy.get(".dt-duration")
+ .invoke("text")
+ .should("match", /AE(D|S)T/);
+ // Check that the comment form is not visible
+ cy.get("#postComment").should("not.exist");
+ // Check that the attendee form is not visible
+ cy.get("#attendEvent").should("not.exist");
+ });
});
diff --git a/cypress/e2e/group.cy.ts b/cypress/e2e/group.cy.ts
new file mode 100644
index 0000000..8250179
--- /dev/null
+++ b/cypress/e2e/group.cy.ts
@@ -0,0 +1,69 @@
+const groupData = {
+ eventGroupName: "Test Group",
+ eventGroupDescription: "Test Group Description",
+ eventGroupURL: "https://example.com",
+ hostName: "Test Host",
+ creatorEmail: "test@example.com",
+};
+
+describe("Groups", () => {
+ beforeEach(() => {
+ cy.visit("/new");
+ cy.get("#showNewEventGroupFormButton").click();
+
+ // Fill in the form
+ cy.get("#eventGroupName").type(groupData.eventGroupName);
+ cy.get("#eventGroupDescription").type(groupData.eventGroupDescription);
+ cy.get("#eventGroupURL").type(groupData.eventGroupURL);
+ cy.get("#eventGroupHostName").type(groupData.hostName);
+ cy.get("#eventGroupCreatorEmail").type(groupData.creatorEmail);
+
+ // Submit the form
+ cy.get("#newEventGroupForm").submit();
+
+ // Wait for the new page to load
+ cy.url().should("not.include", "/new");
+
+ // Get the new group ID from the URL
+ cy.url().then((url) => {
+ const [groupID, editToken] = url.split("/").pop().split("?");
+ cy.wrap(groupID).as("groupID");
+ cy.wrap(editToken.slice(2)).as("editToken");
+ });
+ });
+ it("creates a new group", function () {
+ cy.get("#eventGroupName").should("have.text", groupData.eventGroupName);
+ cy.get("#eventDescription").should(
+ "contain.text",
+ groupData.eventGroupDescription,
+ );
+ cy.get("#eventGroupURL").should(
+ "contain.text",
+ groupData.eventGroupURL,
+ );
+ cy.get("#hostName").should("contain.text", groupData.hostName);
+ cy.get("#eventGroupID").should("contain.text", this.groupID);
+ cy.get("#eventGroupEditToken").should("contain.text", this.editToken);
+ });
+
+ it("edits a group", function () {
+ // // Wait for the modal to not be visible
+ // cy.get("#editModal").should("not.be.visible");
+ // // Check that all the data is correct
+ // cy.get(".p-name").should("have.text", "Edited Event Name");
+ // cy.get(".p-location").should("have.text", "Edited Event Location");
+ // cy.get(".p-summary").should("contain.text", "Edited Event Description");
+ // cy.get("#hosted-by").should("contain.text", "Hosted by Edited Name");
+ // cy.get(".dt-duration").should(
+ // "contain.text",
+ // "Sunday 1 December 2030 from 12:00 am to 1:00 am",
+ // );
+ // cy.get(".dt-duration")
+ // .invoke("text")
+ // .should("match", /AE(D|S)T/);
+ // // Check that the comment form is not visible
+ // cy.get("#postComment").should("not.exist");
+ // // Check that the attendee form is not visible
+ // cy.get("#attendEvent").should("not.exist");
+ });
+});