Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
eebe84d9
Unverified
Commit
eebe84d9
authored
Mar 2, 2023
by
Marlo Longley
Committed by
GitHub
Mar 2, 2023
Browse files
Options
Downloads
Plain Diff
Merge pull request #3675 from ProjectMirador/rtl-workspace-export
Convert WorkspaceExport/Import tests to use RTL
parents
a0dd0f40
34c5837c
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!19
Draft: Merge video support into mui5
,
!18
Only nudge over badge content for the WindowListButton; it needs special...
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
__tests__/src/components/WorkspaceExport.test.js
+19
-29
19 additions, 29 deletions
__tests__/src/components/WorkspaceExport.test.js
__tests__/src/components/WorkspaceImport.test.js
+5
-13
5 additions, 13 deletions
__tests__/src/components/WorkspaceImport.test.js
with
24 additions
and
42 deletions
__tests__/src/components/WorkspaceExport.test.js
+
19
−
29
View file @
eebe84d9
import
{
shallow
}
from
'
enzyme
'
;
import
{
screen
,
render
}
from
'
@testing-library/react
'
;
import
Dialog
from
'
@material-ui/core/Dialog
'
;
import
userEvent
from
'
@testing-library/user-event
'
;
import
Button
from
'
@material-ui/core/Button
'
;
import
Snackbar
from
'
@material-ui/core/Snackbar
'
;
import
{
CopyToClipboard
}
from
'
react-copy-to-clipboard
'
;
import
{
WorkspaceExport
}
from
'
../../../src/components/WorkspaceExport
'
;
import
{
WorkspaceExport
}
from
'
../../../src/components/WorkspaceExport
'
;
describe
(
'
WorkspaceExport
'
,
()
=>
{
describe
(
'
WorkspaceExport
'
,
()
=>
{
let
wrapp
er
;
let
us
er
;
let
handleClose
=
jest
.
fn
();
let
handleClose
=
jest
.
fn
();
let
mockState
;
let
mockState
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
user
=
userEvent
.
setup
();
handleClose
=
jest
.
fn
();
handleClose
=
jest
.
fn
();
mockState
=
{
mockState
=
{
companionWindows
:
{},
companionWindows
:
{},
...
@@ -21,7 +19,7 @@ describe('WorkspaceExport', () => {
...
@@ -21,7 +19,7 @@ describe('WorkspaceExport', () => {
workspace
:
{},
workspace
:
{},
};
};
wrapper
=
shallow
(
render
(
<
WorkspaceExport
<
WorkspaceExport
open
open
handleClose
=
{
handleClose
}
handleClose
=
{
handleClose
}
...
@@ -31,38 +29,30 @@ describe('WorkspaceExport', () => {
...
@@ -31,38 +29,30 @@ describe('WorkspaceExport', () => {
});
});
it
(
'
renders without an error
'
,
()
=>
{
it
(
'
renders without an error
'
,
()
=>
{
expect
(
wrapper
.
find
(
Dialog
).
length
).
toBe
(
1
);
expect
(
screen
.
getByRole
(
'
dialog
'
)).
toBeInTheDocument
(
);
});
});
it
(
'
renders sizing props
'
,
()
=>
{
it
(
'
renders sizing props
'
,
()
=>
{
expect
(
wrapper
.
find
(
Dialog
).
props
()).
toEqual
(
expect
.
objectContaining
({
expect
(
screen
.
getByRole
(
'
dialog
'
)).
toHaveClass
(
'
MuiDialog-paperWidthSm
'
);
fullWidth
:
true
,
maxWidth
:
'
sm
'
,
}));
});
});
it
(
'
is closable by clicking the cancel button
'
,
()
=>
{
it
(
'
is closable by clicking the cancel button
'
,
async
()
=>
{
expect
(
wrapper
.
find
(
Dialog
).
find
(
Button
).
at
(
0
).
text
()).
toMatch
(
'
cancel
'
);
await
user
.
click
(
screen
.
getByRole
(
'
button
'
,
{
name
:
'
cancel
'
}));
wrapper
.
find
(
Dialog
).
find
(
Button
).
at
(
0
).
simulate
(
'
click
'
);
expect
(
handleClose
).
toHaveBeenCalled
();
expect
(
handleClose
).
toHaveBeenCalled
();
});
});
it
(
'
reveals a snackbar on copy
'
,
()
=>
{
it
(
'
reveals a snackbar on copy
'
,
async
()
=>
{
expect
(
wrapper
.
find
(
Dialog
).
find
(
Button
).
at
(
1
).
text
()).
toMatch
(
'
copy
'
);
await
user
.
click
(
screen
.
getByRole
(
'
button
'
,
{
name
:
'
copy
'
})
);
wrapper
.
find
(
Dialog
).
find
(
CopyToClipboard
).
simulate
(
'
copy
'
);
expect
(
screen
.
getByRole
(
'
alert
'
)).
toHaveTextContent
(
'
exportCopied
'
);
expect
(
wrapper
.
find
(
Snackbar
).
length
).
toBe
(
1
);
shallow
(
wrapper
.
find
(
Snackbar
).
props
().
action
).
simulate
(
'
click
'
);
await
user
.
click
(
screen
.
getByRole
(
'
button
'
,
{
name
:
'
dismiss
'
})
);
expect
(
handleClose
).
toHaveBeenCalled
();
expect
(
handleClose
).
toHaveBeenCalled
();
});
});
it
(
'
renders an exportable version of state
'
,
()
=>
{
it
(
'
renders an exportable version of state
'
,
async
()
=>
{
expect
(
wrapper
.
find
(
'
pre
'
).
length
).
toBe
(
1
);
await
user
.
click
(
screen
.
getByRole
(
'
button
'
,
{
name
:
'
viewWorkspaceConfiguration
'
}));
expect
(
wrapper
.
find
(
'
pre
'
).
text
()).
toMatch
(
'
"companionWindows":
'
);
expect
(
screen
.
getByRole
(
'
region
'
).
querySelector
(
'
pre
'
)).
toHaveTextContent
(
// eslint-disable-line testing-library/no-node-access
expect
(
wrapper
.
find
(
'
pre
'
).
text
()).
toMatch
(
'
"config":
'
);
'
{ "companionWindows": {}, "config": {}, "elasticLayout": {}, "viewers": {}, "windows": {}, "workspace": {} }
'
,
expect
(
wrapper
.
find
(
'
pre
'
).
text
()).
toMatch
(
'
"elasticLayout":
'
);
);
expect
(
wrapper
.
find
(
'
pre
'
).
text
()).
toMatch
(
'
"viewers":
'
);
expect
(
wrapper
.
find
(
'
pre
'
).
text
()).
toMatch
(
'
"windows":
'
);
expect
(
wrapper
.
find
(
'
pre
'
).
text
()).
toMatch
(
'
"workspace":
'
);
expect
(
wrapper
.
find
(
'
pre
'
).
text
()).
not
.
toMatch
(
'
"manifests":
'
);
});
});
});
});
This diff is collapsed.
Click to expand it.
__tests__/src/components/WorkspaceImport.test.js
+
5
−
13
View file @
eebe84d9
import
{
shallow
}
from
'
enzyme
'
;
import
{
screen
,
render
}
from
'
@testing-library/react
'
;
import
Dialog
from
'
@material-ui/core/Dialog
'
;
import
TextField
from
'
@material-ui/core/TextField
'
;
import
{
WorkspaceImport
}
from
'
../../../src/components/WorkspaceImport
'
;
import
{
WorkspaceImport
}
from
'
../../../src/components/WorkspaceImport
'
;
describe
(
'
WorkspaceImport
'
,
()
=>
{
describe
(
'
WorkspaceImport
'
,
()
=>
{
let
wrapper
;
let
handleClose
;
let
handleClose
;
let
mockState
;
let
mockState
;
...
@@ -14,7 +11,7 @@ describe('WorkspaceImport', () => {
...
@@ -14,7 +11,7 @@ describe('WorkspaceImport', () => {
configImportValue
:
{},
configImportValue
:
{},
};
};
wrapper
=
shallow
(
render
(
<
WorkspaceImport
<
WorkspaceImport
open
open
handleClose
=
{
handleClose
}
handleClose
=
{
handleClose
}
...
@@ -24,17 +21,12 @@ describe('WorkspaceImport', () => {
...
@@ -24,17 +21,12 @@ describe('WorkspaceImport', () => {
});
});
it
(
'
renders without an error
'
,
()
=>
{
it
(
'
renders without an error
'
,
()
=>
{
expect
(
wrapper
.
find
(
Dialog
).
length
).
toBe
(
1
);
expect
(
screen
.
getByRole
(
'
dialog
'
)).
toBeInTheDocument
(
);
});
});
it
(
'
renders sizing props
'
,
()
=>
{
it
(
'
renders sizing props
'
,
()
=>
{
expect
(
wrapper
.
find
(
Dialog
).
props
()).
toEqual
(
expect
.
objectContaining
({
expect
(
screen
.
getByRole
(
'
dialog
'
)).
toHaveClass
(
'
MuiDialog-paperWidthSm
'
);
fullWidth
:
true
,
maxWidth
:
'
sm
'
,
}));
});
});
it
(
'
renders TextField props
'
,
()
=>
{
it
(
'
renders TextField props
'
,
()
=>
{
expect
(
wrapper
.
find
(
TextField
).
props
()).
toEqual
(
expect
.
objectContaining
({
expect
(
screen
.
getByRole
(
'
textbox
'
)).
toHaveFocus
();
inputProps
:
{
autoFocus
:
'
autofocus
'
},
}));
});
});
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment