Commit d047f312 authored by mfluharty's avatar mfluharty

Clarify order spec, use testid instead of ref

Make failed tests first spec more clear by comparing arrays
Since we only need it for the spec,
use data-testid on case name instead of ref
parent 5069f0f2
...@@ -82,7 +82,7 @@ export default { ...@@ -82,7 +82,7 @@ export default {
<div role="rowheader" class="table-mobile-header">{{ __('Name') }}</div> <div role="rowheader" class="table-mobile-header">{{ __('Name') }}</div>
<div class="table-mobile-content pr-md-1 gl-overflow-wrap-break"> <div class="table-mobile-content pr-md-1 gl-overflow-wrap-break">
<gl-friendly-wrap <gl-friendly-wrap
ref="casename" data-testid="caseName"
:symbols="$options.wrapSymbols" :symbols="$options.wrapSymbols"
:text="testCase.name" :text="testCase.name"
/> />
......
...@@ -23,7 +23,8 @@ describe('Test reports suite table', () => { ...@@ -23,7 +23,8 @@ describe('Test reports suite table', () => {
const noCasesMessage = () => wrapper.find('.js-no-test-cases'); const noCasesMessage = () => wrapper.find('.js-no-test-cases');
const allCaseRows = () => wrapper.findAll('.js-case-row'); const allCaseRows = () => wrapper.findAll('.js-case-row');
const findCaseRowAtIndex = index => wrapper.findAll('.js-case-row').at(index); const findCaseRowAtIndex = index => wrapper.findAll('.js-case-row').at(index);
const findCaseNameAtIndex = index => wrapper.findAll({ ref: 'casename' }).at(index); const allCaseNames = () =>
wrapper.findAll('[data-testid="caseName"]').wrappers.map(el => el.attributes('text'));
const findIconForRow = (row, status) => row.find(`.ci-status-icon-${status}`); const findIconForRow = (row, status) => row.find(`.ci-status-icon-${status}`);
const createComponent = (suite = testSuite) => { const createComponent = (suite = testSuite) => {
...@@ -62,18 +63,14 @@ describe('Test reports suite table', () => { ...@@ -62,18 +63,14 @@ describe('Test reports suite table', () => {
expect(allCaseRows().length).toBe(testCases.length); expect(allCaseRows().length).toBe(testCases.length);
}); });
it('renders the failed tests first', () => { it('renders the failed tests first, skipped tests next, then successful tests', () => {
const failedCaseNames = testCases const expectedCaseOrder = [
.filter(x => x.status === TestStatus.FAILED) ...testCases.filter(x => x.status === TestStatus.FAILED),
.map(x => x.name); ...testCases.filter(x => x.status === TestStatus.SKIPPED),
...testCases.filter(x => x.status === TestStatus.SUCCESS),
].map(x => x.name);
const skippedCaseNames = testCases expect(allCaseNames()).toEqual(expectedCaseOrder);
.filter(x => x.status === TestStatus.SKIPPED)
.map(x => x.name);
expect(findCaseNameAtIndex(0).attributes('text')).toEqual(failedCaseNames[0]);
expect(findCaseNameAtIndex(1).attributes('text')).toEqual(failedCaseNames[1]);
expect(findCaseNameAtIndex(2).attributes('text')).toEqual(skippedCaseNames[0]);
}); });
it('renders the correct icon for each status', () => { it('renders the correct icon for each status', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment