<commit_before>'use strict';

var request = require("supertest-as-promised");

const instance_url = process.env.INSTANCE_URL,
      specHelper = require("../support/specHelper");

it ("a new member successfully signs up and then makes a payment", (done) => {
    let app,
        memberSuffix;

    let successfullyCreatingANewMemberShouldRepondWithA200 = () => {
        return request(app)
            .post("/members")
            .set("Content-Type", "application/json")
            .set("Accept", "application/json")
            .send(member)
            .expect(200, {});
    };

    let successfullyCreatingANewInvoiceShouldRespondWithA200 = () => {
        return request(app)
            .post("/invoices")
            .set("Content-Type", "application/json")
            .set("Accept", "application/json")
            .send(invoice)
            .expect(200, {});
    };

    if (instance_url) {
        app = instance_url;
        memberSuffix = Date.now();
    }
    else {
        app = require("../../app");
        memberSuffix = "";
    }

    let member = {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "email": `sherlock${memberSuffix}@holmes.co.uk`,
        "dateOfBirth": "22/12/1900",
        "primaryPhoneNumber": "0396291146",
        "secondaryPhoneNumber": null,
        "gender": "horse radish",
        "residentialAddress": {
            "address": "222b Baker St",
            "suburb": "London",
            "country": "England",
            "state": "VIC",
            "postcode": "12<script>var potato=true;</script>34"
        },
        "postalAddress": {
            "address": "303 collins st",
            "suburb": "melbourne",
            "country": "australia",
            "state": "VIC",
            "postcode": "3000"
        }
    };

    let invoice = {
        "memberEmail": `sherlock${memberSuffix}@holmes.co.uk`,
        "totalAmount": "88.88",
        "paymentType": "deposit"
    };

    successfullyCreatingANewMemberShouldRepondWithA200()
        .then(successfullyCreatingANewInvoiceShouldRespondWithA200)
        .nodeify(done)
        .catch((err) => {
            done.fail(err);
        });
}, 20000);
<commit_msg>give staging 60s to start up before failing the smoke test<commit_after>'use strict';

var request = require("supertest-as-promised");

const instance_url = process.env.INSTANCE_URL,
      specHelper = require("../support/specHelper");

it ("a new member successfully signs up and then makes a payment", (done) => {
    let app,
        memberSuffix;

    let successfullyCreatingANewMemberShouldRepondWithA200 = () => {
        return request(app)
            .post("/members")
            .set("Content-Type", "application/json")
            .set("Accept", "application/json")
            .send(member)
            .expect(200, {});
    };

    let successfullyCreatingANewInvoiceShouldRespondWithA200 = () => {
        return request(app)
            .post("/invoices")
            .set("Content-Type", "application/json")
            .set("Accept", "application/json")
            .send(invoice)
            .expect(200, {});
    };

    if (instance_url) {
        app = instance_url;
        memberSuffix = Date.now();
    }
    else {
        app = require("../../app");
        memberSuffix = "";
    }

    let member = {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "email": `sherlock${memberSuffix}@holmes.co.uk`,
        "dateOfBirth": "22/12/1900",
        "primaryPhoneNumber": "0396291146",
        "secondaryPhoneNumber": null,
        "gender": "horse radish",
        "residentialAddress": {
            "address": "222b Baker St",
            "suburb": "London",
            "country": "England",
            "state": "VIC",
            "postcode": "12<script>var potato=true;</script>34"
        },
        "postalAddress": {
            "address": "303 collins st",
            "suburb": "melbourne",
            "country": "australia",
            "state": "VIC",
            "postcode": "3000"
        }
    };

    let invoice = {
        "memberEmail": `sherlock${memberSuffix}@holmes.co.uk`,
        "totalAmount": "88.88",
        "paymentType": "deposit"
    };

    successfullyCreatingANewMemberShouldRepondWithA200()
        .then(successfullyCreatingANewInvoiceShouldRespondWithA200)
        .nodeify(done)
        .catch((err) => {
            done.fail(err);
        });
}, 60000);
<|endoftext|>


<commit_before>class Wrapper extends React.Component {
  constructor() {
    super();
    this.state = {
      activeTab: "general",
      tabs: {
        general: {
          disabled: false,
          forceDisabled: false,
          autoEnabled: false,
          color: "#deadbf",
          name: "Calendar",
          uri: "moz-storage-calendar://",
          readOnly: true,
          supressAlarms: false,
          canRefresh: false,
          refreshInterval: 30,
          cache: {
            supported: false,
            enabled: false,
            always: false
          },
          capabilities: {
            alarms: {
              popup: {
                supported: true
              }
            }
          }
        }
      }
    };

    // this.recieveMessage.bind(this) gives new reference every time
    // so declaring instance variable so that event can be removed
    // in componentWillUnmount lifecycle
    this.recieveMessage = this.recieveMessage.bind(this);
  }

  componentWillMount() {
    window.addEventListener("message", this.recieveMessage);
  }

  componentDidMount() {
    setTimeout(() => {
      this.postMessage(JSON.stringify(this.state.tabs, null, 2), `${window.location.origin}`);
    }, 20000);

    // set the visuallyselected attribute of first tab to true
    const firstTabNode = document.querySelector(".tab");
    if (firstTabNode) {
      this.selectTabVisually(firstTabNode);
    } else {
      this.tabInterval = setInterval(() => {
        const firstTab = document.querySelector(".tab");
        if (firstTab) {
          this.selectTabVisually(firstTab);
          clearInterval(this.tabInterval);
        }
      }, 50);
    }
  }

  componentWillUnmount() {
    window.removeEventListener("message", this.recieveMessage);
  }

  selectTabVisually(node) {
    node.setAttribute("visuallyselected", "true");
    node.setAttribute("selected", "true");
  }

  deselectTabVisually(node) {
    node.removeAttribute("visuallyselected");
    node.removeAttribute("selected");
  }

  getSelectOptions(arr) {
    arr = arr ? arr : ["NONE"];
    const options = arr.map((e, i) =>
      <option value={i} key={i}>
        {e}
      </option>
    );

    return options;
  }

  handleCalendarToggleChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.disabled = !tabsState.general.disabled;
    this.setState({ tabs: tabsState });
  }

  handleCalendarNameChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.name = event.currentTarget.value;
    this.setState({ tabs: tabsState });
  }

  handleCalendarColorChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.color = event.currentTarget.value;
    this.setState({ tabs: tabsState });
  }

  handleCalendarUriChange(event) {
    this.setState({ tabs: this.state.tabs });
  }

  handleCalendarEmailChange(event) {
    const generalTab = Object.assign({}, this.state.tabs.general, {
      selectedEmailIndex: event.currentTarget.selectedIndex
    });

    const tabsState = Object.assign({}, this.state.tabs, {
      general: generalTab
    });

    this.setState({ tabs: tabsState });
  }

  handleReadOnlyChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.readOnly = !tabsState.general.readOnly;
    this.setState({ tabs: tabsState });
  }

  handleSuppressAlarmsChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.supressAlarms = !tabsState.general.supressAlarms;
    this.setState({ tabs: tabsState });
  }

  // remove this tabName arguemnt when tabStrip is done
  getGeneralTab(tabName) {
    const {
      disabled,
      name,
      color,
      uri,
      readOnly,
      supressAlarms,
      emails,
      selectedEmailIndex
    } = this.state.tabs[tabName];

    const emailOptions = this.getSelectOptions(emails);

    const handleCalendarToggle = this.handleCalendarToggleChange.bind(this);

    const handleCalendarName = this.handleCalendarNameChange.bind(this);

    const handleCalendarColor = this.handleCalendarColorChange.bind(this);

    const handleCalendarUri = this.handleCalendarUriChange.bind(this);

    const handleCalendarEmail = this.handleCalendarEmailChange.bind(this);

    const handleReadOnly = this.handleReadOnlyChange.bind(this);

    const handleSuppressAlarms = this.handleSuppressAlarmsChange.bind(this);

    return (

          <input
            type="checkbox"
            className="checkbox"
            id="calendar-enabled-checkbox"
            value="disabled"
            checked={!disabled}
            onChange={handleCalendarToggle}
          />

            Switch this calendar on

              Calendar Name:

            <input
              type="text"
              id="calendar-name"
              className="row-input"
              value={name}
              onChange={handleCalendarName}
              disabled={disabled}
            />

              Color:

            <input
              type="color"
              id="calendar-color"
              className="row-input"
              value={color}
              onChange={handleCalendarColor}
              disabled={disabled}
            />

              Location:

            <input
              type="text"
              id="calendar-uri"
              className="row-input"
              value={uri}
              onChange={handleCalendarUri}
              disabled={disabled}
            />

              E-Mail:

            <select
              type="text"
              id="email-identity-menulist"
              className="row-input hidden"
              disabled={disabled}
              onChange={handleCalendarEmail}
              value={selectedEmailIndex}
            >
              {emailOptions}
            </select>

              <input
                type="checkbox"
                className="checkbox"
                id="readOnly"
                checked={readOnly}
                onChange={handleReadOnly}
                disabled={disabled}
              />

                Read Only

              <input
                type="checkbox"
                className="checkbox"
                id="fire-alarms"
                checked={supressAlarms}
                onChange={handleSuppressAlarms}
                disabled={disabled}
              />

                Show Reminders

    );
  }

  getTab(tabName) {
    let Tab;
    switch (tabName) {
      case "general":
        Tab = this.getGeneralTab(tabName);
        break;
      default:
        Tab = this.getGeneralTab(tabName);
        break;
    }
    return Tab;
  }

  postMessage(msg, origin) {
    // parent and window are same thing if the current page is not in any frame
    console.log(window !== parent);
    if (window !== parent) {
      parent.postMessage(msg, origin);
    }
  }

  recieveMessage(e) {
    if (e.origin !== window.location.origin) {
      return;
    }

    this.postMessage(
      JSON.stringify({ messageRecieved: true }),
      `${window.location.origin}/iframe-testing-ground`
    );

    console.log("%c Data from Parent: Starts", "color: #333; font-size: 20px; font-weight: bold");
    console.log(`%c ${e.data}`, "color: #ED4CBC; font-size: 16px");
    console.log("%c Data from Parent: Ends", "color: #333; font-size: 20px; font-weight: bold");

    const newTabState = Object.assign({}, JSON.parse(e.data));
    this.setState({ tabs: newTabState });
  }

  changeTab(tabName) {
    this.setState({ activeTab: tabName });
  }

  getTabStrip(activeTab) {
    const tabs = Object.keys(this.state.tabs).map(tabName =>

 {
          const tabNodes = document.querySelectorAll(".tab");

          Array.prototype.forEach.call(tabNodes, tab => {
            this.deselectTabVisually(tab);
          });

          this.selectTabVisually(event.target);
          this.changeTab(tabName);
        }}
        className={`tab ${activeTab === tabName ? "selected" : ""}`}
        selected={activeTab === tabName}
        id={`${tabName}tab`}
        key={tabName}
      >
        {tabName}

    );

    if (tabs.length > 1) {
      return (

          {tabs}

      );
    } else {
      return "";
    }
  }

  render() {
    const Tab = this.getTab(this.state.activeTab);
    const TabStrip = this.getTabStrip(this.state.activeTab);
    return (

          {TabStrip}
          {Tab}

    );
  }
}

ReactDOM.render(<Wrapper />, document.getElementById("root"));
<commit_msg>adding changes<commit_after>class Wrapper extends React.Component {
  constructor() {
    super();
    this.state = {
      activeTab: "general",
      tabs: {
        general: {
          disabled: false,
          forceDisabled: false,
          autoEnabled: false,
          color: "#deadbf",
          name: "Calendar",
          uri: "moz-storage-calendar://",
          readOnly: true,
          supressAlarms: false,
          canRefresh: false,
          refreshInterval: 30,
          cache: {
            supported: false,
            enabled: false,
            always: false
          },
          capabilities: {
            alarms: {
              popup: {
                supported: true
              }
            }
          }
        }
      }
    };

    // this.recieveMessage.bind(this) gives new reference every time
    // so declaring instance variable so that event can be removed
    // in componentWillUnmount lifecycle
    this.recieveMessage = this.recieveMessage.bind(this);
  }

  componentWillMount() {
    window.addEventListener("message", this.recieveMessage);
  }

  componentDidMount() {
    setTimeout(() => {
      this.postMessage(JSON.stringify(this.state.tabs, null, 2), `${window.location.origin}`);
    }, 20000);

    // set the visuallyselected attribute of first tab to true
    const firstTabNode = document.querySelector(".tab");
    if (firstTabNode) {
      this.selectTabVisually(firstTabNode);
    } else {
      this.tabInterval = setInterval(() => {
        const firstTab = document.querySelector(".tab");
        if (firstTab) {
          this.selectTabVisually(firstTab);
          clearInterval(this.tabInterval);
        }
      }, 50);
    }
  }

  componentWillUnmount() {
    window.removeEventListener("message", this.recieveMessage);
  }

  selectTabVisually(node) {
    node.setAttribute("visuallyselected", "true");
    node.setAttribute("selected", "true");
  }

  deselectTabVisually(node) {
    node.removeAttribute("visuallyselected");
    node.removeAttribute("selected");
  }

  getSelectOptions(arr) {
    arr = arr ? arr : ["NONE"];
    const options = arr.map((e, i) =>
      <option value={i} key={i}>
        {e}
      </option>
    );

    return options;
  }

  handleCalendarToggleChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.disabled = !tabsState.general.disabled;
    this.setState({ tabs: tabsState });
  }

  handleCalendarNameChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.name = event.currentTarget.value;
    this.setState({ tabs: tabsState });
  }

  handleCalendarColorChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.color = event.currentTarget.value;
    this.setState({ tabs: tabsState });
  }

  handleCalendarUriChange(event) {
    this.setState({ tabs: this.state.tabs });
  }

  handleCalendarEmailChange(event) {
    const generalTab = Object.assign({}, this.state.tabs.general, {
      selectedEmailIndex: event.currentTarget.selectedIndex
    });

    const tabsState = Object.assign({}, this.state.tabs, {
      general: generalTab
    });

    this.setState({ tabs: tabsState });
  }

  handleReadOnlyChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.readOnly = !tabsState.general.readOnly;
    this.setState({ tabs: tabsState });
  }

  handleSuppressAlarmsChange(event) {
    const tabsState = Object.assign({}, this.state.tabs);
    tabsState.general.supressAlarms = !tabsState.general.supressAlarms;
    this.setState({ tabs: tabsState });
  }

  // remove this tabName arguemnt when tabStrip is done
  getGeneralTab(tabName) {
    const {
      disabled,
      name,
      color,
      uri,
      readOnly,
      supressAlarms,
      emails,
      selectedEmailIndex
    } = this.state.tabs[tabName];

    const emailOptions = this.getSelectOptions(emails);

    const handleCalendarToggle = this.handleCalendarToggleChange.bind(this);

    const handleCalendarName = this.handleCalendarNameChange.bind(this);

    const handleCalendarColor = this.handleCalendarColorChange.bind(this);

    const handleCalendarUri = this.handleCalendarUriChange.bind(this);

    const handleCalendarEmail = this.handleCalendarEmailChange.bind(this);

    const handleReadOnly = this.handleReadOnlyChange.bind(this);

    const handleSuppressAlarms = this.handleSuppressAlarmsChange.bind(this);

    return (

          <input
            type="checkbox"
            className="checkbox"
            id="calendar-enabled-checkbox"
            value="disabled"
            checked={!disabled}
            onChange={handleCalendarToggle}
          />

            Switch this calendar on

              Calendar Name:

            <input
              type="text"
              id="calendar-name"
              className="row-input"
              value={name}
              onChange={handleCalendarName}
              disabled={disabled}
            />

              Color:

            <input
              type="color"
              id="calendar-color"
              className="row-input"
              value={color}
              onChange={handleCalendarColor}
              disabled={disabled}
            />

              Location:

            <input
              type="text"
              id="calendar-uri"
              className="row-input"
              value={uri}
              onChange={handleCalendarUri}
              disabled={disabled}
            />

              E-Mail:

            <select
              type="text"
              id="email-identity-menulist"
              className="row-input hidden"
              disabled={disabled}
              onChange={handleCalendarEmail}
              value={selectedEmailIndex}
            >
              {emailOptions}
            </select>

              <input
                type="checkbox"
                className="checkbox"
                id="readOnly"
                checked={readOnly}
                onChange={handleReadOnly}
                disabled={disabled}
              />

                Read Only

              <input
                type="checkbox"
                className="checkbox"
                id="fire-alarms"
                checked={supressAlarms}
                onChange={handleSuppressAlarms}
                disabled={disabled}
              />

                Show Reminders

    );
  }

  getTab(tabName) {
    let Tab;
    switch (tabName) {
      case "general":
        Tab = this.getGeneralTab(tabName);
        break;
      default:
        Tab = this.getGeneralTab(tabName);
        break;
    }
    return Tab;
  }

  postMessage(msg, origin) {
    // parent and window are same thing if the current page is not in any frame
    if (window !== parent) {
      parent.postMessage(msg, origin);
    }
  }

  recieveMessage(e) {
    if (e.origin !== window.location.origin) {
      return;
    }

    this.postMessage(
      JSON.stringify({ messageRecieved: true }),
      `${window.location.origin}/iframe-testing-ground`
    );

    console.log("%c Data from Parent: Starts", "color: #333; font-size: 20px; font-weight: bold");
    console.log(`%c ${e.data}`, "color: #ED4CBC; font-size: 16px");
    console.log("%c Data from Parent: Ends", "color: #333; font-size: 20px; font-weight: bold");

    const newTabState = Object.assign({}, JSON.parse(e.data));
    this.setState({ tabs: newTabState });
  }

  changeTab(tabName) {
    this.setState({ activeTab: tabName });
  }

  getTabStrip(activeTab) {
    const tabs = Object.keys(this.state.tabs).map(tabName =>

 {
          const tabNodes = document.querySelectorAll(".tab");

          Array.prototype.forEach.call(tabNodes, tab => {
            this.deselectTabVisually(tab);
          });

          this.selectTabVisually(event.target);
          this.changeTab(tabName);
        }}
        className={`tab ${activeTab === tabName ? "selected" : ""}`}
        selected={activeTab === tabName}
        id={`${tabName}tab`}
        key={tabName}
      >
        {tabName}

    );

    if (tabs.length > 1) {
      return (

          {tabs}

      );
    } else {
      return "";
    }
  }

  render() {
    const Tab = this.getTab(this.state.activeTab);
    const TabStrip = this.getTabStrip(this.state.activeTab);
    return (

          {TabStrip}
          {Tab}

    );
  }
}

ReactDOM.render(<Wrapper />, document.getElementById("root"));
<|endoftext|>