From 885531b34518f526b8cd5ef09e90b094911f2ee2 Mon Sep 17 00:00:00 2001 From: Jono Mingard Date: Tue, 6 Jun 2023 15:50:07 +1200 Subject: [PATCH] Added e2e tests for most simple AdminX settings --- ghost/admin-x-settings/package.json | 1 + .../src/admin-x-ds/global/Select.tsx | 10 +-- .../src/admin-x-ds/global/TextField.tsx | 16 +++-- .../settings/email/DefaultRecipients.tsx | 7 +- .../src/components/settings/email/Mailgun.tsx | 3 +- .../components/settings/general/Facebook.tsx | 5 +- .../components/settings/general/LockSite.tsx | 5 +- .../components/settings/general/Metadata.tsx | 3 +- .../settings/general/PublicationLanguage.tsx | 3 +- .../settings/general/SocialAccounts.tsx | 3 +- .../components/settings/general/TimeZone.tsx | 3 +- .../components/settings/general/Twitter.tsx | 3 +- .../components/settings/membership/Access.tsx | 3 +- .../settings/membership/Analytics.tsx | 3 +- .../test/e2e/email/defaultRecipients.test.ts | 58 ++++++++++++++++ .../test/e2e/email/mailgun.test.ts | 39 +++++++++++ .../test/e2e/general/facebook.test.ts | 42 +++++++++++ .../test/e2e/general/lockSite.test.ts | 65 ++++++++++++++++++ .../test/e2e/general/metadata.test.ts | 41 +++++++++++ .../e2e/general/publicationLanguage.test.ts | 36 ++++++++++ .../test/e2e/general/socialAccounts.test.ts | 41 +++++++++++ .../test/e2e/general/timeZone.test.ts | 36 ++++++++++ .../{ => general}/titleAndDescription.test.ts | 2 +- .../test/e2e/general/twitter.test.ts | 42 +++++++++++ .../test/e2e/membership/access.test.ts | 46 +++++++++++++ .../test/e2e/membership/analytics.test.ts | 42 +++++++++++ ghost/admin-x-settings/test/utils/e2e.ts | 13 +++- .../test/utils/images/image.png | Bin 0 -> 110140 bytes yarn.lock | 5 ++ 29 files changed, 552 insertions(+), 24 deletions(-) create mode 100644 ghost/admin-x-settings/test/e2e/email/defaultRecipients.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/email/mailgun.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/general/facebook.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/general/lockSite.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/general/metadata.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/general/publicationLanguage.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/general/socialAccounts.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/general/timeZone.test.ts rename ghost/admin-x-settings/test/e2e/{ => general}/titleAndDescription.test.ts (95%) create mode 100644 ghost/admin-x-settings/test/e2e/general/twitter.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/membership/access.test.ts create mode 100644 ghost/admin-x-settings/test/e2e/membership/analytics.test.ts create mode 100644 ghost/admin-x-settings/test/utils/images/image.png diff --git a/ghost/admin-x-settings/package.json b/ghost/admin-x-settings/package.json index 874adb307a..4912ef3e4f 100644 --- a/ghost/admin-x-settings/package.json +++ b/ghost/admin-x-settings/package.json @@ -45,6 +45,7 @@ "dependencies": { "@ebay/nice-modal-react": "^1.2.10", "@tryghost/timezone-data": "0.3.0", + "clsx": "^1.2.1", "react": "^18.2.0", "react-dom": "^18.2.0", "validator": "7.2.0" diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/Select.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/Select.tsx index 197c3cfaa1..755255d12d 100644 --- a/ghost/admin-x-settings/src/admin-x-ds/global/Select.tsx +++ b/ghost/admin-x-settings/src/admin-x-ds/global/Select.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react'; +import React, {useEffect, useId, useState} from 'react'; import Heading from './Heading'; import Hint from './Hint'; @@ -20,6 +20,8 @@ interface SelectProps { } const Select: React.FC = ({title, prompt, options, onSelect, error, hint, defaultSelectedOption, clearBg = false}) => { + const id = useId(); + const [selectedOption, setSelectedOption] = useState(defaultSelectedOption); useEffect(() => { @@ -36,9 +38,9 @@ const Select: React.FC = ({title, prompt, options, onSelect, error, return (
- {title && {title}} + {title && {title}}
- {prompt && } {options.map(option => (