Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full rename to My Museum Tour [WEB-2755] #27

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ cypress/downloads
cypress/screenshots
cypress/videos

# Ignore all dist files except for the CustomTourBuilder
# Ignore all dist files except for the MyMuseumTourBuilder
dist/*
!dist/CustomTourBuilder.js
!dist/MyMuseumTourBuilder.js
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
![Art Institute of Chicago](https://raw.githubusercontent.com/Art-Institute-of-Chicago/template/master/aic-logo.gif)

# Custom Tours ![Build status badge](https://github.com/art-institute-of-chicago/custom-tours/actions/workflows/build.yml/badge.svg)
# My Museum Tour ![Build status badge](https://github.com/art-institute-of-chicago/my-museum-tour/actions/workflows/build.yml/badge.svg)


## Summary of the project

This React app drives the custom tours builder on the main [artic.edu website](https://artic.edu/custom-tours). It provided an interactive client-side interface for users to create custom tours.
This React app drives the My Museum Tour builder on the main [artic.edu website](https://artic.edu/my-museum-tour). It provided an interactive client-side interface for users to create a My Museum Tour.

## Features

- Uses the API from [artic.edu](https://artic.edu) to:
- Search artworks
- `POST` data to the `custom-tours` endpoint
- `POST` data to the `my-museum-tour` endpoint
- Cypress component testing and integration testing
- Included as part of the Github Actions workflow

Expand All @@ -28,9 +28,9 @@ It's decoupled from [artic.edu](https://github.com/art-institute-of-chicago/arti

## Configuration

The `<CustomToursBuilder />` React component can take in two `props`.
The `<MyMuseumTourBuilder />` React component can take in two `props`.

- `apiSaveEndpoint` (optional) - which should be the path to the `custom-tours` save endpoint. If not provided it will default to `/api/v1/custom-tours`
- `apiSaveEndpoint` (optional) - which should be the path to the `my-museum-tour` save endpoint. If not provided it will default to `/api/v1/my-museum-tour`
- `heroImageId` (optional) - which should be a string forming part of a IIIF image identifier that will be concatenated into a IIIF URL. If not provided there will be no hero image rendered on the customization screen.


Expand Down Expand Up @@ -75,7 +75,7 @@ A full list of thse scripts is available in [`package.json`](package.json), or b
<tbody>
<tr>
<td><code>npm run dev</code></td>
<td>Watches files in the <a href="./src"><code>src</code></a> directory for changes and serves a preview at <a href="https://localhost:43110">https://localhost:43110</a> with hot module replacement. You can edit the <a href="./index.html"><code>index.html</code></a> file to update the rendering of this preview (e.g. update the props in <code>CustomToursBuilder</code>)</a></td>
<td>Watches files in the <a href="./src"><code>src</code></a> directory for changes and serves a preview at <a href="https://localhost:43110">https://localhost:43110</a> with hot module replacement. You can edit the <a href="./index.html"><code>index.html</code></a> file to update the rendering of this preview (e.g. update the props in <code>MyMuseumTourBuilder</code>)</a></td>
</tr>
<tr>
<td><code>npm run build</code></td>
Expand Down Expand Up @@ -142,31 +142,31 @@ The expectation is that the code generated by this project will live within [art

```json
{
"custom-tour-builder": "git+ssh://[email protected]/art-institute-of-chicago/custom-tours.git#main",
"my-museum-tour-builder": "git+ssh://[email protected]/art-institute-of-chicago/my-museum-tour.git#main",
}
```

> [!NOTE]<br>
> The fragment (i.e. "#main") of the url shown above refers to the branch. There might be some instances (such as developing a new feature) where you'd like to reference a different branch, which can be achieved by updating this to the corresponding branch and running `npm i custom-tour-builder`. You will need to run this command whenever updates are made to the branch shown here, as the `package-lock.json` stores references to specific commits
> The fragment (i.e. "#main") of the url shown above refers to the branch. There might be some instances (such as developing a new feature) where you'd like to reference a different branch, which can be achieved by updating this to the corresponding branch and running `npm i my-museum-tour-builder`. You will need to run this command whenever updates are made to the branch shown here, as the `package-lock.json` stores references to specific commits

2. Run `npm i custom-tour-builder`
2. Run `npm i my-museum-tour-builder`

3. The default export for the primary component of this app can be accessed as you would any other npm package using ESModules:
```js
import CustomTourBuilder from 'custom-tour-builder';
import MyMuseumTourBuilder from 'my-museum-tour-builder';
```

4. Your app is responsible for mounting this component to the DOM using ReactDOM

React 16:
```js
ReactDOM.render(<CustomTourBuilder/>, container);
ReactDOM.render(<MyMuseumTourBuilder/>, container);
```


React > 16:
```js
ReactDOM.createRoot(container).render(<CustomTourBuilder/>);
ReactDOM.createRoot(container).render(<MyMuseumTourBuilder/>);
```


Expand All @@ -176,10 +176,10 @@ We encourage your contributions. Please fork this repository and make your chang

```bash
# Clone the repo to your computer
git clone [email protected]:art-institute-of-chicago/custom-tours.git
git clone [email protected]:art-institute-of-chicago/my-museum-tour.git

# Enter the folder that was created by the clone
cd custom-tours
cd my-museum-tour

# Start a feature branch
git checkout -b feature/good-short-description
Expand Down
10 changes: 5 additions & 5 deletions dist/CustomTourBuilder.js → dist/MyMuseumTourBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function V(i) {
), [X, Z] = b(l || []), [ee, te] = b(0), [ae, re] = pe(
fe,
m || []
), ie = C(null), ne = C(null), [se, ce] = b([]), le = u || "/api/v1/custom-tours", [oe, me] = b(!1), [ue, de] = b(0), he = O(
), ie = C(null), ne = C(null), [se, ce] = b([]), le = u || "/api/v1/my-museum-tour", [oe, me] = b(!1), [ue, de] = b(0), he = O(
() => ({
objectNote: 255,
title: 255,
Expand Down Expand Up @@ -286,7 +286,7 @@ function Ee() {
className: o,
type: "button",
onClick: () => {
a === 0 ? B.assign("/my-museum-tours") : r(a === 1 ? 0 : 1);
a === 0 ? B.assign("/my-museum-tour") : r(a === 1 ? 0 : 1);
}
},
/* @__PURE__ */ e.createElement("svg", { className: "icon--arrow", "aria-hidden": "true" }, /* @__PURE__ */ e.createElement("use", { xlinkHref: "#icon--arrow" })),
Expand Down Expand Up @@ -1332,7 +1332,7 @@ function Ce() {
const v = [];
a.length || v.push("A tour title"), a.length > h.title && v.push("Tour title must not exceed the character limit"), n || v.push("A valid email address"), m.length > h.description && v.push(
"Tour description must not exceed the character limit"
), o.length < h.items.min && v.push("At least one artwork is required for your tour"), o.length > h.items.max && v.push("Tours must not contain more than 6 artworks"), o.some((x) => {
), o.length < h.items.min && v.push("At least one artwork is required for your tour"), o.length > h.items.max && v.push("Tour must not contain more than 6 artworks"), o.some((x) => {
var R;
return ((R = x.objectNote) == null ? void 0 : R.length) > h.objectNote ? (v.push("Notes must not exceed the character limit"), !0) : !1;
}), u(v);
Expand All @@ -1345,7 +1345,7 @@ function Ce() {
n
]), g(() => {
_ != null && _.id && (window.removeEventListener("beforeunload", E), B.assign(
`/my-museum-tours/${_.id}?tourCreationComplete=true`
`/my-museum-tour/${_.id}?tourCreationComplete=true`
));
}, [_, E]), /* @__PURE__ */ e.createElement("div", { className: "aic-ct-validation" }, l.length ? /* @__PURE__ */ e.createElement(
"div",
Expand Down Expand Up @@ -1462,7 +1462,7 @@ const xe = (i) => {
};
return g(() => {
window.addEventListener("beforeunload", o), document.body.style.overflow = "unset";
}, []), /* @__PURE__ */ e.createElement("div", { id: "custom-tours-builder", className: "custom-tours" }, /* @__PURE__ */ e.createElement(V, { ...m }, /* @__PURE__ */ e.createElement(Ee, null), /* @__PURE__ */ e.createElement(j, null, /* @__PURE__ */ e.createElement(
}, []), /* @__PURE__ */ e.createElement("div", { id: "my-museum-tour-builder", className: "my-museum-tour" }, /* @__PURE__ */ e.createElement(V, { ...m }, /* @__PURE__ */ e.createElement(Ee, null), /* @__PURE__ */ e.createElement(j, null, /* @__PURE__ */ e.createElement(
L,
{
id: 0,
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
<script type="module">
import React from "react";
import ReactDOM from "react-dom";
import CustomToursBuilder from "./src/CustomTourBuilder.jsx";
import MyMuseumTourBuilder from "./src/MyMuseumTourBuilder.jsx";

ReactDOM.render(
React.createElement(
React.StrictMode,
null,
React.createElement(CustomToursBuilder, {
apiSaveEndpoint: "https://artic.edu.ddev.site/api/v1/custom-tours",
React.createElement(MyMuseumTourBuilder, {
apiSaveEndpoint: "https://artic.edu.ddev.site/api/v1/my-museum-tour",
heroImageId: "3c27b499-af56-f0d5-93b5-a7f2f1ad5813",
}),
),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "custom-tours",
"name": "my-museum-tour",
"version": "0.1.0",
"description": "![Art Institute of Chicago](https://raw.githubusercontent.com/Art-Institute-of-Chicago/template/master/aic-logo.gif)",
"main": "dist/CustomTourBuilder.js",
"main": "dist/MyMuseumTourBuilder.js",
"files": [
"dist/CustomTourBuilder.js"
"dist/MyMuseumTourBuilder.js"
],
"scripts": {
"build": "vite build",
"dev": "vite",
"lint": "run-p lint:* prettier",
"lint:scripts": "eslint --fix \"src/**/*.{js,jsx}\"",
"prettier": "prettier -w \"src/**/*.{js,jsx}\"",
"test": "cypress run --component --port=3000",
"test:gui": "cypress open --component --port=3000"
"test": "cypress run --component --port=30001",
"test:gui": "cypress open --component --port=30001"
},
"dependencies": {
"classnames": "^2.3.2",
Expand Down
38 changes: 18 additions & 20 deletions src/CustomTourBuilder.cy.jsx → src/MyMuseumTourBuilder.cy.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import CustomTourBuilder from "./CustomTourBuilder";
import MyMuseumTourBuilder from "./MyMuseumTourBuilder";
import searchJson from "../cypress/fixtures/json/search.json";
import { Location } from "./utils";

Expand Down Expand Up @@ -30,13 +30,13 @@ function interceptSearch() {
});
}

describe("<CustomTourBuilder />", () => {
describe("<MyMuseumTourBuilder />", () => {
beforeEach(() => {
interceptImages().as("images");
interceptSearch().as("search");
});
it("Renders", () => {
cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-search").should("exist");
cy.get("#aic-ct-metadata__title").should("exist");
cy.get("#aic-ct-metadata__description").should("exist");
Expand All @@ -46,7 +46,7 @@ describe("<CustomTourBuilder />", () => {
});

it("Can add each metadata field for the tour", () => {
cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-nav-button-1").click();
cy.get("#aic-ct-metadata__title").type("A tour title", { delay: 0 });
cy.get("#aic-ct-metadata__description").type("A tour description", {
Expand All @@ -73,7 +73,7 @@ describe("<CustomTourBuilder />", () => {
statusCode: 500,
}).as("500");

cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-search__input").type("test");
cy.get("#aic-ct-search__button").click();
cy.get("#aic-ct-search-results__error").should(
Expand All @@ -83,7 +83,7 @@ describe("<CustomTourBuilder />", () => {
});

it("Can perform a keyword search and show results", () => {
cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-search__input").type("test");
cy.get("#aic-ct-search__button").click();
cy.get("#aic-ct-search-results__loading").should("have.text", "Loading...");
Expand All @@ -92,17 +92,15 @@ describe("<CustomTourBuilder />", () => {
});

it("Can perform a search on a theme and show results", () => {
cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-theme-toggle-0").click();
cy.get("#aic-ct-search-results__loading").should("have.text", "Loading...");
cy.get("#aic-ct-search-results__items").should("exist");
cy.get("#aic-ct-search-results__items li").should("have.length", 10);
cy.get("#aic-ct-theme-toggle-0").click();
cy.get("#aic-ct-search-results__items").should("not.exist");
});

it("Can add and remove up to 6 artworks to the tour", () => {
cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);

// Adding and removing from search page
cy.get("#aic-ct-nav-button-0").click();
Expand Down Expand Up @@ -205,7 +203,7 @@ describe("<CustomTourBuilder />", () => {
});

it("Wipes notes when an item is removed and added again", () => {
cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-nav-button-0").click();
cy.get("#aic-ct-search__input").type("test");
cy.get("#aic-ct-search__button").click();
Expand Down Expand Up @@ -236,7 +234,7 @@ describe("<CustomTourBuilder />", () => {
});

it("Displays validation errors on the submission screen", () => {
cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-nav-button-2").click();
cy.get("#aic-ct-validation__errors ul").children().should("have.length", 3);
});
Expand All @@ -249,7 +247,7 @@ describe("<CustomTourBuilder />", () => {
note: tooLongString,
}));
cy.mount(
<CustomTourBuilder
<MyMuseumTourBuilder
tourTitle={tooLongString}
tourDescription={tooLongString}
tourItems={tooManyTourItems}
Expand All @@ -263,11 +261,11 @@ describe("<CustomTourBuilder />", () => {
.parent()
.contains("Tour description must not exceed the character limit")
.parent()
.contains("Tours must not contain more than 6 artworks");
.contains("Tour must not contain more than 6 artworks");
});

it("Shows a submit button if all requirements are met", () => {
cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-nav-button-2").click();
cy.get("#aic-ct-validation__errors ul").children().should("have.length", 3);
cy.get("#aic-ct-nav-button-0").click();
Expand All @@ -288,13 +286,13 @@ describe("<CustomTourBuilder />", () => {
});

it("Correctly handles an error while saving", () => {
cy.intercept("POST", "/api/v1/custom-tours", {
cy.intercept("POST", "/api/v1/my-museum-tour", {
fixture: "json/saveMissingTitle.json",
statusCode: 422,
delayMs: 80,
}).as("save");

cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-nav-button-0").click();
cy.get("#aic-ct-search__input").type("test");
cy.get("#aic-ct-search__button").click();
Expand All @@ -312,7 +310,7 @@ describe("<CustomTourBuilder />", () => {
});

it("Can save and show a success message", () => {
cy.intercept("POST", "/api/v1/my-museum-tours", {
cy.intercept("POST", "/api/v1/my-museum-tour", {
fixture: "json/saveSuccess.json",
statusCode: 201,
delayMs: 80,
Expand All @@ -321,7 +319,7 @@ describe("<CustomTourBuilder />", () => {
// Prevent redirect in this test
cy.stub(Location, "assign").as("assign");

cy.mount(<CustomTourBuilder />);
cy.mount(<MyMuseumTourBuilder />);
cy.get("#aic-ct-nav-button-0").click();
cy.get("#aic-ct-search__input").type("test");
cy.get("#aic-ct-search__button").click();
Expand Down Expand Up @@ -355,7 +353,7 @@ describe("<CustomTourBuilder />", () => {
cy.get("#aic-ct-validation__success").should("exist");
cy.get("@assign").should(
"have.been.calledWith",
"/my-museum-tours/23?tourCreationComplete=true",
"/my-museum-tour/23?tourCreationComplete=true",
);
});
});
8 changes: 4 additions & 4 deletions src/CustomTourBuilder.jsx → src/MyMuseumTourBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { AppProvider } from "./contexts/AppContext";
import PropTypes from "prop-types";
import { iiifUrl } from "./utils";

const CustomTourBuilder = (props) => {
const MyMuseumTourBuilder = (props) => {
// Mainly used for testing, but could be used for hydrating the app
const {
apiSaveEndpoint,
Expand Down Expand Up @@ -50,7 +50,7 @@ const CustomTourBuilder = (props) => {
}, []);

return (
<div id="custom-tours-builder" className="custom-tours">
<div id="my-museum-tour-builder" className="my-museum-tour">
<AppProvider {...AppProviderProps}>
<Header />
<NavPages>
Expand Down Expand Up @@ -139,7 +139,7 @@ const CustomTourBuilder = (props) => {
);
};

CustomTourBuilder.propTypes = {
MyMuseumTourBuilder.propTypes = {
apiSaveEndpoint: PropTypes.string,
tourTitle: PropTypes.string,
tourDescription: PropTypes.string,
Expand All @@ -148,4 +148,4 @@ CustomTourBuilder.propTypes = {
heroImageId: PropTypes.string,
};

export default CustomTourBuilder;
export default MyMuseumTourBuilder;
2 changes: 1 addition & 1 deletion src/components/navigation/Header.cy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ describe("<Header />", () => {
cy.stub(Location, "assign").as("assign");

cy.get("#aic-ct-header__back-button").click();
cy.get("@assign").should("have.been.calledWith", "/my-museum-tours");
cy.get("@assign").should("have.been.calledWith", "/my-museum-tour");
});
});
Loading
Loading