Skip to content

Commit

Permalink
VACMS-10089: Cypress testing of outreach cal checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
chri5tia committed Oct 5, 2023
1 parent 2f81169 commit 0eb85d5
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 15 deletions.
24 changes: 16 additions & 8 deletions config/sync/core.entity_view_display.node.event.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ third_party_settings:
group_c:
children:
- field_datetime_range_timezone
- field_listing
- field_media
- field_body
- field_url_of_an_online_event
Expand All @@ -75,7 +76,7 @@ third_party_settings:
label: Location-related
parent_name: group_c
region: content
weight: 28
weight: 7
format_type: fieldset
format_settings:
classes: ''
Expand All @@ -90,7 +91,7 @@ third_party_settings:
label: 'Registration related'
parent_name: group_c
region: content
weight: 29
weight: 8
format_type: fieldset
format_settings:
classes: ''
Expand Down Expand Up @@ -135,7 +136,7 @@ content:
label: above
settings: { }
third_party_settings: { }
weight: 25
weight: 4
region: content
field_datetime_range_timezone:
type: smartdate_default
Expand All @@ -157,7 +158,7 @@ content:
decimals: 2
suffix: h
third_party_settings: { }
weight: 23
weight: 1
region: content
field_description:
type: string
Expand All @@ -180,7 +181,7 @@ content:
label: above
settings: { }
third_party_settings: { }
weight: 27
weight: 6
region: content
field_event_registrationrequired:
type: boolean
Expand Down Expand Up @@ -232,6 +233,14 @@ content:
third_party_settings: { }
weight: 17
region: content
field_listing:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
field_location_humanreadable:
type: string
label: above
Expand All @@ -254,7 +263,7 @@ content:
view_mode: default
link: false
third_party_settings: { }
weight: 24
weight: 3
region: content
field_order:
type: list_default
Expand All @@ -273,14 +282,13 @@ content:
rel: ''
target: ''
third_party_settings: { }
weight: 26
weight: 5
region: content
hidden:
breadcrumbs: true
content_moderation_control: true
field_administration: true
field_last_saved_by_an_editor: true
field_listing: true
field_meta_tags: true
field_publish_to_outreach_cal: true
langcode: true
Expand Down
19 changes: 12 additions & 7 deletions tests/cypress/integration/features/content_type/event.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: Content Type: Event

Scenario: Log in and create an event.
Given I am logged in as a user with the "content_admin" role
Then I create a "event" node
And I create a "event" node

Scenario: Confirm that event form conditional fields are cleared out if parent options change
Given I am logged in as a user with the "content_admin" role
Expand Down Expand Up @@ -33,7 +33,6 @@ Feature: Content Type: Event
And the option "- None -" from dropdown "State" should be selected
When I select the "Online" radio button
Then an element with the selector "#edit-field-url-of-an-online-event-0-uri" should be empty
# EVENT FORM SPECS

Scenario: Confirm that the default time zone when creating an event is set explicitly to Eastern.
Given I am logged in as a user with the "content_admin" role
Expand All @@ -42,7 +41,7 @@ Feature: Content Type: Event

Scenario: Confirm that the event form conditional elements are shown or hidden appropriately
Given I am logged in as a user with the "content_admin" role
And I am at "node/add/event"
When I am at "node/add/event"

And I select the "At a VA facility" radio button
Then I should see "Facility location"
Expand Down Expand Up @@ -79,17 +78,23 @@ Feature: Content Type: Event

When I select option "Register" from dropdown "Call to action"
Then I should see an element with the selector "#edit-field-link-0-uri"
And I select option "Apply" from dropdown "Call to action"
When I select option "Apply" from dropdown "Call to action"
Then I should see an element with the selector "#edit-field-link-0-uri"
And I select option "RSVP" from dropdown "Call to action"
When I select option "RSVP" from dropdown "Call to action"
Then I should see an element with the selector "#edit-field-link-0-uri"
And I select option "More Details" from dropdown "Call to action"
When I select option "More Details" from dropdown "Call to action"
Then I should see an element with the selector "#edit-field-link-0-uri"
And I select option "- None -" from dropdown "Call to action"
When I select option "- None -" from dropdown "Call to action"
Then I should not see an element with the selector "#edit-field-link-0-uri"

When I uncheck the "Include registration information" checkbox
Then I should not see "Cost"
And I should not see "Registration is required for this event"
And I should not see "Call to action"
And I should not see an element with the selector "#edit-field-link-0-uri"

Scenario: Users who can only publish to National Outreach Calendar do not see the "Publish to the National Outreach Calendar" checkbox
Given I am logged in as a user with the roles "office_content_creator, content_publisher"
When my workbench access sections are set to "7"
And I am at "node/add/event"
Then I should see "This event will automatically be published to the National Outreach Calendar"
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ const creators = {
"VA Alaska health care: Events",
{ force: true }
);
cy.get("#edit-field-publish-to-outreach-cal-value").check();
cy.findAllByLabelText("Street address").type(
faker.address.streetAddress(),
{ force: true }
Expand Down Expand Up @@ -279,6 +280,7 @@ const creators = {
).should("exist");
cy.get("form.node-form").find("input#edit-submit").click();
cy.get(".node__content").contains("Sun, Nov 5 2023, 10:00am - 11:00am MST");
cy.get(".node__content").contains("Outreach events");
cy.scrollTo("top", { ensureScrollable: false });
cy.get(".tabs__tab a").contains("Edit").click({ force: true });
cy.get("#edit-field-datetime-range-timezone-0-manage-instances").click();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/* eslint-disable max-nested-callbacks */
import { Given } from "@badeball/cypress-cucumber-preprocessor";
import { faker } from "@faker-js/faker";

const creators = {
event: () => {
cy.findAllByLabelText("Name").type(
`[Test Data] ${faker.lorem.sentence()}`,
{ force: true }
);
cy.get(
"#edit-field-datetime-range-timezone-0-time-wrapper-value-date"
).type("2023-11-04", { force: true });
cy.get(
"#edit-field-datetime-range-timezone-0-time-wrapper-value-date"
).type("2023-11-04", { force: true });
cy.get(
"#edit-field-datetime-range-timezone-0-time-wrapper-value-time"
).type("10:00:00", { force: true });
cy.get(
"#edit-field-datetime-range-timezone-0-time-wrapper-end-value-time"
).type("11:00:00", { force: true });
cy.get("#edit-field-datetime-range-timezone-0-timezone").select("Phoenix");
cy.get("#edit-field-datetime-range-timezone-0-make-recurring").check();
cy.get("#edit-field-datetime-range-timezone-0-interval").type("1");
cy.get("#edit-field-datetime-range-timezone-0-repeat-end-date").type(
"2023-11-07",
{ force: true }
);
cy.get("#edit-field-datetime-range-timezone-0-repeat").select("DAILY");
cy.findAllByLabelText("Where should the event be listed?").select(
"VA Alaska health care: Events",
{ force: true }
);
cy.findAllByLabelText("Street address").type(
faker.address.streetAddress(),
{ force: true }
);
cy.findAllByLabelText("City").type(faker.address.city(), { force: true });
cy.findAllByLabelText("State").select("Alabama", { force: true });
cy.findAllByLabelText("Section").select("--Outreach Hub", { force: true });
// cy.scrollToSelector("#edit-field-media-open-button");
// cy.get("#edit-field-media-open-button").click({ force: true });
// cy.get(".dropzone", {
// timeout: 20000,
// }).should("exist");
// cy.get(".dropzone").attachFile("images/polygon_image.png", {
// subjectType: "drag-n-drop",
// });
// cy.findAllByLabelText("Alternative text").type(faker.lorem.sentence(), {
// force: true,
// });
// cy.get('[data-drupal-selector="edit-media-0-fields-field-owner"]').select(
// "VACO",
// { force: true }
// );
// cy.get("#edit-revision-log-0-value").type(
// `[Test revision log 1]${faker.lorem.sentence()}`,
// { force: true }
// );
// cy.get("button").contains("Save and insert").click({ force: true });
// cy.get(
// 'div.media-library-item[data-drupal-selector="edit-field-media-selection-0"]',
// {
// timeout: 20000,
// }
// ).should("exist");
// cy.get("form.node-form").find("input#edit-submit").click();
// cy.get(".node__content").contains("Sun, Nov 5 2023, 10:00am - 11:00am MST");
// cy.scrollTo("top", { ensureScrollable: false });
// cy.get(".tabs__tab a").contains("Edit").click({ force: true });
// cy.get("#edit-field-datetime-range-timezone-0-manage-instances").click();
// cy.get("table#manage-instances")
// .find(".dropbutton-action")
// .first()
// .find("a")
// .click({ force: true });
// cy.get("#manage-instances form").find("input.form-submit").click();
// cy.get("#manage-instances form").should("not.exist");
// cy.get("button.ui-dialog-titlebar-close").click();
return cy.wait(1000);
},
};

Given("I fill in {string} node details", (contentType) => {
const creator = creators[contentType];
assert.isNotNull(
creator,
`I do not know to fill in ${contentType} node details yet. Please add a definition in ${__filename}.`
);
cy.visit(`/node/add/${contentType}`);
cy.injectAxe();
cy.scrollTo("top");
cy.checkAccessibility();
creator().then(() => {
cy.get("#edit-revision-log-0-value").type(
`[Test revision log]${faker.lorem.sentence()}`,
{ force: true }
);
cy.get("form.node-form").find("input#edit-submit").click();
cy.location("pathname", { timeout: 10000 }).should(
"not.include",
"/node/add"
);
cy.injectAxe();
cy.checkAccessibility();
cy.drupalWatchdogHasNoNewErrors();
cy.getDrupalSettings().then((drupalSettings) => {
const { currentPath } = drupalSettings.path;
cy.wrap(currentPath.split("/").pop()).as("nodeId");
cy.window().then((window) => {
const pagePath = window.location.pathname;
cy.wrap(pagePath).as("pagePath");
});
});
});
});
//
// Given("I create a {string} node and continue", (contentType) => {
// const creator = creators[contentType];
// assert.isDefined(
// creator,
// `I do not know how to create ${contentType} nodes yet. Please add a definition in ${__filename}.`
// );
// cy.visit(`/node/add/${contentType}`);
// cy.injectAxe();
// cy.scrollTo("top");
// cy.checkAccessibility();
// creator().then(() => {
// cy.get("#edit-revision-log-0-value").type(
// `[Test revision log]${faker.lorem.sentence()}`,
// { force: true }
// );
// cy.get("form.node-form").find("input#edit-save-continue").click();
// cy.location("pathname", { timeout: 10000 }).should(
// "not.include",
// "/node/add"
// );
// cy.injectAxe();
// cy.checkAccessibility();
// cy.drupalWatchdogHasNoNewErrors();
// cy.getDrupalSettings().then((drupalSettings) => {
// const { currentPath } = drupalSettings.path;
// const pathComponents = currentPath.split("/");
// pathComponents.pop();
// cy.wrap(pathComponents.pop()).as("nodeId");
// cy.window().then((window) => {
// const pagePath = window.location.pathname;
// cy.wrap(pagePath).as("pagePath");
// });
// });
// });
// });
Loading

0 comments on commit 0eb85d5

Please sign in to comment.