Skip to content

Commit

Permalink
Merge pull request #814 from prismicio/dev-070
Browse files Browse the repository at this point in the history
[v0.6.1] Bug Fixes
  • Loading branch information
Heyrows authored Jan 19, 2023
2 parents 8b21073 + 0eee573 commit 755db6b
Show file tree
Hide file tree
Showing 41 changed files with 681 additions and 237 deletions.
48 changes: 48 additions & 0 deletions cypress/e2e/slices/00-create.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ describe("Create Slices", () => {
cy.getInputByLabel("Variation ID*").type("bar");

cy.get("#variation-add").submit();

cy.contains("button", "Simulate Slice").should("have.attr", "disabled");
cy.contains("button", "Simulate Slice").realHover();
cy.get("#simulator-button-tooltip").should("be.visible");
cy.get("#simulator-button-tooltip").should(
"contain",
"Save your work in order to simulate"
);
cy.contains("button", "Update screenshot").should("have.attr", "disabled");
cy.contains("button", "Update screenshot").realHover();
cy.get("#update-screenshot-button-tooltip").should("be.visible");
cy.get("#update-screenshot-button-tooltip").should(
"contain",
"Save your work in order to update the screenshot"
);

cy.location("pathname", { timeout: 20000 }).should(
"eq",
`/${lib}/${editedSliceName}/bar`
Expand All @@ -47,6 +63,12 @@ describe("Create Slices", () => {

cy.contains("Save to File System").click();

cy.contains("button", "Simulate Slice").should("not.have.attr", "disabled");
cy.contains("button", "Update screenshot").should(
"not.have.attr",
"disabled"
);

// simulator

simulatorPage.setup();
Expand Down Expand Up @@ -88,4 +110,30 @@ describe("Create Slices", () => {
.its("content.text")
.should("equal", "🎉");
});

it("allows drag n drop to the top position", () => {
// inspired by https://github.com/atlassian/react-beautiful-dnd/blob/master/cypress/integration/reorder.spec.js
// could not get it to work with mouse events

// TODO: use faster fixtures
cy.createSlice(lib, sliceId, sliceName);

cy.get('ul[data-cy="slice-non-repeatable-zone"] > li')
.eq(1)
.contains("Description");

cy.get("[data-rbd-draggable-id='list-item-description'] button")
.first()
.focus()
.trigger("keydown", { keyCode: 32 });
cy.get("[data-rbd-draggable-id='list-item-description'] button")
.first()
.trigger("keydown", { keyCode: 38, force: true })
.wait(1 * 1000)
.trigger("keydown", { keyCode: 32, force: true });

cy.get('ul[data-cy="slice-non-repeatable-zone"] > li')
.eq(0)
.contains("Description");
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/user-flows/scenario_custom_screenshots.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SliceCard } from "../../pages/slices/sliceCard";
import { SlicePage } from "../../pages/slices/slicePage";
import { Menu } from "../../pages/Menu";

describe("I am an existing SM user and I want to upload screenshots on variations of an existing Slice", () => {
describe.skip("I am an existing SM user and I want to upload screenshots on variations of an existing Slice", () => {
const random = Date.now();

const slice = {
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ import "./commands";
// require('./commands')

import "./assertions";

import "cypress-real-events";
15 changes: 15 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"dependencies": {
"cypress": "^12.1.0",
"cypress-localstorage-commands": "^1.7.0",
"cypress-real-events": "^1.7.6",
"cypress-wait-until": "^1.7.2",
"start-server-and-test": "^1.14.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package-lock.json

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

4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/client",
"version": "1.1.16",
"version": "1.1.17-dev-070.11",
"main": "./build/index.js",
"engines": {
"node": ">=14"
Expand All @@ -23,7 +23,7 @@
},
"dependencies": {
"@prismicio/types-internal": "^1.5.3",
"@slicemachine/core": "1.1.16",
"@slicemachine/core": "1.1.17-dev-070.11",
"axios": "^0.27.2",
"form-data": "^3.0.0",
"fp-ts": "^2.11.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/core",
"version": "1.1.16",
"version": "1.1.17-dev-070.11",
"private": false,
"main": "./build/index.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/init/package-lock.json

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

6 changes: 3 additions & 3 deletions packages/init/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/init",
"version": "1.1.16",
"version": "1.1.17-dev-070.11",
"description": "The easiest way to add Slice Machine to your project",
"license": "MIT",
"bin": {
Expand All @@ -21,8 +21,8 @@
"dependencies": {
"@hapi/hapi": "^20.2.0",
"@prismicio/types-internal": "^1.5.3",
"@slicemachine/client": "1.1.16",
"@slicemachine/core": "1.1.16",
"@slicemachine/client": "1.1.17-dev-070.11",
"@slicemachine/core": "1.1.17-dev-070.11",
"adm-zip": "^0.5.9",
"analytics-node": "^6.0.0",
"axios": "^0.24.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/slice-machine/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ module.exports = {
"eslint-config-prettier",
],
ignorePatterns: ["build", "templates", "**/tests/**", "helpers/**"],
rules: {
"@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/strict-boolean-expressions": "warn",
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const AuthInstructions = () => (
borderBottom: (t) => `1px solid ${t.colors?.borders}`,
}}
>
<Heading as="h3">Login to Prismic</Heading>
<Heading as="h3">Log in to Prismic</Heading>
</Flex>
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export const AuthErrorPage = () => {
Could not access your repository
</Text>
<Text sx={{ fontSize: "13px", lineHeight: "24px" }}>
You need to login to Prismic in order to push your changes.
You need to log in to Prismic in order to push your changes.
</Text>
<Button sx={{ mt: "24px" }} onClick={() => openLoginModal()}>
Login to Prismic
Log in to Prismic
</Button>
</Flex>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion packages/slice-machine/components/FormFields/Array.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const FormFieldArray = ({
refs.current[len - 1].focus();
}
setPrevLen(len);
}, [refs.current.length]);
}, [refs.current.length, focusOnNewEntry, prevLen]);

return (
<Fragment>
Expand Down
39 changes: 23 additions & 16 deletions packages/slice-machine/components/FormFields/CheckboxControl.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { useState, useEffect } from "react";
import { useFormikContext } from "formik";

import { FormFieldCheckbox } from "./";

/**
* This components allows to set/unset the value of an arbitrary field via checking/unchecking the box
*
* field: the controlled Formik field that we want to manipulate
* label: a function of text displayed next to the checkbox. Can be either a string or a function
* controlledValue: the value of the field being controlled
* setControlledValue: function to update the value of the controlled value in Formik
* buildControlledValue: function to build the new value based on the current controlled value and the state of the checkbox
*
*/
const CheckboxControl = ({
field,
helpers,
label,
defaultValue,
onChange,
getFieldControl,
setControlFromField,
controlledValue,
setControlledValue,
buildControlledValue,
}) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { values } = useFormikContext();
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
const fieldControl = getFieldControl(values);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
const [isChecked, setCheck] = useState(
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
Expand All @@ -24,13 +29,15 @@ const CheckboxControl = ({

useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
helpers.setValue(
setControlFromField
? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-call
setControlFromField(fieldControl, isChecked)
: fieldControl
);
}, [isChecked, fieldControl]);
buildControlledValue
? // eslint-disable-next-line @typescript-eslint/no-unsafe-call
setControlledValue(buildControlledValue(controlledValue))
: // eslint-disable-next-line @typescript-eslint/no-unsafe-call
setControlledValue(buildControlledValue);
// Adding the missing dependency to this hook triggers an infinite loop
// We decided to leave it for now, waiting for a bigger refactor
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isChecked, controlledValue, buildControlledValue]);

return (
<FormFieldCheckbox
Expand All @@ -44,7 +51,7 @@ const CheckboxControl = ({
onChange={(value) => setCheck(value) && onChange && onChange(value)}
label={
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
typeof label === "function" ? label(fieldControl, isChecked) : label
typeof label === "function" ? label(controlledValue, isChecked) : label
}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/slice-machine/components/LoginModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const LoginModal: React.FunctionComponent = () => {
closeModals();
} catch (e) {
stopLoadingLogin();
openToaster("Logging fail", ToasterType.ERROR);
openToaster("Login failed", ToasterType.ERROR);
}
};

Expand Down Expand Up @@ -157,7 +157,7 @@ const LoginModal: React.FunctionComponent = () => {
{isLoginLoading ? (
<Spinner color="#FFF" size={16} />
) : (
<>Signin to Prismic</>
<>Log in to Prismic</>
)}
</Button>
</Flex>
Expand Down
Loading

0 comments on commit 755db6b

Please sign in to comment.