@orangelogic/orange-dam-content-browser-sdk 2.1.5 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CBSDKdemo.html +2 -2
  2. package/cypress/support/commands.ts +69 -0
  3. package/cypress/support/component-index.html +22 -0
  4. package/cypress/support/component.ts +46 -0
  5. package/cypress/support/e2e.ts +21 -0
  6. package/cypress.config.ts +69 -0
  7. package/gab_extension/GAB.html +2 -2
  8. package/package.json +32 -2
  9. package/src/components/ArrayClamp/ArrayClamp.cy.tsx +24 -0
  10. package/src/components/Browser/Browser.cy.tsx +307 -0
  11. package/src/components/ControlBar/ControlBar.cy.tsx +336 -0
  12. package/src/components/ControlBar/ControlBar.tsx +4 -1
  13. package/src/components/ControlBar/Facet/Facet.cy.tsx +81 -0
  14. package/src/components/FormatDialog/CropPreviewer/CropPreviewer.cy.tsx +107 -0
  15. package/src/components/FormatDialog/CustomRendition/CustomRendition.cy.tsx +622 -0
  16. package/src/components/FormatDialog/CustomRendition/transformations/Crop.cy.tsx +95 -0
  17. package/src/components/FormatDialog/CustomRendition/transformations/Extension.cy.tsx +332 -0
  18. package/src/components/FormatDialog/CustomRendition/transformations/Format.cy.tsx +70 -0
  19. package/src/components/FormatDialog/CustomRendition/transformations/Quality.cy.tsx +51 -0
  20. package/src/components/FormatDialog/CustomRendition/transformations/Resize.cy.tsx +86 -0
  21. package/src/components/FormatDialog/CustomRendition/transformations/Rotate.cy.tsx +49 -0
  22. package/src/components/FormatDialog/FormatDialog.cy.tsx +472 -0
  23. package/src/components/FormatDialog/FormatDialog.tsx +3 -3
  24. package/src/components/FormatDialog/Previewer/Previewer.cy.tsx +113 -0
  25. package/src/components/FormatDialog/ProxyMenu/ProxyMenu.cy.tsx +70 -0
  26. package/src/components/FormatDialog/TrackingParameters/TrackingParameters.cy.tsx +77 -0
  27. package/src/components/Header/Header.cy.tsx +161 -0
  28. package/src/components/Loader/Loader.cy.tsx +25 -0
  29. package/src/components/NoResult/NoResult.cy.tsx +11 -0
  30. package/src/components/Result/AssetCard/AssetCardWrapper.cy.tsx +209 -0
  31. package/src/components/Result/AssetPreview/AssetPreview.cy.tsx +123 -0
  32. package/src/components/Result/AssetPreview/ImagePreview/ImagePreview.cy.tsx +17 -0
  33. package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.cy.tsx +16 -0
  34. package/src/components/Result/AssetPreview/VideoPreview/VideoPreview.cy.tsx +75 -0
  35. package/src/components/Result/AssetPreview/VideoPreview/VideoPreview.tsx +1 -1
  36. package/src/page/Authenticate/Authenticate.cy.tsx +74 -0
  37. package/src/page/Authenticate/Authenticate.tsx +1 -0
  38. package/src/page/Home/Home.tsx +12 -2
  39. package/src/setupTests.ts +5 -0
  40. package/src/utils/constants.ts +1 -0
  41. package/src/utils/storage.ts +1 -10
  42. package/src/utils/utils.cy.tsx +253 -0
  43. package/tsconfig.json +2 -1
  44. package/src/utils/fetch.ts +0 -116
package/CBSDKdemo.html CHANGED
@@ -6,9 +6,9 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
8
8
 
9
- <script src="https://downloads.orangelogic.com/ContentBrowserSDK/v2.1.5/OrangeDAMContentBrowserSDK.min.js"></script>
9
+ <script src="https://downloads.orangelogic.com/ContentBrowserSDK/v2.1.6/OrangeDAMContentBrowserSDK.min.js"></script>
10
10
  <link rel="stylesheet" type="text/css"
11
- href="https://downloads.orangelogic.com/ContentBrowserSDK/v2.1.5/OrangeDAMContentBrowserSDK.min.css">
11
+ href="https://downloads.orangelogic.com/ContentBrowserSDK/v2.1.6/OrangeDAMContentBrowserSDK.min.css">
12
12
 
13
13
  <style>
14
14
  * {
@@ -0,0 +1,69 @@
1
+ /// <reference types="cypress" />
2
+ // ***********************************************
3
+ // This example commands.ts shows you how to
4
+ // create various custom commands and overwrite
5
+ // existing commands.
6
+ //
7
+ // For more comprehensive examples of custom
8
+ // commands please read more here:
9
+ // https://on.cypress.io/custom-commands
10
+ // ***********************************************
11
+ //
12
+ //
13
+ // -- This is a parent command --
14
+ // Cypress.Commands.add('login', (email, password) => { ... })
15
+ //
16
+ //
17
+ // -- This is a child command --
18
+ // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19
+ //
20
+ //
21
+ // -- This is a dual command --
22
+ // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23
+ //
24
+ //
25
+ // -- This will overwrite an existing command --
26
+ // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27
+ //
28
+ // declare global {
29
+ // namespace Cypress {
30
+ // interface Chainable {
31
+ // login(email: string, password: string): Chainable<void>
32
+ // drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33
+ // dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34
+ // visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35
+ // }
36
+ // }
37
+ // }
38
+
39
+ Cypress.Commands.add(
40
+ 'reactComponent',
41
+ {
42
+ prevSubject: 'element',
43
+ },
44
+ ($el) => {
45
+ if ($el.length !== 1) {
46
+ throw new Error(
47
+ `cy.component() requires element of length 1 but got ${$el.length}`,
48
+ );
49
+ }
50
+ // Query for key starting with __reactInternalInstance$ for React v16.x
51
+ const key = Object.keys($el.get(0)).find((item) =>
52
+ item.startsWith('__reactFiber$'),
53
+ );
54
+ const domFiber = $el.prop(key || '');
55
+ Cypress.log({
56
+ name: 'component',
57
+ consoleProps() {
58
+ return {
59
+ component: domFiber,
60
+ };
61
+ },
62
+ });
63
+ return domFiber.return;
64
+ },
65
+ );
66
+
67
+ Cypress.Commands.add('waitForCustomElement', (tagName) => {
68
+ cy.window().then((win) => win.customElements.whenDefined(tagName));
69
+ });
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
+ <link rel="stylesheet" href="https://design-system.orangelogic.com/css/ol-light.css">
8
+ <script type="module" src="https://design-system.orangelogic.com/entry.1.0.186.js"></script>
9
+ <title>Components App</title>
10
+ <style>
11
+ .resize__input-group {
12
+ display: flex;
13
+ flex: 1;
14
+ } cx-input {
15
+ flex: 1;
16
+ }
17
+ </style>
18
+ </head>
19
+ <body>
20
+ <div data-cy-root></div>
21
+ </body>
22
+ </html>
@@ -0,0 +1,46 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ /* eslint-disable import/no-extraneous-dependencies */
4
+
5
+ // ***********************************************************
6
+ // This example support/component.ts is processed and
7
+ // loaded automatically before your test files.
8
+ //
9
+ // This is a great place to put global configuration and
10
+ // behavior that modifies Cypress.
11
+ //
12
+ // You can change the location of this file or turn off
13
+ // automatically serving support files with the
14
+ // 'supportFile' configuration option.
15
+ //
16
+ // You can read more here:
17
+ // https://on.cypress.io/configuration
18
+ // ***********************************************************
19
+
20
+ // Import commands.js using ES2015 syntax:
21
+ import './commands';
22
+ import '@cypress/code-coverage/support';
23
+
24
+ // Alternatively you can use CommonJS syntax:
25
+ // require('./commands')
26
+
27
+ import { mount } from 'cypress/react';
28
+
29
+ // Augment the Cypress namespace to include type definitions for
30
+ // your custom command.
31
+ // Alternatively, can be defined in cypress/support/component.d.ts
32
+ // with a <reference path="./component" /> at the top of your spec.
33
+ declare global {
34
+ namespace Cypress {
35
+ interface Chainable {
36
+ mount: typeof mount;
37
+ reactComponent: Chainable<any>;
38
+ waitForCustomElement: (tagname: string) => Chainable<any>;
39
+ }
40
+ }
41
+ }
42
+
43
+ Cypress.Commands.add('mount', mount);
44
+
45
+ // Example use:
46
+ // cy.mount(<MyComponent />)
@@ -0,0 +1,21 @@
1
+ // ***********************************************************
2
+ // This example support/e2e.ts is processed and
3
+ // loaded automatically before your test files.
4
+ //
5
+ // This is a great place to put global configuration and
6
+ // behavior that modifies Cypress.
7
+ //
8
+ // You can change the location of this file or turn off
9
+ // automatically serving support files with the
10
+ // 'supportFile' configuration option.
11
+ //
12
+ // You can read more here:
13
+ // https://on.cypress.io/configuration
14
+ // ***********************************************************
15
+
16
+ // Import commands.js using ES2015 syntax:
17
+ import './commands';
18
+ import '@cypress/code-coverage/support';
19
+
20
+ // Alternatively you can use CommonJS syntax:
21
+ // require('./commands')
@@ -0,0 +1,69 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+ import { defineConfig } from 'cypress';
4
+ import path from 'path';
5
+ process.env.NODE_ENV = 'test';
6
+ export default defineConfig({
7
+ e2e: {
8
+ experimentalRunAllSpecs: true,
9
+ setupNodeEvents(on, config) {
10
+ require('@cypress/code-coverage/task')(on, config);
11
+ return config;
12
+ },
13
+ },
14
+
15
+ component: {
16
+ devServer: {
17
+ framework: 'react',
18
+ bundler: 'webpack',
19
+ webpackConfig: {
20
+ resolve: {
21
+ extensions: ['.ts', '.tsx', '.js', '.jsx'],
22
+ alias: {
23
+ '@': path.resolve(__dirname, './src'), // adjust if your src is in a different folder
24
+ },
25
+ },
26
+ mode: 'development',
27
+ devtool: false,
28
+ module: {
29
+ rules: [
30
+ // application and Cypress files are bundled like React components
31
+ // and instrumented using the babel-plugin-istanbul
32
+ // (we will filter the code coverage for non-application files later)
33
+ {
34
+ test: /\.(ts|tsx|js|jsx)?$/,
35
+ exclude: /node_modules/,
36
+ use: {
37
+ loader: 'babel-loader',
38
+ options: {
39
+ presets: [
40
+ '@babel/preset-env',
41
+ ['@babel/preset-react', { runtime: 'automatic' }],
42
+ '@babel/preset-typescript',
43
+ ],
44
+ plugins: [
45
+ // we could optionally insert this plugin
46
+ // only if the code coverage flag is on
47
+ 'babel-plugin-istanbul',
48
+ ],
49
+ },
50
+ },
51
+ },
52
+ ],
53
+ },
54
+ },
55
+ },
56
+ setupNodeEvents(on, config) {
57
+ require('@cypress/code-coverage/task')(on, config);
58
+ on('task', {
59
+ log: message => {
60
+ console.log(message);
61
+ return null;
62
+ },
63
+ });
64
+ return config;
65
+ },
66
+ },
67
+ viewportWidth: 1280,
68
+ viewportHeight: 720,
69
+ });
@@ -3,9 +3,9 @@
3
3
 
4
4
  <head>
5
5
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&amp;display=swap">
6
- <script src="https://downloads.orangelogic.com/Cortex/AssetBrowser/v2.1.5/OrangeDamAssetBrowser.min.js"></script>
6
+ <script src="https://downloads.orangelogic.com/Cortex/AssetBrowser/v2.1.6/OrangeDamAssetBrowser.min.js"></script>
7
7
  <link rel="stylesheet" type="text/css"
8
- href="https://downloads.orangelogic.com/Cortex/AssetBrowser/v2.1.5/OrangeDamAssetBrowser.min.css">
8
+ href="https://downloads.orangelogic.com/Cortex/AssetBrowser/v2.1.6/OrangeDamAssetBrowser.min.css">
9
9
  <style>
10
10
  #orangelogic-GAB-browser-wrapper {
11
11
  min-width: 382px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangelogic/orange-dam-content-browser-sdk",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "OrangeDAM Content Browser SDK source code",
5
5
  "main": "index.js",
6
6
  "homepage": "/",
@@ -27,9 +27,15 @@
27
27
  "start": "node scripts/start.js",
28
28
  "test": "node scripts/test.js",
29
29
  "format": "eslint --fix .",
30
- "lint": "tsc --noEmit && eslint src/**/*.ts{,x}"
30
+ "lint": "tsc --noEmit && eslint src/**/*.ts{,x}",
31
+ "cypress:test": "cypress run --component --browser chrome"
31
32
  },
32
33
  "devDependencies": {
34
+ "@babel/preset-env": "^7.26.9",
35
+ "@babel/preset-react": "^7.26.3",
36
+ "@babel/preset-typescript": "^7.27.0",
37
+ "@cypress/code-coverage": "^3.14.0",
38
+ "@cypress/instrument-cra": "^1.4.0",
33
39
  "@semantic-release/changelog": "^6.0.3",
34
40
  "@semantic-release/exec": "^6.0.3",
35
41
  "@semantic-release/git": "^10.0.1",
@@ -42,6 +48,8 @@
42
48
  "@types/webfontloader": "^1.6.35",
43
49
  "@typescript-eslint/eslint-plugin": "^6.21.0",
44
50
  "@typescript-eslint/parser": "^6.21.0",
51
+ "babel-plugin-istanbul": "^7.0.0",
52
+ "cypress": "^14.3.0",
45
53
  "ajv": "^8.9.0",
46
54
  "autoprefixer": "^10.4.14",
47
55
  "eslint": "^8.46.0",
@@ -186,6 +194,28 @@
186
194
  ]
187
195
  },
188
196
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
197
+ "nyc": {
198
+ "all": true,
199
+ "excludeAfterRemap": true,
200
+ "include": [
201
+ "src/**/*.{ts,tsx}"
202
+ ],
203
+ "exclude": [
204
+ "src/store/**/*",
205
+ "src/__tests__/**/*",
206
+ "src/**/*.d.ts",
207
+ "src/types/**/*",
208
+ "src/utils/api.ts",
209
+ "src/AppContext.ts",
210
+ "src/page/Home/**/*",
211
+ "src/view/**/*"
212
+ ],
213
+ "check-coverage": true,
214
+ "branches": 70,
215
+ "functions": 90,
216
+ "lines": 80,
217
+ "statements": 80
218
+ },
189
219
  "publishConfig": {
190
220
  "access": "public"
191
221
  }
@@ -0,0 +1,24 @@
1
+ /// <reference types="cypress" />
2
+
3
+ import ArrayClamp from '@/components/ArrayClamp';
4
+
5
+
6
+ describe('Loader', () => {
7
+
8
+ it('Should hide 3 items', () => {
9
+ cy.mount(<div style={{
10
+ width: '300px',
11
+ }}><ArrayClamp>
12
+ {[1, 2, 3, 4, 5].map((item) => (
13
+ <span key={item} style={{
14
+ width: '120px',
15
+ display: 'inline-block',
16
+ }}>{item}</span>
17
+ ))}
18
+ </ArrayClamp></div>);
19
+ cy.get('.clamped').should('have.length', 3);
20
+ });
21
+
22
+
23
+
24
+ });
@@ -0,0 +1,307 @@
1
+ /// <reference types="cypress" />
2
+
3
+ import { Provider } from 'react-redux';
4
+ import { store } from '@/store';
5
+
6
+ import Browser from './Browser';
7
+ import { Folder } from '@/types/search';
8
+ import { storeData } from '@/utils/storage';
9
+
10
+ const BrowserProps = {
11
+ collectionPath: 'containers>>virtual folders',
12
+ currentFolder: {
13
+ id: '2Y1FQECIK0',
14
+ title: 'Library',
15
+ docType: 'Story',
16
+ path: [''],
17
+ fullPath: 'Library',
18
+ parents: [
19
+ {
20
+ id: '',
21
+ title: '',
22
+ docType: 'Story',
23
+ path: [],
24
+ parents: [],
25
+ fullPath: '',
26
+ hasChildren: true,
27
+ },
28
+ ],
29
+ hasChildren: true,
30
+ },
31
+ lastLocationMode: true,
32
+ open: true,
33
+ showCollections: true,
34
+ useSession: 'qqqqqq',
35
+ };
36
+
37
+ const folderData = [
38
+ {
39
+ recordID: '2Y1FQECIK0',
40
+ fields: {
41
+ 'CoreField.TitleWithFallback': 'Library',
42
+ 'CoreField.DocType': 'Story',
43
+ 'Document.CortexPath': 'Root/Library',
44
+ 'Document.HasBrowserChildren': '1',
45
+ AllowATSLink: 'False',
46
+ },
47
+ },
48
+ {
49
+ recordID: '2Y1FQECZA6',
50
+ fields: {
51
+ 'CoreField.TitleWithFallback': 'Personal Folders',
52
+ 'CoreField.DocType': 'Story',
53
+ 'Document.CortexPath': 'Root/Personal Folders',
54
+ 'Document.HasBrowserChildren': '1',
55
+ AllowATSLink: 'False',
56
+ },
57
+ },
58
+ {
59
+ recordID: '2Y1FQEZH3T',
60
+ fields: {
61
+ 'CoreField.TitleWithFallback': 'Database',
62
+ 'CoreField.DocType': 'Story',
63
+ 'Document.CortexPath': 'Root/Database',
64
+ 'Document.HasBrowserChildren': '1',
65
+ AllowATSLink: 'False',
66
+ },
67
+ },
68
+ {
69
+ recordID: '2Y1FQEF3LZ',
70
+ fields: {
71
+ 'CoreField.TitleWithFallback': 'Site',
72
+ 'CoreField.DocType': 'Story',
73
+ 'Document.CortexPath': 'Root/Site',
74
+ 'Document.HasBrowserChildren': '1',
75
+ AllowATSLink: 'False',
76
+ },
77
+ },
78
+ {
79
+ recordID: '2Y1FQEK3DZ',
80
+ fields: {
81
+ 'CoreField.TitleWithFallback': 'System Bin',
82
+ 'CoreField.DocType': 'Story',
83
+ 'Document.CortexPath': 'Root/System Bin',
84
+ 'Document.HasBrowserChildren': '0',
85
+ AllowATSLink: 'False',
86
+ },
87
+ },
88
+ ];
89
+
90
+ const BrowserWrapper = ({
91
+ lastLocationMode,
92
+ onFolderSelect,
93
+ }: {
94
+ onFolderSelect?: (selectedFolder: Folder) => void;
95
+ lastLocationMode?: boolean;
96
+ }) => {
97
+ const props = { ...BrowserProps };
98
+ if (lastLocationMode !== undefined) {
99
+ props.lastLocationMode = lastLocationMode;
100
+ }
101
+ return (
102
+ <Provider store={store}>
103
+ <Browser {...props} onFolderSelect={onFolderSelect || (() => {})} onClose={() => {}} />
104
+ </Provider>
105
+ );
106
+ };
107
+
108
+ describe('Browser', () => {
109
+ beforeEach(() => {
110
+ cy.intercept(
111
+ 'GET',
112
+ '/webapi/extensibility/integrations/contentBrowserSDK/getcontent_4bw_v1*',
113
+ (req) => {
114
+ const url = new URL(req.url);
115
+ const objectRecordID = url.searchParams.get('objectRecordID');
116
+ const extraFilters = url.searchParams.get('extraFilters');
117
+ const searchText = (extraFilters || '').split('Story_Title:')[1]?.split(' ')[0];
118
+ if (objectRecordID) {
119
+ req.reply({
120
+ body: {
121
+ contentItems: [
122
+ {
123
+ recordID: '2Y1FQEX9IB9',
124
+ fields: {
125
+ 'CoreField.TitleWithFallback': 'Images',
126
+ 'CoreField.DocType': 'Story',
127
+ 'Document.CortexPath': 'Root/Library/Images',
128
+ 'Document.HasBrowserChildren': '0',
129
+ AllowATSLink: 'False',
130
+ },
131
+ },
132
+ {
133
+ recordID: '2Y1FQEYV03',
134
+ fields: {
135
+ 'CoreField.TitleWithFallback': 'Contact photos',
136
+ 'CoreField.DocType': 'Story',
137
+ 'Document.CortexPath': 'Root/Library/Contact photos',
138
+ 'Document.HasBrowserChildren': '0',
139
+ AllowATSLink: 'False',
140
+ },
141
+ },
142
+ {
143
+ recordID: '2Y1FQEQANQ9',
144
+ fields: {
145
+ 'CoreField.TitleWithFallback': 'Items without primary links',
146
+ 'CoreField.DocType': 'Story',
147
+ 'Document.CortexPath': 'Root/Library/Items without primary links',
148
+ 'Document.HasBrowserChildren': '1',
149
+ AllowATSLink: 'False',
150
+ },
151
+ },
152
+ ],
153
+ },
154
+ delay: 1000,
155
+ });
156
+ } else if (searchText) {
157
+ if (searchText === 'Lib') {
158
+ req.reply({
159
+ body: {
160
+ contentItems: [
161
+ {
162
+ recordID: '2Y1FQECIK0',
163
+ fields: {
164
+ 'CoreField.TitleWithFallback': 'Library',
165
+ 'CoreField.DocType': 'Story',
166
+ 'Document.CortexPath': 'Root/Library',
167
+ 'Document.HasBrowserChildren': '1',
168
+ AllowATSLink: 'False',
169
+ },
170
+ },
171
+ ],
172
+ },
173
+ delay: 1000,
174
+ });
175
+ } else {
176
+ req.reply({
177
+ body: {
178
+ contentItems: [],
179
+ },
180
+ delay: 1000,
181
+ });
182
+ }
183
+ } else {
184
+ req.reply({
185
+ body: {
186
+ contentItems: folderData,
187
+ },
188
+ delay: 1000,
189
+ });
190
+ }
191
+ },
192
+ ).as('getFolders');
193
+ });
194
+
195
+ it('Should render the browser with correct number of items', () => {
196
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
197
+
198
+ cy.get('cx-tree-item').should('have.length', folderData.length);
199
+ });
200
+
201
+ it('Should expand', () => {
202
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
203
+
204
+ cy.get('cx-tree-item').eq(0).shadow().find('[part="expand-button"]').click();
205
+ cy.get('cx-tree-item').eq(0).find('cx-tree-item').should('have.length', 3);
206
+ });
207
+
208
+ it('Should collapse', () => {
209
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
210
+
211
+ cy.get('cx-tree-item').eq(0).shadow().find('[part="expand-button"]').click();
212
+ cy.get('cx-tree-item').eq(0).shadow().find('[part="expand-button"]').click();
213
+ cy.get('cx-tree-item').eq(0).should('not.have.attr', 'expanded');
214
+ });
215
+
216
+ it('Should show search results', () => {
217
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
218
+
219
+ cy.get('cx-input').shadow().find('input').type('Lib');
220
+ cy.get('cx-tree-item').should('have.length', 1);
221
+ });
222
+
223
+ it('Should show no search results', () => {
224
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
225
+
226
+ cy.get('cx-input').shadow().find('input').type('non-existing-folder');
227
+ cy.get('cx-tree-item').should('have.length', 0);
228
+ });
229
+
230
+ it('Should reset the search results', () => {
231
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
232
+
233
+ cy.get('cx-input').shadow().find('input').type('Lib');
234
+ cy.get('cx-tree-item').should('have.length', 1);
235
+ cy.get('cx-input').shadow().find('input').clear();
236
+ cy.get('cx-tree-item').should('have.length', folderData.length);
237
+ });
238
+
239
+ it('Should close the browser', () => {
240
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
241
+
242
+ cy.get('cx-drawer').shadow().find('cx-icon-button').click();
243
+ cy.get('cx-drawer').should('not.have.attr', 'open');
244
+ });
245
+
246
+ it('Should select default folder when localStorage data is invalid', () => {
247
+ storeData('lastLocation', 'hello');
248
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
249
+ cy.get('cx-tree-item').should('have.length', folderData.length);
250
+ cy.get('cx-tree-item').eq(0).should('have.attr', 'selected');
251
+ });
252
+
253
+ it('Should select default folder when localStorage data is not found', () => {
254
+ storeData(
255
+ 'lastLocation',
256
+ JSON.stringify({
257
+ id: 'some-random-id',
258
+ }),
259
+ );
260
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
261
+ cy.get('cx-tree-item').should('have.length', folderData.length);
262
+ cy.get('cx-tree-item').eq(0).should('have.attr', 'selected');
263
+ });
264
+
265
+ it('Should select correct folder when localStorage data is valid', () => {
266
+ storeData(
267
+ 'lastLocation',
268
+ JSON.stringify({
269
+ id: '2Y1FQECIK0',
270
+ title: 'Library',
271
+ docType: 'Story',
272
+ path: [''],
273
+ fullPath: 'Library',
274
+ parents: [
275
+ {
276
+ id: '',
277
+ title: '',
278
+ docType: 'Story',
279
+ path: [],
280
+ parents: [],
281
+ fullPath: '',
282
+ hasChildren: true,
283
+ },
284
+ ],
285
+ hasChildren: true,
286
+ }),
287
+ );
288
+ cy.mount(<BrowserWrapper></BrowserWrapper>);
289
+ cy.get('cx-tree-item').should('have.length', folderData.length);
290
+ cy.get('cx-tree-item').eq(0).should('have.attr', 'selected');
291
+ });
292
+
293
+ it('Should render default folder when lastLocationMode is false', () => {
294
+ cy.mount(<BrowserWrapper lastLocationMode={false}></BrowserWrapper>);
295
+ cy.get('cx-tree-item').should('have.length', folderData.length);
296
+ cy.get('cx-tree-item').eq(0).should('have.attr', 'selected');
297
+ });
298
+
299
+ it('Should call onFolderSelect when a folder is selected', () => {
300
+ const onFolderSelect = cy.stub().as('onFolderSelect');
301
+ cy.mount(<BrowserWrapper onFolderSelect={onFolderSelect}></BrowserWrapper>);
302
+
303
+ cy.get('cx-tree-item').eq(2).click();
304
+
305
+ cy.get('@onFolderSelect').should('have.been.called');
306
+ });
307
+ });