From b8d431c6142635451666650cfb69c95d57d37a70 Mon Sep 17 00:00:00 2001 From: FOLIO Translations Bot <38661258+folio-translations@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:11:30 -0400 Subject: [PATCH 1/2] Lokalise: updates --- translations/stripes-core/en_SE.json | 16 +++++----- translations/stripes-core/es_419.json | 12 ++++---- translations/stripes-core/sv.json | 42 +++++++++++++-------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/translations/stripes-core/en_SE.json b/translations/stripes-core/en_SE.json index bc8e80dc6..1eace1278 100644 --- a/translations/stripes-core/en_SE.json +++ b/translations/stripes-core/en_SE.json @@ -1,13 +1,13 @@ { - "front.welcome": "Welcome, the Future Of Libraries Is OPEN!", - "front.home": "Home", + "front.welcome": "Välkommen till FOLIO!", + "front.home": "Start", "front.about": "Software versions", - "button.new": "+ New", - "button.new_tooltip": "Add {entry}", - "button.edit": "Edit", - "button.delete": "Delete", - "button.deleteEntry": "Delete {entry}", - "button.saveAndClose": "Save and close", + "button.new": "+ Ny", + "button.new_tooltip": "Lägg till {entry}", + "button.edit": "Redigera", + "button.delete": "Radera", + "button.deleteEntry": "Radera {entry}", + "button.saveAndClose": "Spara och stäng", "button.cancel": "Cancel", "label.confirmDeleteEntry": "{name} will be removed", "label.editEntry": "Edit {entry}", diff --git a/translations/stripes-core/es_419.json b/translations/stripes-core/es_419.json index 692ac60db..3c4ead0d2 100644 --- a/translations/stripes-core/es_419.json +++ b/translations/stripes-core/es_419.json @@ -147,10 +147,10 @@ "placeholder.forgotUsername": "Introduce email o teléfono", "title.cookieEnabled": "Cookies are required to login. Please enable cookies and try again.", "errors.sso.session.failed": "Error al iniciar sesión en SSO. Inténtalo de nuevo", - "logoutPending": "Log out in process...", - "rtr.idleSession.modalHeader": "Your session will expire soon!", - "rtr.idleSession.timeRemaining": "Time remaining", - "rtr.idleSession.keepWorking": "Keep working", - "rtr.idleSession.sessionExpiredSoSad": "Your session expired due to inactivity.", - "rtr.idleSession.logInAgain": "Log in again" + "logoutPending": "Cierre de sesión en proceso...", + "rtr.idleSession.modalHeader": "Su sesión expirará pronto.", + "rtr.idleSession.timeRemaining": "Tiempo restante", + "rtr.idleSession.keepWorking": "Seguir trabajando", + "rtr.idleSession.sessionExpiredSoSad": "Tu sesión expiró por inactividad.", + "rtr.idleSession.logInAgain": "Ingresar de nuevo" } \ No newline at end of file diff --git a/translations/stripes-core/sv.json b/translations/stripes-core/sv.json index bc8e80dc6..e455f28b6 100644 --- a/translations/stripes-core/sv.json +++ b/translations/stripes-core/sv.json @@ -1,19 +1,19 @@ { - "front.welcome": "Welcome, the Future Of Libraries Is OPEN!", - "front.home": "Home", + "front.welcome": "Välkommen till FOLIO!", + "front.home": "Start", "front.about": "Software versions", - "button.new": "+ New", - "button.new_tooltip": "Add {entry}", - "button.edit": "Edit", - "button.delete": "Delete", - "button.deleteEntry": "Delete {entry}", - "button.saveAndClose": "Save and close", - "button.cancel": "Cancel", + "button.new": "+Ny", + "button.new_tooltip": "Lägg till {entry}", + "button.edit": "Redigera", + "button.delete": "Radera", + "button.deleteEntry": "Radera {entry}", + "button.saveAndClose": "Spara och stäng", + "button.cancel": "Ångra", "label.confirmDeleteEntry": "{name} will be removed", - "label.editEntry": "Edit {entry}", + "label.editEntry": "Redigera {entry}", "label.createEntry": "Create {entry}", "label.missingRequiredField": "Please fill this in to continue", - "label.okay": "Okay", + "label.okay": "Okej", "successfullyDeleted": "The {entry} {name} was successfully deleted.", "untitled": "Untitled", "about.paneTitle": "Software versions", @@ -40,17 +40,17 @@ "about.settingsModuleCount": "{count, number} settings {count, plural, one {module} other {modules}}", "about.pluginModuleCount": "{count, number} plugin {count, plural, one {module} other {modules}}", "loggedInAs": "Logged in as {firstName} {lastName}", - "logout": "Log out", - "settings": "Settings", - "folioSettings": "FOLIO settings", + "logout": "Logga ut", + "settings": "Inställningar", + "folioSettings": "FOLIO-inställningar", "loginViaSSO": "Log in via SSO", - "button.close": "Close", - "login": "Log in", - "username": "Username", - "password": "Password", - "loggingIn": "Logging in...", - "button.back": "Back", - "button.confirm": "Confirm", + "button.close": "Stäng", + "login": "Logga in", + "username": "Användarnamn", + "password": "Lösenord", + "loggingIn": "Loggar in...", + "button.back": "Tillbaka", + "button.confirm": "Bekräfta", "title.home": "Home", "title.settings": "Settings", "title.login": "Log in", From 2bb758686b1fb75b9a5bbb3b7162d06c615bbb40 Mon Sep 17 00:00:00 2001 From: Zak Burke Date: Wed, 26 Jun 2024 11:03:40 -0400 Subject: [PATCH 2/2] STCOR-864 correctly evaluate typeof stripes.okapi (#1497) Stripes should render `` either when discovery is complete or when okapi isn't present at all, i.e. when `stripes.config.js` doesn't even contain an `okapi` entry. What's most amazing about this bug is not the bug, which is a relatively simple typo, but that it didn't bite us for more than six years. BTOG init never conducted discovery, but _did_ pass an okapi object during application setup, which is another way of saying that our application didn't have anything that relied on the presence of this bug, but our test suite did. Refs STCOR-864 --- CHANGELOG.md | 1 + src/RootWithIntl.js | 2 +- src/RootWithIntl.test.js | 123 +++++++++++++++++++ src/components/index.js | 1 + test/bigtest/helpers/setup-application.js | 3 + test/jest/__mock__/stripesComponents.mock.js | 1 + 6 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/RootWithIntl.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ee664887..7175b90dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * Avoid deprecated `getChildContext`. Refs STCOR-842. * Read locale from stripes-config before defaulting to `en-US`. Refs STCOR-851. * Correctly populate `stripes.user.user` on reload. Refs STCOR-860. +* Correctly evaluate `stripes.okapi` before rendering ``. Refs STCOR-864. ## [10.1.0](https://github.com/folio-org/stripes-core/tree/v10.1.0) (2024-03-12) [Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.0.0...v10.1.0) diff --git a/src/RootWithIntl.js b/src/RootWithIntl.js index 8658fd941..62e825355 100644 --- a/src/RootWithIntl.js +++ b/src/RootWithIntl.js @@ -70,7 +70,7 @@ const RootWithIntl = ({ stripes, token = '', isAuthenticated = false, disableAut event={events.LOGIN} stripes={connectedStripes} /> - { (connectedStripes.okapi !== 'object' || connectedStripes.discovery.isFinished) && ( + { (typeof connectedStripes.okapi !== 'object' || connectedStripes.discovery.isFinished) && ( {connectedStripes.config.useSecureTokens && } diff --git a/src/RootWithIntl.test.js b/src/RootWithIntl.test.js new file mode 100644 index 000000000..24507b40d --- /dev/null +++ b/src/RootWithIntl.test.js @@ -0,0 +1,123 @@ +/* shhhh, eslint, it's ok. we need "unused" imports for mocks */ +/* eslint-disable no-unused-vars */ + +import { render, screen } from '@folio/jest-config-stripes/testing-library/react'; +import { Router as DefaultRouter } from 'react-router-dom'; +import { createMemoryHistory } from 'history'; + +import { + Login, + MainNav, + MainContainer, + ModuleContainer, + OverlayContainer, + StaleBundleWarning, + SessionEventContainer, +} from './components'; + +import RootWithIntl from './RootWithIntl'; +import Stripes from './Stripes'; + +jest.mock('./components/Login', () => () => ''); +jest.mock('./components/MainNav', () => () => ''); +jest.mock('./components/OverlayContainer', () => () => ''); +jest.mock('./components/ModuleContainer', () => ({ children }) => children); +jest.mock('./components/MainContainer', () => ({ children }) => children); +jest.mock('./components/StaleBundleWarning', () => () => ''); +jest.mock('./components/SessionEventContainer', () => () => ''); + +const defaultHistory = createMemoryHistory(); + +const Harness = ({ + Router = DefaultRouter, + children, + history = defaultHistory, +}) => { + return ( + + {children} + + ); +}; + +const store = { + getState: () => ({ + okapi: { + token: '123', + }, + }), + dispatch: () => {}, + subscribe: () => {}, + replaceReducer: () => {}, +}; + +describe('RootWithIntl', () => { + it('renders login without one of (isAuthenticated, token, disableAuth)', async () => { + const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, discovery: { isFinished: false } }); + await render(); + + expect(screen.getByText(//)).toBeInTheDocument(); + expect(screen.queryByText(//)).toBeNull(); + }); + + describe('renders MainNav', () => { + it('given isAuthenticated', async () => { + const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, discovery: { isFinished: false } }); + await render(); + + expect(screen.queryByText(//)).toBeNull(); + expect(screen.queryByText(//)).toBeInTheDocument(); + }); + + it('given token', async () => { + const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, discovery: { isFinished: false } }); + await render(); + + expect(screen.queryByText(//)).toBeNull(); + expect(screen.queryByText(//)).toBeInTheDocument(); + }); + + it('given disableAuth', async () => { + const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, discovery: { isFinished: false } }); + await render(); + + expect(screen.queryByText(//)).toBeNull(); + expect(screen.queryByText(//)).toBeInTheDocument(); + }); + }); + + describe('renders ModuleContainer', () => { + it('if config.okapi is not an object', async () => { + const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, discovery: { isFinished: true } }); + await render(); + + expect(screen.queryByText(//)).toBeNull(); + expect(screen.queryByText(//)).toBeInTheDocument(); + expect(screen.getByText(//)).toBeInTheDocument(); + }); + + it('if discovery is finished', async () => { + const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, okapi: {}, discovery: { isFinished: true } }); + await render(); + + expect(screen.queryByText(//)).toBeNull(); + expect(screen.queryByText(//)).toBeInTheDocument(); + expect(screen.getByText(//)).toBeInTheDocument(); + }); + }); + + it('renders StaleBundleWarning', async () => { + const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: { staleBundleWarning: {} }, store, okapi: {}, discovery: { isFinished: true } }); + await render(); + + expect(screen.getByText(//)).toBeInTheDocument(); + }); + + it('renders SessionEventContainer', async () => { + const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: { useSecureTokens: true }, store, okapi: {}, discovery: { isFinished: true } }); + await render(); + + expect(screen.getByText(//)).toBeInTheDocument(); + }); + +}); diff --git a/src/components/index.js b/src/components/index.js index 99e2dcd54..f6e471bba 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -31,6 +31,7 @@ export { default as BadRequestScreen } from './BadRequestScreen'; export { default as NoPermissionScreen } from './NoPermissionScreen'; export { default as ResetPasswordNotAvailableScreen } from './ResetPasswordNotAvailableScreen'; export { default as SessionEventContainer } from './SessionEventContainer'; +export { default as StaleBundleWarning } from './StaleBundleWarning'; export * from './ModuleHierarchy'; export * from './Namespace'; diff --git a/test/bigtest/helpers/setup-application.js b/test/bigtest/helpers/setup-application.js index c54aa590c..7346300d8 100644 --- a/test/bigtest/helpers/setup-application.js +++ b/test/bigtest/helpers/setup-application.js @@ -54,6 +54,9 @@ export default function setupApplication({ currentPerms: permissions, isAuthenticated: true, }; + initialState.discovery = { + isFinished: true, + }; } else { initialState.okapi = { ssoEnabled: true, diff --git a/test/jest/__mock__/stripesComponents.mock.js b/test/jest/__mock__/stripesComponents.mock.js index 81647d4c6..1f5a9e44f 100644 --- a/test/jest/__mock__/stripesComponents.mock.js +++ b/test/jest/__mock__/stripesComponents.mock.js @@ -49,6 +49,7 @@ jest.mock('@folio/stripes-components', () => ({ {children} )), Headline: jest.fn(({ children }) =>
{ children }
), + HotKeys: jest.fn(({ children }) => <>{ children }), Icon: jest.fn((props) => (props && props.children ? props.children : )), IconButton: jest.fn(({ buttonProps,