|
1 |
| -import { DebugSpecsFragmentDoc } from '../generated/graphql-test' |
| 1 | +import { DebugSpecListGroupsFragment, DebugSpecListSpecFragment, DebugSpecListTestsFragment, DebugSpecsFragmentDoc } from '../generated/graphql-test' |
2 | 2 | import DebugContainer from './DebugContainer.vue'
|
3 | 3 | import { defaultMessages } from '@cy/i18n'
|
4 | 4 | import { useLoginConnectStore } from '@packages/frontend-shared/src/store/login-connect-store'
|
@@ -83,69 +83,81 @@ describe('<DebugContainer />', () => {
|
83 | 83 | })
|
84 | 84 |
|
85 | 85 | describe('testing util function: debugMapping', () => {
|
86 |
| - const createSpecs = (idArr: string[]) => { |
87 |
| - const acc: {id: string}[] = [] |
88 |
| - |
89 |
| - idArr.forEach((val) => { |
90 |
| - acc.push({ id: val }) |
91 |
| - }) |
92 |
| - |
93 |
| - return acc |
94 |
| - } |
95 |
| - |
96 | 86 | it('maps correctly for a single spec', () => {
|
97 |
| - const spec = createSpecs(['a1c']) |
| 87 | + const specs = [ |
| 88 | + { id: 'a1c', groupIds: ['a'] }, |
| 89 | + ] as DebugSpecListSpecFragment[] |
98 | 90 | const tests = [
|
99 | 91 | { specId: 'a1c', id: 'random1' },
|
100 | 92 | { specId: 'a1c', id: 'random2' },
|
101 |
| - ] |
| 93 | + ] as DebugSpecListTestsFragment[] |
| 94 | + const groups = [ |
| 95 | + { id: 'a', testingType: 'e2e' }, |
| 96 | + { id: 'b', testingType: 'e2e' }, |
| 97 | + ] as DebugSpecListGroupsFragment[] |
102 | 98 |
|
103 |
| - const debugMappingArray = specsList(spec, tests) |
| 99 | + const debugMappingArray = specsList({ specs, tests, groups, localSpecs: [], currentTestingType: 'e2e' }) |
104 | 100 |
|
105 | 101 | expect(debugMappingArray).to.have.length(1)
|
106 |
| - expect(debugMappingArray[0]).to.deep.equal({ spec: { id: 'a1c' }, tests: [{ specId: 'a1c', id: 'random1' }, { specId: 'a1c', id: 'random2' }] }) |
| 102 | + expect(debugMappingArray[0]).to.deep.equal({ spec: { id: 'a1c', groupIds: ['a'] }, tests: [{ specId: 'a1c', id: 'random1' }, { specId: 'a1c', id: 'random2' }], groups: [{ id: 'a', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true }) |
107 | 103 | })
|
108 | 104 |
|
109 | 105 | it('maps correctly for multiple specs and test', () => {
|
110 |
| - const specs = createSpecs(['123', '456', '789']) |
| 106 | + const specs = [ |
| 107 | + { id: '123', groupIds: ['a'] }, |
| 108 | + { id: '456', groupIds: ['b'] }, |
| 109 | + { id: '789', groupIds: ['a', 'b'] }, |
| 110 | + ] as DebugSpecListSpecFragment[] |
111 | 111 | const tests = [
|
112 | 112 | { specId: '123', id: 'random1' },
|
113 | 113 | { specId: '456', id: 'random2' },
|
114 | 114 | { specId: '456', id: 'random3' },
|
115 | 115 | { specId: '789', id: 'random4' },
|
116 | 116 | { specId: '123', id: 'random6' },
|
117 |
| - ] |
| 117 | + ] as DebugSpecListTestsFragment[] |
| 118 | + const groups = [ |
| 119 | + { id: 'a', testingType: 'e2e' }, |
| 120 | + { id: 'b', testingType: 'e2e' }, |
| 121 | + ] as DebugSpecListGroupsFragment[] |
118 | 122 |
|
119 |
| - const debugMappingArray = specsList(specs, tests) |
| 123 | + const debugMappingArray = specsList({ specs, tests, localSpecs: [], currentTestingType: 'e2e', groups }) |
120 | 124 |
|
121 | 125 | const expected = [
|
122 |
| - { spec: { id: '123' }, tests: [{ specId: '123', id: 'random1' }, { specId: '123', id: 'random6' }] }, |
123 |
| - { spec: { id: '456' }, tests: [{ specId: '456', id: 'random2' }, { specId: '456', id: 'random3' }] }, |
124 |
| - { spec: { id: '789' }, tests: [{ specId: '789', id: 'random4' }] }, |
| 126 | + { spec: { id: '123', groupIds: ['a'] }, tests: [{ specId: '123', id: 'random1' }, { specId: '123', id: 'random6' }], groups: [{ id: 'a', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true }, |
| 127 | + { spec: { id: '456', groupIds: ['b'] }, tests: [{ specId: '456', id: 'random2' }, { specId: '456', id: 'random3' }], groups: [{ id: 'b', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true }, |
| 128 | + { spec: { id: '789', groupIds: ['a', 'b'] }, tests: [{ specId: '789', id: 'random4' }], groups: [{ id: 'a', testingType: 'e2e' }, { id: 'b', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true }, |
125 | 129 | ]
|
126 | 130 |
|
127 | 131 | expect(debugMappingArray).to.deep.equal(expected)
|
128 | 132 | })
|
129 | 133 |
|
130 | 134 | it('maps does not show specs that do not have tests', () => {
|
131 |
| - const specs = createSpecs(['123', '456', '789']) |
132 |
| - const tests = [{ specId: '123', id: 'random1' }] |
| 135 | + const specs = [ |
| 136 | + { id: '123', groupIds: ['a'] }, |
| 137 | + { id: '456', groupIds: ['a'] }, |
| 138 | + { id: '789', groupIds: ['a'] }, |
| 139 | + ] as DebugSpecListSpecFragment[] |
| 140 | + const tests = [{ specId: '123', id: 'random1' }] as DebugSpecListTestsFragment[] |
| 141 | + const groups = [{ id: 'a', testingType: 'e2e' }] as DebugSpecListGroupsFragment[] |
133 | 142 |
|
134 |
| - const debugMappingArray = specsList(specs, tests) |
| 143 | + const debugMappingArray = specsList({ specs, tests, localSpecs: [], currentTestingType: 'e2e', groups }) |
135 | 144 |
|
136 | 145 | expect(debugMappingArray).to.have.length(1)
|
137 |
| - expect(debugMappingArray).to.deep.equal([{ spec: { id: '123' }, tests: [{ specId: '123', id: 'random1' }] }]) |
| 146 | + expect(debugMappingArray).to.deep.equal([{ spec: { id: '123', groupIds: ['a'] }, tests: [{ specId: '123', id: 'random1' }], groups: [{ id: 'a', testingType: 'e2e' }], foundLocally: false, testingType: 'e2e', matchesCurrentTestingType: true }]) |
138 | 147 | })
|
139 | 148 |
|
140 | 149 | it('throws an error when a test does not map to a spec', () => {
|
141 |
| - const specs = createSpecs(['123']) |
| 150 | + const specs = [ |
| 151 | + { id: '123', groupIds: ['a'] }, |
| 152 | + ] as DebugSpecListSpecFragment[] |
142 | 153 | const tests = [
|
143 | 154 | { specId: '123', id: 'random1' },
|
144 | 155 | { specId: '456', id: 'random2' },
|
145 |
| - ] |
| 156 | + ] as DebugSpecListTestsFragment[] |
| 157 | + const groups = [{ id: 'a' }] as DebugSpecListGroupsFragment[] |
146 | 158 |
|
147 | 159 | const specsListWrapper = () => {
|
148 |
| - return specsList(specs, tests) |
| 160 | + return specsList({ specs, tests, groups, localSpecs: [], currentTestingType: 'e2e' }) |
149 | 161 | }
|
150 | 162 |
|
151 | 163 | expect(specsListWrapper).to.throw('Could not find spec for id 456')
|
|
0 commit comments