Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
ae10e4a8
Commit
ae10e4a8
authored
6 years ago
by
Michael Lange
Browse files
Options
Download
Email Patches
Plain Diff
Use PageObject for job evaluations tests
parent
1c893792
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ui/tests/acceptance/job-evaluations-test.js
+20
-29
ui/tests/acceptance/job-evaluations-test.js
ui/tests/pages/jobs/job/evaluations.js
+21
-0
ui/tests/pages/jobs/job/evaluations.js
with
41 additions
and
29 deletions
+41
-29
ui/tests/acceptance/job-evaluations-test.js
+
20
-
29
View file @
ae10e4a8
import
{
test
}
from
'
qunit
'
;
import
{
findAll
,
click
}
from
'
ember-native-dom-helpers
'
;
import
moduleForAcceptance
from
'
nomad-ui/tests/helpers/module-for-acceptance
'
;
import
Evaluations
from
'
nomad-ui/tests/pages/jobs/job/evaluations
'
;
let
job
;
let
evaluations
;
...
...
@@ -10,29 +10,23 @@ moduleForAcceptance('Acceptance | job evaluations', {
job
=
server
.
create
(
'
job
'
,
{
noFailedPlacements
:
true
,
createAllocations
:
false
});
evaluations
=
server
.
db
.
evaluations
.
where
({
jobId
:
job
.
id
});
visit
(
`/jobs/
${
job
.
id
}
/evaluations`
);
Evaluations
.
visit
({
id
:
job
.
id
}
);
},
});
test
(
'
lists all evaluations for the job
'
,
function
(
assert
)
{
const
evaluationRows
=
findAll
(
'
[data-test-evaluation]
'
);
assert
.
equal
(
evaluationRows
.
length
,
evaluations
.
length
,
'
All evaluations are listed
'
);
evaluations
.
sortBy
(
'
modifyIndex
'
)
.
reverse
()
.
forEach
((
evaluation
,
index
)
=>
{
const
shortId
=
evaluation
.
id
.
split
(
'
-
'
)[
0
];
assert
.
equal
(
evaluationRows
[
index
].
querySelector
(
'
[data-test-id]
'
).
textContent
.
trim
(),
shortId
,
`Evaluation
${
index
}
is
${
shortId
}
`
);
});
assert
.
equal
(
Evaluations
.
evaluations
.
length
,
evaluations
.
length
,
'
All evaluations are listed
'
);
const
sortedEvaluations
=
evaluations
.
sortBy
(
'
modifyIndex
'
).
reverse
();
Evaluations
.
evaluations
.
forEach
((
evaluation
,
index
)
=>
{
const
shortId
=
sortedEvaluations
[
index
].
id
.
split
(
'
-
'
)[
0
];
assert
.
equal
(
evaluation
.
id
,
shortId
,
`Evaluation
${
index
}
is
${
shortId
}
`
);
});
});
test
(
'
evaluations table is sortable
'
,
function
(
assert
)
{
click
(
'
[data-test-sort-by="
priority
"]
'
);
Evaluations
.
sortBy
(
'
priority
'
);
andThen
(()
=>
{
assert
.
equal
(
...
...
@@ -40,17 +34,14 @@ test('evaluations table is sortable', function(assert) {
`/jobs/
${
job
.
id
}
/evaluations?sort=priority`
,
'
the URL persists the sort parameter
'
);
const
evaluationRows
=
findAll
(
'
[data-test-evaluation]
'
);
evaluations
.
sortBy
(
'
priority
'
)
.
reverse
()
.
forEach
((
evaluation
,
index
)
=>
{
const
shortId
=
evaluation
.
id
.
split
(
'
-
'
)[
0
];
assert
.
equal
(
evaluationRows
[
index
].
querySelector
(
'
[data-test-id]
'
).
textContent
.
trim
(),
shortId
,
`Evaluation
${
index
}
is
${
shortId
}
with priority
${
evaluation
.
priority
}
`
);
});
const
sortedEvaluations
=
evaluations
.
sortBy
(
'
priority
'
).
reverse
();
Evaluations
.
evaluations
.
forEach
((
evaluation
,
index
)
=>
{
const
shortId
=
sortedEvaluations
[
index
].
id
.
split
(
'
-
'
)[
0
];
assert
.
equal
(
evaluation
.
id
,
shortId
,
`Evaluation
${
index
}
is
${
shortId
}
with priority
${
sortedEvaluations
[
index
].
priority
}
`
);
});
});
});
This diff is collapsed.
Click to expand it.
ui/tests/pages/jobs/job/evaluations.js
0 → 100644
+
21
-
0
View file @
ae10e4a8
import
{
attribute
,
clickable
,
create
,
collection
,
text
,
visitable
}
from
'
ember-cli-page-object
'
;
export
default
create
({
visit
:
visitable
(
'
/jobs/:id/evaluations
'
),
evaluations
:
collection
(
'
[data-test-evaluation]
'
,
{
id
:
text
(
'
[data-test-id]
'
),
}),
sortOptions
:
collection
(
'
[data-test-sort-by]
'
,
{
id
:
attribute
(
'
data-test-sort-by
'
),
sort
:
clickable
(),
}),
sortBy
(
id
)
{
return
this
.
sortOptions
.
toArray
()
.
findBy
(
'
id
'
,
id
)
.
sort
();
},
});
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help