diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 18:11:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 18:11:09 +0000 |
commit | 026689ee8276defd4376f60312d77cbc82b152fc (patch) | |
tree | ba38fe216d45b04d4bb48efb3cbbd380a7a2a5b5 /spec | |
parent | 9c6578ed4e0bc92cd838ef96d978df54403e9609 (diff) | |
download | gitlab-ce-026689ee8276defd4376f60312d77cbc82b152fc.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/services/user_activates_issue_tracker_spec.rb | 2 | ||||
-rw-r--r-- | spec/frontend/fixtures/api_markdown.yml | 4 | ||||
-rw-r--r-- | spec/frontend/pipelines/__snapshots__/parsing_utils_spec.js.snap | 373 | ||||
-rw-r--r-- | spec/frontend/pipelines/parsing_utils_spec.js (renamed from spec/frontend/pipelines/components/dag/parsing_utils_spec.js) | 46 | ||||
-rw-r--r-- | spec/support/shared_examples/serializers/environment_serializer_shared_examples.rb | 20 |
5 files changed, 442 insertions, 3 deletions
diff --git a/spec/features/projects/services/user_activates_issue_tracker_spec.rb b/spec/features/projects/services/user_activates_issue_tracker_spec.rb index 1aec8883395..019d50a497b 100644 --- a/spec/features/projects/services/user_activates_issue_tracker_spec.rb +++ b/spec/features/projects/services/user_activates_issue_tracker_spec.rb @@ -87,6 +87,6 @@ RSpec.describe 'User activates issue tracker', :js do it_behaves_like 'external issue tracker activation', tracker: 'Redmine' it_behaves_like 'external issue tracker activation', tracker: 'YouTrack', skip_new_issue_url: true it_behaves_like 'external issue tracker activation', tracker: 'Bugzilla' - it_behaves_like 'external issue tracker activation', tracker: 'Custom Issue Tracker' + it_behaves_like 'external issue tracker activation', tracker: 'Custom issue tracker' it_behaves_like 'external issue tracker activation', tracker: 'EWM', skip_test: true end diff --git a/spec/frontend/fixtures/api_markdown.yml b/spec/frontend/fixtures/api_markdown.yml index a83d5374e2c..a1ea2806879 100644 --- a/spec/frontend/fixtures/api_markdown.yml +++ b/spec/frontend/fixtures/api_markdown.yml @@ -48,3 +48,7 @@ 3. list item 3 - name: image markdown: '![alt text](https://gitlab.com/logo.png)' +- name: hard_break + markdown: |- + This is a line after a\ + hard break diff --git a/spec/frontend/pipelines/__snapshots__/parsing_utils_spec.js.snap b/spec/frontend/pipelines/__snapshots__/parsing_utils_spec.js.snap new file mode 100644 index 00000000000..60625d301c0 --- /dev/null +++ b/spec/frontend/pipelines/__snapshots__/parsing_utils_spec.js.snap @@ -0,0 +1,373 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DAG visualization parsing utilities generateColumnsFromLayersList matches the snapshot 1`] = ` +Array [ + Object { + "groups": Array [ + Object { + "__typename": "CiGroup", + "jobs": Array [ + Object { + "__typename": "CiJob", + "name": "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", + "needs": Array [], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1482/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1482", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + ], + "name": "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", + "size": 1, + "stageName": "build", + "status": Object { + "__typename": "DetailedStatus", + "group": "success", + "icon": "status_success", + "label": "passed", + }, + }, + Object { + "__typename": "CiGroup", + "jobs": Array [ + Object { + "__typename": "CiJob", + "name": "build_b", + "needs": Array [], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1515/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1515", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + ], + "name": "build_b", + "size": 1, + "stageName": "build", + "status": Object { + "__typename": "DetailedStatus", + "group": "success", + "icon": "status_success", + "label": "passed", + }, + }, + Object { + "__typename": "CiGroup", + "jobs": Array [ + Object { + "__typename": "CiJob", + "name": "build_c", + "needs": Array [], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1484/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1484", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + ], + "name": "build_c", + "size": 1, + "stageName": "build", + "status": Object { + "__typename": "DetailedStatus", + "group": "success", + "icon": "status_success", + "label": "passed", + }, + }, + Object { + "__typename": "CiGroup", + "jobs": Array [ + Object { + "__typename": "CiJob", + "name": "build_d 1/3", + "needs": Array [], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1485/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1485", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + Object { + "__typename": "CiJob", + "name": "build_d 2/3", + "needs": Array [], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1486/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1486", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + Object { + "__typename": "CiJob", + "name": "build_d 3/3", + "needs": Array [], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1487/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1487", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + ], + "name": "build_d", + "size": 3, + "stageName": "build", + "status": Object { + "__typename": "DetailedStatus", + "group": "success", + "icon": "status_success", + "label": "passed", + }, + }, + Object { + "__typename": "CiGroup", + "jobs": Array [ + Object { + "__typename": "CiJob", + "name": "test_c", + "needs": Array [], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": null, + "detailsPath": "/root/kinder-pipe/-/pipelines/154", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": null, + }, + }, + ], + "name": "test_c", + "size": 1, + "stageName": "test", + "status": Object { + "__typename": "DetailedStatus", + "group": "success", + "icon": "status_success", + "label": null, + }, + }, + ], + "id": "layer-0", + "name": "", + "status": Object { + "action": null, + }, + }, + Object { + "groups": Array [ + Object { + "__typename": "CiGroup", + "jobs": Array [ + Object { + "__typename": "CiJob", + "name": "test_a", + "needs": Array [ + "build_c", + "build_b", + "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", + ], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1514/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1514", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + ], + "name": "test_a", + "size": 1, + "stageName": "test", + "status": Object { + "__typename": "DetailedStatus", + "group": "success", + "icon": "status_success", + "label": "passed", + }, + }, + Object { + "__typename": "CiGroup", + "jobs": Array [ + Object { + "__typename": "CiJob", + "name": "test_b 1/2", + "needs": Array [ + "build_d 3/3", + "build_d 2/3", + "build_d 1/3", + "build_b", + "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", + ], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1489/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1489", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + Object { + "__typename": "CiJob", + "name": "test_b 2/2", + "needs": Array [ + "build_d 3/3", + "build_d 2/3", + "build_d 1/3", + "build_b", + "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", + ], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": Object { + "__typename": "StatusAction", + "buttonTitle": "Retry this job", + "icon": "retry", + "path": "/root/abcd-dag/-/jobs/1490/retry", + "title": "Retry", + }, + "detailsPath": "/root/abcd-dag/-/jobs/1490", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": "passed", + }, + }, + ], + "name": "test_b", + "size": 2, + "stageName": "test", + "status": Object { + "__typename": "DetailedStatus", + "group": "success", + "icon": "status_success", + "label": "passed", + }, + }, + Object { + "__typename": "CiGroup", + "jobs": Array [ + Object { + "__typename": "CiJob", + "name": "test_d", + "needs": Array [ + "build_b", + ], + "scheduledAt": null, + "status": Object { + "__typename": "DetailedStatus", + "action": null, + "detailsPath": "/root/abcd-dag/-/pipelines/153", + "group": "success", + "hasDetails": true, + "icon": "status_success", + "tooltip": null, + }, + }, + ], + "name": "test_d", + "size": 1, + "stageName": "test", + "status": Object { + "__typename": "DetailedStatus", + "group": "success", + "icon": "status_success", + "label": null, + }, + }, + ], + "id": "layer-1", + "name": "", + "status": Object { + "action": null, + }, + }, +] +`; diff --git a/spec/frontend/pipelines/components/dag/parsing_utils_spec.js b/spec/frontend/pipelines/parsing_utils_spec.js index 84ff83883b7..96748ae9e5c 100644 --- a/spec/frontend/pipelines/components/dag/parsing_utils_spec.js +++ b/spec/frontend/pipelines/parsing_utils_spec.js @@ -3,12 +3,15 @@ import { createNodeDict, makeLinksFromNodes, filterByAncestors, + generateColumnsFromLayersListBare, + listByLayers, parseData, removeOrphanNodes, getMaxNodes, } from '~/pipelines/components/parsing_utils'; -import { mockParsedGraphQLNodes } from './mock_data'; +import { mockParsedGraphQLNodes } from './components/dag/mock_data'; +import { generateResponse, mockPipelineResponse } from './graph/mock_data'; describe('DAG visualization parsing utilities', () => { const nodeDict = createNodeDict(mockParsedGraphQLNodes); @@ -108,4 +111,45 @@ describe('DAG visualization parsing utilities', () => { expect(getMaxNodes(layerNodes)).toBe(3); }); }); + + describe('generateColumnsFromLayersList', () => { + const pipeline = generateResponse(mockPipelineResponse, 'root/fungi-xoxo'); + const layers = listByLayers(pipeline); + const columns = generateColumnsFromLayersListBare(pipeline, layers); + + it('returns stage-like objects with default name, id, and status', () => { + columns.forEach((col, idx) => { + expect(col).toMatchObject({ + name: '', + status: { action: null }, + id: `layer-${idx}`, + }); + }); + }); + + it('creates groups that match the list created in listByLayers', () => { + columns.forEach((col, idx) => { + const groupNames = col.groups.map(({ name }) => name); + expect(groupNames).toEqual(layers[idx]); + }); + }); + + it('looks up the correct group object', () => { + columns.forEach((col) => { + col.groups.forEach((group) => { + const groupStage = pipeline.stages.find((el) => el.name === group.stageName); + const groupObject = groupStage.groups.find((el) => el.name === group.name); + expect(group).toBe(groupObject); + }); + }); + }); + + /* + Just as a fallback in case multiple functions change, so tests pass + but the implementation moves away from case. + */ + it('matches the snapshot', () => { + expect(columns).toMatchSnapshot(); + }); + }); }); diff --git a/spec/support/shared_examples/serializers/environment_serializer_shared_examples.rb b/spec/support/shared_examples/serializers/environment_serializer_shared_examples.rb index 00146335ef7..9d7ae6bcb3d 100644 --- a/spec/support/shared_examples/serializers/environment_serializer_shared_examples.rb +++ b/spec/support/shared_examples/serializers/environment_serializer_shared_examples.rb @@ -20,9 +20,27 @@ RSpec.shared_examples 'avoid N+1 on environments serialization' do expect { serialize(grouping: false) }.not_to exceed_query_limit(control.count) end - def serialize(grouping:) + it 'does not preload for environments that does not exist in the page', :request_store do + create_environment_with_associations(project) + + first_page_query = ActiveRecord::QueryRecorder.new do + serialize(grouping: false, query: { page: 1, per_page: 1 } ) + end + + second_page_query = ActiveRecord::QueryRecorder.new do + serialize(grouping: false, query: { page: 2, per_page: 1 } ) + end + + expect(second_page_query.count).to be < first_page_query.count + end + + def serialize(grouping:, query: nil) + query ||= { page: 1, per_page: 1 } + request = double(url: "#{Gitlab.config.gitlab.url}:8080/api/v4/projects?#{query.to_query}", query_parameters: query) + EnvironmentSerializer.new(current_user: user, project: project).yield_self do |serializer| serializer.within_folders if grouping + serializer.with_pagination(request, spy('response')) serializer.represent(Environment.where(project: project)) end end |