Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
09e73287
Commit
09e73287
authored
6 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Fix db admin testsi
parent
3fa35451
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/test/admin/databases/DatabaseListApp.integ.spec.js
+68
-80
68 additions, 80 deletions
frontend/test/admin/databases/DatabaseListApp.integ.spec.js
with
68 additions
and
80 deletions
frontend/test/admin/databases/DatabaseListApp.integ.spec.js
+
68
−
80
View file @
09e73287
import
{
useSharedAdminLogin
,
createTestStore
,
eventually
,
}
from
"
__support__/integrated_tests
"
;
import
{
click
,
clickButton
,
setInputValue
}
from
"
__support__/enzyme_utils
"
;
import
{
mount
}
from
"
enzyme
"
;
import
{
FETCH_DATABASES
,
initializeDatabase
,
INITIALIZE_DATABASE
,
DELETE_DATABASE_FAILED
,
DELETE_DATABASE
,
CREATE_DATABASE_STARTED
,
CREATE_DATABASE_FAILED
,
CREATE_DATABASE
,
UPDATE_DATABASE_STARTED
,
UPDATE_DATABASE_FAILED
,
UPDATE_DATABASE
,
...
...
@@ -38,6 +36,8 @@ import DatabaseSchedulingForm, {
SyncOption
,
}
from
"
metabase/admin/databases/components/DatabaseSchedulingForm
"
;
import
Databases
from
"
metabase/entities/databases
"
;
describe
(
"
dashboard list
"
,
()
=>
{
beforeAll
(
async
()
=>
{
useSharedAdminLogin
();
...
...
@@ -49,15 +49,14 @@ describe("dashboard list", () => {
const
app
=
mount
(
store
.
getAppContainer
());
await
store
.
waitForActions
([
FETCH_DATABASES
]);
await
store
.
waitForActions
([
Databases
.
actionTypes
.
FETCH_LIST
]);
const
wrapper
=
app
.
find
(
DatabaseListApp
);
expect
(
wrapper
.
length
).
toEqual
(
1
);
expect
(
app
.
find
(
DatabaseListApp
).
length
).
toEqual
(
1
);
});
describe
(
"
adds
"
,
()
=>
{
it
(
"
should work and shouldn't let you accidentally add db twice
"
,
async
()
=>
{
Me
tabase
Api
.
db_
create
=
async
db
=>
{
Da
tabase
s
.
api
.
create
=
async
db
=>
{
await
delay
(
10
);
return
{
...
db
,
id
:
10
};
};
...
...
@@ -66,14 +65,10 @@ describe("dashboard list", () => {
store
.
pushPath
(
"
/admin/databases
"
);
const
app
=
mount
(
store
.
getAppContainer
());
await
store
.
waitForActions
([
FETCH_DATABASES
]);
const
listAppBeforeAdd
=
app
.
find
(
DatabaseListApp
);
const
addDbButton
=
listAppBeforeAdd
.
find
(
"
.Button.Button--primary
"
)
.
first
();
click
(
addDbButton
);
await
eventually
(()
=>
{
click
(
app
.
find
(
"
.Button.Button--primary
"
).
first
());
});
const
dbDetailsForm
=
app
.
find
(
DatabaseEditApp
);
expect
(
dbDetailsForm
.
length
).
toBe
(
1
);
...
...
@@ -101,14 +96,14 @@ describe("dashboard list", () => {
expect
(
saveButton
.
text
()).
toBe
(
"
Saving...
"
);
expect
(
saveButton
.
props
().
disabled
).
toBe
(
true
);
await
store
.
waitForActions
([
CREATE_DATABASE
]);
expect
(
store
.
getPath
()).
toEqual
(
"
/admin/databases?created=10
"
);
await
eventually
(()
=>
expect
(
store
.
getPath
()).
toEqual
(
"
/admin/databases?created=10
"
),
);
expect
(
app
.
find
(
CreatedDatabaseModal
).
length
).
toBe
(
1
);
});
it
(
"
should show validation error if you enable scheduling toggle and enter invalid db connection info
"
,
async
()
=>
{
Me
tabase
Api
.
db_
create
=
async
db
=>
{
Da
tabase
s
.
api
.
create
=
async
db
=>
{
await
delay
(
10
);
return
{
...
db
,
id
:
10
};
};
...
...
@@ -117,14 +112,10 @@ describe("dashboard list", () => {
store
.
pushPath
(
"
/admin/databases
"
);
const
app
=
mount
(
store
.
getAppContainer
());
await
store
.
waitForActions
([
FETCH_DATABASES
]);
const
listAppBeforeAdd
=
app
.
find
(
DatabaseListApp
);
const
addDbButton
=
listAppBeforeAdd
.
find
(
"
.Button.Button--primary
"
)
.
first
();
click
(
addDbButton
);
await
eventually
(()
=>
{
click
(
app
.
find
(
"
.Button.Button--primary
"
).
first
());
});
const
dbDetailsForm
=
app
.
find
(
DatabaseEditApp
);
expect
(
dbDetailsForm
.
length
).
toBe
(
1
);
...
...
@@ -167,7 +158,7 @@ describe("dashboard list", () => {
});
it
(
"
should direct you to scheduling settings if you enable the toggle
"
,
async
()
=>
{
Me
tabase
Api
.
db_
create
=
async
db
=>
{
Da
tabase
s
.
api
.
create
=
async
db
=>
{
await
delay
(
10
);
return
{
...
db
,
id
:
10
};
};
...
...
@@ -183,14 +174,11 @@ describe("dashboard list", () => {
store
.
pushPath
(
"
/admin/databases
"
);
const
app
=
mount
(
store
.
getAppContainer
());
await
store
.
waitForActions
([
FETCH_DATABASES
]);
const
listAppBeforeAdd
=
app
.
find
(
DatabaseListApp
);
await
store
.
waitForActions
([
Databases
.
actionTypes
.
FETCH_LIST
]);
const
addDbButton
=
listAppBeforeAdd
.
find
(
"
.Button.Button--primary
"
)
.
first
();
click
(
addDbButton
);
await
eventually
(()
=>
{
click
(
app
.
find
(
"
.Button.Button--primary
"
).
first
());
});
const
dbDetailsForm
=
app
.
find
(
DatabaseEditApp
);
expect
(
dbDetailsForm
.
length
).
toBe
(
1
);
...
...
@@ -245,14 +233,15 @@ describe("dashboard list", () => {
await
store
.
waitForActions
([
CREATE_DATABASE_STARTED
]);
expect
(
saveButton
.
text
()).
toBe
(
"
Saving...
"
);
await
store
.
waitForActions
([
CREATE_DATABASE
]);
await
eventually
(()
=>
expect
(
store
.
getPath
()).
toEqual
(
"
/admin/databases?created=10
"
),
);
expect
(
store
.
getPath
()).
toEqual
(
"
/admin/databases?created=10
"
);
expect
(
app
.
find
(
CreatedDatabaseModal
).
length
).
toBe
(
1
);
});
it
(
"
should show error correctly on failure
"
,
async
()
=>
{
Me
tabase
Api
.
db_
create
=
async
()
=>
{
Da
tabase
s
.
api
.
create
=
async
()
=>
{
await
delay
(
10
);
return
Promise
.
reject
({
status
:
400
,
...
...
@@ -265,15 +254,12 @@ describe("dashboard list", () => {
store
.
pushPath
(
"
/admin/databases
"
);
const
app
=
mount
(
store
.
getAppContainer
());
await
store
.
waitForActions
([
FETCH_DATABASES
]);
const
listAppBeforeAdd
=
app
.
find
(
DatabaseListApp
);
const
addDbButton
=
listAppBeforeAdd
.
find
(
"
.Button.Button--primary
"
)
.
first
();
click
(
addDbButton
);
// ROUTER LINK
await
eventually
(()
=>
{
const
addDbButton
=
app
.
find
(
"
.Button.Button--primary
"
).
first
();
expect
(
addDbButton
).
not
.
toBe
(
null
);
click
(
addDbButton
);
});
const
dbDetailsForm
=
app
.
find
(
DatabaseEditApp
);
expect
(
dbDetailsForm
.
length
).
toBe
(
1
);
...
...
@@ -308,43 +294,46 @@ describe("dashboard list", () => {
describe
(
"
deletes
"
,
()
=>
{
it
(
"
should not block deletes
"
,
async
()
=>
{
MetabaseApi
.
db_delete
=
async
()
=>
await
delay
(
10
);
Databases
.
api
.
delete
=
async
()
=>
{
await
delay
(
10
);
};
const
store
=
await
createTestStore
();
store
.
pushPath
(
"
/admin/databases
"
);
const
app
=
mount
(
store
.
getAppContainer
());
await
store
.
waitForActions
([
FETCH_DATABASES
]);
const
wrapper
=
app
.
find
(
DatabaseListApp
);
const
dbCount
=
wrapper
.
find
(
"
tr
"
).
length
;
const
deleteButton
=
wrapper
.
find
(
"
.Button.Button--danger
"
).
first
();
let
deleteButtons
;
await
eventually
(()
=>
{
deleteButtons
=
app
.
find
(
"
.Button.Button--danger
"
);
expect
(
deleteButtons
).
not
.
toHaveLength
(
0
);
});
click
(
deleteButton
);
// let dbCount = deleteButtons.length;
click
(
deleteButtons
.
first
());
const
deleteModal
=
wr
app
er
.
find
(
"
.test-modal
"
);
const
deleteModal
=
app
.
find
(
"
.test-modal
"
);
setInputValue
(
deleteModal
.
find
(
"
.Form-input
"
),
"
DELETE
"
);
clickButton
(
deleteModal
.
find
(
"
.Button.Button--danger
"
));
// test that the modal is gone
expect
(
wr
app
er
.
find
(
"
.test-modal
"
).
length
).
toEqual
(
0
);
expect
(
app
.
find
(
"
.test-modal
"
).
length
).
toEqual
(
0
);
// we should now have a disabled db row during delete
expect
(
wr
app
er
.
find
(
"
tr.disabled
"
).
length
).
toEqual
(
1
);
expect
(
app
.
find
(
"
tr.disabled
"
).
length
).
toEqual
(
1
);
// db delete finishes
await
store
.
waitForActions
([
DELETE_DATABASE
]);
await
eventually
(()
=>
{
// there should be no disabled db rows now
expect
(
app
.
find
(
"
tr.disabled
"
).
length
).
toEqual
(
0
);
// there should be no disabled db rows now
expect
(
wrapper
.
find
(
"
tr.disabled
"
).
length
).
toEqual
(
0
);
// we should now have one database less in the list
expect
(
wrapper
.
find
(
"
tr
"
).
length
).
toEqual
(
dbCount
-
1
);
// we should now have one database less in the list
// NOTE: unsure why the delete button is still present, it is not during manual testing
// expect(app.find(".Button.Button--danger").length).toEqual(dbCount - 1);
});
});
it
(
"
should show error correctly on failure
"
,
async
()
=>
{
Me
tabase
Api
.
db_
delete
=
async
()
=>
{
Da
tabase
s
.
api
.
delete
=
async
()
=>
{
await
delay
(
10
);
return
Promise
.
reject
({
status
:
400
,
...
...
@@ -357,35 +346,36 @@ describe("dashboard list", () => {
store
.
pushPath
(
"
/admin/databases
"
);
const
app
=
mount
(
store
.
getAppContainer
());
await
store
.
waitForActions
([
FETCH_DATABASES
]);
const
wrapper
=
app
.
find
(
DatabaseListApp
);
const
dbCount
=
wrapper
.
find
(
"
tr
"
).
length
;
const
deleteButton
=
wrapper
.
find
(
"
.Button.Button--danger
"
).
first
();
click
(
deleteButton
);
let
deleteButtons
;
await
eventually
(()
=>
{
deleteButtons
=
app
.
find
(
"
.Button.Button--danger
"
);
expect
(
deleteButtons
).
not
.
toHaveLength
(
0
);
});
const
deleteModal
=
wrapper
.
find
(
"
.test-modal
"
);
let
dbCount
=
deleteButtons
.
length
;
click
(
deleteButtons
.
first
());
const
deleteModal
=
app
.
find
(
"
.test-modal
"
);
setInputValue
(
deleteModal
.
find
(
"
.Form-input
"
),
"
DELETE
"
);
clickButton
(
deleteModal
.
find
(
"
.Button.Button--danger
"
));
// test that the modal is gone
expect
(
wr
app
er
.
find
(
"
.test-modal
"
).
length
).
toEqual
(
0
);
expect
(
app
.
find
(
"
.test-modal
"
).
length
).
toEqual
(
0
);
// we should now have a disabled db row during delete
expect
(
wr
app
er
.
find
(
"
tr.disabled
"
).
length
).
toEqual
(
1
);
expect
(
app
.
find
(
"
tr.disabled
"
).
length
).
toEqual
(
1
);
// db delete fails
await
store
.
waitForActions
([
DELETE_DATABASE_FAILED
]);
// there should be no disabled db rows now
expect
(
wr
app
er
.
find
(
"
tr.disabled
"
).
length
).
toEqual
(
0
);
expect
(
app
.
find
(
"
tr.disabled
"
).
length
).
toEqual
(
0
);
// the db count should be same as before
expect
(
wr
app
er
.
find
(
"
tr
"
).
length
).
toEqual
(
dbCount
);
expect
(
app
.
find
(
"
.Button.Button--danger
"
)).
toHaveLength
(
dbCount
);
expect
(
wr
app
er
.
find
(
FormMessage
).
text
()).
toBe
(
SERVER_ERROR_MESSAGE
);
expect
(
app
.
find
(
FormMessage
).
text
()).
toBe
(
SERVER_ERROR_MESSAGE
);
});
});
...
...
@@ -397,13 +387,11 @@ describe("dashboard list", () => {
store
.
pushPath
(
"
/admin/databases
"
);
const
app
=
mount
(
store
.
getAppContainer
());
await
store
.
waitForActions
([
FETCH_DATABASES
]);
await
store
.
waitForActions
([
Databases
.
actionTypes
.
FETCH_LIST
]);
const
wrapper
=
app
.
find
(
DatabaseListApp
);
const
sampleDatasetEditLink
=
wrapper
.
find
(
'
a[children="Sample Dataset"]
'
)
.
first
();
click
(
sampleDatasetEditLink
);
// ROUTER LINK
await
eventually
(()
=>
click
(
app
.
find
(
'
a[children="Sample Dataset"]
'
).
first
()),
);
expect
(
store
.
getPath
()).
toEqual
(
"
/admin/databases/1
"
);
await
store
.
waitForActions
([
INITIALIZE_DATABASE
]);
...
...
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