Commit 65a21c63 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents cfa0e2dc 526e99ae
- if any_projects?(@projects)
.project-item-select-holder.btn-group.gl-ml-auto.gl-mr-auto.gl-py-3.gl-relative.gl-display-flex.gl-overflow-hidden
.project-item-select-holder.btn-group.gl-ml-auto.gl-mr-auto.gl-relative.gl-overflow-hidden{ class: 'gl-display-flex!' }
%a.btn.gl-button.btn-confirm.new-project-item-link.block-truncated.qa-new-project-item-link{ href: '', data: { label: local_assigns[:label], type: local_assigns[:type] }, class: "gl-m-0!" }
= loading_icon(color: 'light')
= project_select_tag :project_path, class: "project-item-select gl-absolute! gl-visibility-hidden", data: { include_groups: local_assigns[:include_groups], order_by: 'last_activity_at', relative_path: local_assigns[:path], with_shared: local_assigns[:with_shared], include_projects_in_subgroups: local_assigns[:include_projects_in_subgroups] }, with_feature_enabled: local_assigns[:with_feature_enabled]
......
......@@ -153,8 +153,9 @@ Danger is run but its output is not added to a merge request comment if working
on a fork. This happens because the secret variable from the canonical project
is not shared to forks. To work around this, you can add an [environment
variable](../ci/variables/index.md) called `DANGER_GITLAB_API_TOKEN` with a
personal API token to your fork. That way the danger comments are made from CI
using that API token instead. Making the variable
[personal API token](https://gitlab.com/-/profile/personal_access_tokens?name=GitLab+Dangerbot&scopes=api)
to your fork that has the `api` scope set. That way the danger comments are made
from CI using that API token instead. Making the variable
[masked](../ci/variables/index.md#mask-a-cicd-variable) makes sure it
doesn't show up in the job logs. The variable cannot be
[protected](../ci/variables/index.md#protect-a-cicd-variable), as it needs
......
......@@ -82,15 +82,15 @@ graph RL;
subgraph "No needed jobs";
1-1["danger-review (2.3 minutes)"];
click 1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8100542&udv=0"
1-2["build-qa-image (1.6 minutes)"];
1-2["build-qa-image (2 minutes)"];
click 1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914325&udv=0"
1-3["compile-test-assets (7 minutes)"];
1-3["compile-test-assets (6 minutes)"];
click 1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914317&udv=0"
1-4["compile-test-assets as-if-foss (7 minutes)"];
click 1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356616&udv=0"
1-5["compile-production-assets (19 minutes)"];
1-5["compile-production-assets (14 minutes)"];
click 1-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914312&udv=0"
1-6["setup-test-env (9 minutes)"];
1-6["setup-test-env (4 minutes)"];
click 1-6 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914315&udv=0"
1-7["review-stop-failed-deployment"];
1-8["dependency_scanning"];
......@@ -111,24 +111,24 @@ graph RL;
class 1-6 criticalPath;
end
2_1-1["graphql-verify (4 minutes)"];
2_1-1["graphql-verify (2.3 minutes)"];
click 2_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356715&udv=0"
2_1-2["memory-static (4.75 minutes)"];
click 2_1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356721&udv=0"
2_1-3["run-dev-fixtures (6 minutes)"];
2_1-3["run-dev-fixtures (3 minutes)"];
click 2_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356729&udv=0"
2_1-4["run-dev-fixtures-ee (6.75 minutes)"];
2_1-4["run-dev-fixtures-ee (4 minutes)"];
click 2_1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356731&udv=0"
subgraph "Needs `setup-test-env`";
2_1-1 & 2_1-2 & 2_1-3 & 2_1-4 --> 1-6;
end
2_2-2["rspec frontend_fixture/rspec-ee frontend_fixture (12 minutes)"];
2_2-2["rspec frontend_fixture/rspec-ee frontend_fixture (11 minutes)"];
class 2_2-2 criticalPath;
click 2_2-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910143&udv=0"
2_2-4["memory-on-boot (6 minutes)"];
2_2-4["memory-on-boot (3.5 minutes)"];
click 2_2-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356727&udv=0"
2_2-5["webpack-dev-server (4.5 minutes)"];
2_2-5["webpack-dev-server (4 minutes)"];
click 2_2-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8404303&udv=0"
subgraph "Needs `setup-test-env` & `compile-test-assets`";
2_2-2 & 2_2-4 & 2_2-5 --> 1-6 & 1-3;
......@@ -152,22 +152,22 @@ graph RL;
click 2_5-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations"
end
3_1-1["jest (15 minutes)"];
3_1-1["jest (16 minutes)"];
class 3_1-1 criticalPath;
click 3_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914204&udv=0"
3_1-2["karma (4 minutes)"];
3_1-2["karma (2 minutes)"];
click 3_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914200&udv=0"
subgraph "Needs `rspec frontend_fixture/rspec-ee frontend_fixture`";
3_1-1 & 3_1-2 --> 2_2-2;
end
3_2-1["rspec:coverage (4.6 minutes)"];
3_2-1["rspec:coverage (5.3 minutes)"];
subgraph "Depends on `rspec` jobs";
3_2-1 -.->|"(don't use needs because of limitations)"| 2_5-1;
click 3_2-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7248745&udv=0"
end
4_1-1["coverage-frontend (2.75 minutes)"];
4_1-1["coverage-frontend (2 minutes)"];
subgraph "Needs `jest`";
4_1-1 --> 3_1-1;
class 4_1-1 criticalPath;
......@@ -186,15 +186,15 @@ graph RL;
subgraph "No needed jobs";
1-1["danger-review (2.3 minutes)"];
click 1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8100542&udv=0"
1-2["build-qa-image (1.6 minutes)"];
1-2["build-qa-image (2 minutes)"];
click 1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914325&udv=0"
1-3["compile-test-assets (7 minutes)"];
1-3["compile-test-assets (6 minutes)"];
click 1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914317&udv=0"
1-4["compile-test-assets as-if-foss (7 minutes)"];
click 1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356616&udv=0"
1-5["compile-production-assets (19 minutes)"];
1-5["compile-production-assets (14 minutes)"];
click 1-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914312&udv=0"
1-6["setup-test-env (9 minutes)"];
1-6["setup-test-env (4 minutes)"];
click 1-6 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914315&udv=0"
1-7["review-stop-failed-deployment"];
1-8["dependency_scanning"];
......@@ -216,24 +216,24 @@ graph RL;
class 1-6 criticalPath;
end
2_1-1["graphql-verify (4 minutes)"];
2_1-1["graphql-verify (2.3 minutes)"];
click 2_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356715&udv=0"
2_1-2["memory-static (4.75 minutes)"];
click 2_1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356721&udv=0"
2_1-3["run-dev-fixtures (6 minutes)"];
2_1-3["run-dev-fixtures (3 minutes)"];
click 2_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356729&udv=0"
2_1-4["run-dev-fixtures-ee (6.75 minutes)"];
2_1-4["run-dev-fixtures-ee (4 minutes)"];
click 2_1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356731&udv=0"
subgraph "Needs `setup-test-env`";
2_1-1 & 2_1-2 & 2_1-3 & 2_1-4 --> 1-6;
end
2_2-2["rspec frontend_fixture/rspec-ee frontend_fixture (12 minutes)"];
2_2-2["rspec frontend_fixture/rspec-ee frontend_fixture (11 minutes)"];
class 2_2-2 criticalPath;
click 2_2-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910143&udv=0"
2_2-4["memory-on-boot (6 minutes)"];
2_2-4["memory-on-boot (3.5 minutes)"];
click 2_2-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356727&udv=0"
2_2-5["webpack-dev-server (4.5 minutes)"];
2_2-5["webpack-dev-server (4 minutes)"];
click 2_2-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8404303&udv=0"
subgraph "Needs `setup-test-env` & `compile-test-assets`";
2_2-2 & 2_2-4 & 2_2-5 --> 1-6 & 1-3;
......@@ -258,51 +258,48 @@ graph RL;
click 2_5-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations"
end
2_6-1["review-build-cng (27.3 minutes)"];
2_6-1["review-build-cng (27 minutes)"];
subgraph "Needs `build-assets-image`";
2_6-1 --> 2_3-1;
class 2_6-1 criticalPath;
click 2_6-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914314&udv=0"
end
3_1-1["jest (15 minutes)"];
3_1-1["jest (16 minutes)"];
class 3_1-1 criticalPath;
click 3_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914204&udv=0"
3_1-2["karma (4 minutes)"];
3_1-2["karma (2 minutes)"];
click 3_1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914200&udv=0"
subgraph "Needs `rspec frontend_fixture/rspec-ee frontend_fixture`";
3_1-1 & 3_1-2 --> 2_2-2;
end
3_2-1["rspec:coverage (4.6 minutes)"];
3_2-1["rspec:coverage (5.3 minutes)"];
subgraph "Depends on `rspec` jobs";
3_2-1 -.->|"(don't use needs because of limitations)"| 2_5-1;
click 3_2-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7248745&udv=0"
end
4_1-1["coverage-frontend (2.75 minutes)"];
4_1-1["coverage-frontend (2 minutes)"];
subgraph "Needs `jest`";
4_1-1 --> 3_1-1;
class 4_1-1 criticalPath;
click 4_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910777&udv=0"
end
3_3-1["review-deploy (6 minutes)"];
3_3-1["review-deploy (10.5 minutes)"];
subgraph "Played by `review-build-cng`";
3_3-1 --> 2_6-1;
class 3_3-1 criticalPath;
click 3_3-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6721130&udv=0"
end
4_2-1["review-qa-smoke (8 minutes)"];
4_2-1["review-qa-smoke (7.4 minutes)"];
click 4_2-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6729805&udv=0"
4_2-2["review-performance (4 minutes)"];
4_2-2["review-performance (2.5 minutes)"];
click 4_2-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356817&udv=0"
4_2-3["dast (18 minutes)"];
click 4_2-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356819&udv=0"
class 4_2-3 criticalPath;
subgraph "Played by `review-deploy`";
4_2-1 & 4_2-2 & 4_2-3 -.->|"(don't use needs because of limitations)"| 3_3-1;
4_2-1 & 4_2-2 --> 3_3-1;
end
```
......@@ -317,15 +314,15 @@ graph RL;
subgraph "No needed jobs";
1-1["danger-review (2.3 minutes)"];
click 1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8100542&udv=0"
1-2["build-qa-image (1.6 minutes)"];
1-2["build-qa-image (2 minutes)"];
click 1-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914325&udv=0"
1-3["compile-test-assets (7 minutes)"];
1-3["compile-test-assets (6 minutes)"];
click 1-3 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914317&udv=0"
1-4["compile-test-assets as-if-foss (7 minutes)"];
click 1-4 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356616&udv=0"
1-5["compile-production-assets (19 minutes)"];
1-5["compile-production-assets (14 minutes)"];
click 1-5 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914312&udv=0"
1-6["setup-test-env (9 minutes)"];
1-6["setup-test-env (4 minutes)"];
click 1-6 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914315&udv=0"
1-7["review-stop-failed-deployment"];
1-8["dependency_scanning"];
......@@ -345,7 +342,7 @@ graph RL;
class 1-5 criticalPath;
end
2_1-1["graphql-verify (4 minutes)"];
2_1-1["graphql-verify (2.3 minutes)"];
click 2_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=8356715&udv=0"
subgraph "Needs `setup-test-env`";
2_1-1 --> 1-6;
......@@ -357,7 +354,7 @@ graph RL;
class 2_3-1 criticalPath;
end
2_4-1["package-and-qa (105 minutes)"];
2_4-1["package-and-qa (140 minutes)"];
subgraph "Needs `build-qa-image` & `build-assets-image`";
2_4-1 --> 1-2 & 2_3-1;
class 2_4-1 criticalPath;
......
......@@ -891,14 +891,13 @@ describe GraphQL::Query, type: :request do
include GraphqlHelpers
all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql'
fragment_paths = ['releases/graphql/fragments/release.fragment.graphql']
before(:all) do
clean_frontend_fixtures('graphql/releases/')
end
it "graphql/#{all_releases_query_path}.json" do
query = get_graphql_query_as_string(all_releases_query_path, fragment_paths)
query = get_graphql_query_as_string(all_releases_query_path)
post_graphql(query, current_user: admin, variables: { fullPath: project.full_path })
......@@ -910,10 +909,6 @@ end
This will create a new fixture located at
`tmp/tests/frontend/fixtures-ee/graphql/releases/graphql/queries/all_releases.query.graphql.json`.
You will need to provide the paths to all fragments used by the query.
`get_graphql_query_as_string` reads all of the provided file paths and returns
the result as a single, concatenated string.
You can import the JSON fixture in a Jest test using the `getJSONFixture` method
[as described below](#use-fixtures).
......
......@@ -11,7 +11,6 @@ import {
import validation from '~/vue_shared/directives/validation';
import {
activateLabel,
fieldRequiredMessage,
INVALID_CODE_ERROR,
INVALID_CODE_ERROR_MESSAGE,
subscriptionActivationForm,
......@@ -37,7 +36,6 @@ export default {
acceptTerms: subscriptionActivationForm.acceptTerms,
activateLabel,
activationCode: subscriptionActivationForm.activationCode,
fieldRequiredMessage,
pasteActivationCode: subscriptionActivationForm.pasteActivationCode,
},
directives: {
......@@ -74,6 +72,10 @@ export default {
};
},
computed: {
checkboxLabelClass() {
// by default, if the value is not false the text will look green, therefore we force it to gray-900
return this.form.fields.terms.state === false ? '' : 'gl-text-gray-900!';
},
isRequestingActivation() {
return this.isLoading;
},
......@@ -142,11 +144,7 @@ export default {
/>
</gl-form-group>
<gl-form-group
class="gl-mb-0"
:invalid-feedback="$options.i18n.fieldRequiredMessage"
data-testid="form-group-terms"
>
<gl-form-group class="gl-mb-0" data-testid="form-group-terms">
<gl-form-checkbox
id="subscription-form-terms-check"
v-model="form.fields.terms.value"
......@@ -155,7 +153,7 @@ export default {
name="terms"
required
>
<span class="gl-text-gray-900!">
<span :class="checkboxLabelClass">
<gl-sprintf :message="$options.i18n.acceptTerms">
<template #link="{ content }">
<gl-link href="https://about.gitlab.com/terms/" target="_blank">{{
......
......@@ -3,7 +3,6 @@ import activateSubscriptionMutation from './graphql/mutations/activate_subscript
import getCurrentLicense from './graphql/queries/get_current_license.query.graphql';
import getLicenseHistory from './graphql/queries/get_license_history.query.graphql';
export const fieldRequiredMessage = s__('SuperSonics|This field is required.');
export const subscriptionMainTitle = s__('SuperSonics|Your subscription');
export const subscriptionActivationNotificationText = s__(
`SuperSonics|Your subscription was successfully activated. You can see the details below.`,
......
......@@ -7,7 +7,6 @@ import SubscriptionActivationForm, {
} from 'ee/admin/subscriptions/show/components/subscription_activation_form.vue';
import {
CONNECTIVITY_ERROR,
fieldRequiredMessage,
INVALID_CODE_ERROR,
subscriptionQueries,
} from 'ee/admin/subscriptions/show/constants';
......@@ -20,11 +19,11 @@ import { activateLicenseMutationResponse } from '../mock_data';
const localVue = createLocalVue();
localVue.use(VueApollo);
describe('CloudLicenseApp', () => {
describe('SubscriptionActivationForm', () => {
let wrapper;
const fakeActivationCode = 'gEg959hDCkvM2d4Der5RyktT ';
const fakeActivationCodeTrimmed = 'gEg959hDCkvM2d4Der5RyktT';
const fakeActivationCodeTrimmed = 'aaasddfffdddas';
const fakeActivationCode = `${fakeActivationCodeTrimmed} `;
const createMockApolloProvider = (resolverMock) => {
localVue.use(VueApollo);
......@@ -34,7 +33,8 @@ describe('CloudLicenseApp', () => {
const findActivateButton = () => wrapper.findByTestId('activate-button');
const findAgreementCheckbox = () => wrapper.findComponent(GlFormCheckbox);
const findAgreementCheckboxInput = () => findAgreementCheckbox().find('input');
const findAgreementCheckboxFormGroup = () => wrapper.findByTestId('form-group-terms');
const findAgreementCheckboxFormGroupSpan = () =>
wrapper.findByTestId('form-group-terms').find('span');
const findActivationCodeFormGroup = () => wrapper.findByTestId('form-group-activation-code');
const findActivationCodeInput = () => wrapper.findComponent(GlFormInput);
const findActivateSubscriptionForm = () => wrapper.findComponent(GlForm);
......@@ -67,7 +67,7 @@ describe('CloudLicenseApp', () => {
wrapper.destroy();
});
describe('Subscription Activation Form', () => {
describe('component setup', () => {
beforeEach(() => createComponentWithApollo());
it('presents a form', () => {
......@@ -78,6 +78,10 @@ describe('CloudLicenseApp', () => {
expect(findActivationCodeInput().exists()).toBe(true);
});
it('applies a class to the checkbox', () => {
expect(findAgreementCheckboxFormGroupSpan().attributes('class')).toBe('gl-text-gray-900!');
});
it('has an `Activate` button', () => {
expect(findActivateButton().text()).toBe('Activate');
});
......@@ -91,26 +95,20 @@ describe('CloudLicenseApp', () => {
});
});
describe('form errors', () => {
describe('form validation', () => {
const mutationMock = jest.fn();
beforeEach(() => {
createComponentWithApollo({ mutationMock });
beforeEach(async () => {
createComponentWithApollo({ mutationMock, mountMethod: mount });
await findAgreementCheckbox().vm.$emit('input', false);
findActivateSubscriptionForm().vm.$emit('submit', createFakeEvent());
});
it('shows an error for the text field', async () => {
await findActivateSubscriptionForm().vm.$emit('submit', createFakeEvent());
expect(findActivationCodeFormGroup().attributes('invalid-feedback')).toBe(
'Please fill out this field.',
);
it('shows an error for the text field', () => {
expect(findActivationCodeFormGroup().text()).toContain('Please fill out this field.');
});
it('shows an error for the checkbox field', async () => {
await findActivationCodeInput().vm.$emit('input', fakeActivationCode);
expect(findAgreementCheckboxFormGroup().attributes('invalid-feedback')).toBe(
fieldRequiredMessage,
);
it('applies the correct class', () => {
expect(findAgreementCheckboxFormGroupSpan().attributes('class')).toBe('');
});
it('does not perform any mutation', () => {
......
......@@ -31524,9 +31524,6 @@ msgstr ""
msgid "SuperSonics|There is a connectivity issue."
msgstr ""
msgid "SuperSonics|This field is required."
msgstr ""
msgid "SuperSonics|This is the highest peak of users on your installation since the license started."
msgstr ""
......
......@@ -61,13 +61,12 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do
clean_frontend_fixtures('graphql/projects/access_tokens')
end
fragment_paths = ['graphql_shared/fragments/pageInfo.fragment.graphql']
base_input_path = 'access_tokens/graphql/queries/'
base_output_path = 'graphql/projects/access_tokens/'
query_name = 'get_projects.query.graphql'
it "#{base_output_path}#{query_name}.json" do
query = get_graphql_query_as_string("#{base_input_path}#{query_name}", fragment_paths)
query = get_graphql_query_as_string("#{base_input_path}#{query_name}")
post_graphql(query, current_user: user, variables: { search: '', first: 2 })
......
......@@ -133,15 +133,13 @@ RSpec.describe 'Releases (JavaScript fixtures)' do
all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql'
one_release_query_path = 'releases/graphql/queries/one_release.query.graphql'
one_release_for_editing_query_path = 'releases/graphql/queries/one_release_for_editing.query.graphql'
release_fragment_path = 'releases/graphql/fragments/release.fragment.graphql'
release_for_editing_fragment_path = 'releases/graphql/fragments/release_for_editing.fragment.graphql'
before(:all) do
clean_frontend_fixtures('graphql/releases/')
end
it "graphql/#{all_releases_query_path}.json" do
query = get_graphql_query_as_string(all_releases_query_path, [release_fragment_path])
query = get_graphql_query_as_string(all_releases_query_path)
post_graphql(query, current_user: admin, variables: { fullPath: project.full_path })
......@@ -150,7 +148,7 @@ RSpec.describe 'Releases (JavaScript fixtures)' do
end
it "graphql/#{one_release_query_path}.json" do
query = get_graphql_query_as_string(one_release_query_path, [release_fragment_path])
query = get_graphql_query_as_string(one_release_query_path)
post_graphql(query, current_user: admin, variables: { fullPath: project.full_path, tagName: release.tag })
......@@ -159,7 +157,7 @@ RSpec.describe 'Releases (JavaScript fixtures)' do
end
it "graphql/#{one_release_for_editing_query_path}.json" do
query = get_graphql_query_as_string(one_release_for_editing_query_path, [release_for_editing_fragment_path])
query = get_graphql_query_as_string(one_release_for_editing_query_path)
post_graphql(query, current_user: admin, variables: { fullPath: project.full_path, tagName: release.tag })
......
......@@ -36,10 +36,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do
get_runners_query_name = 'get_runners.query.graphql'
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runners_query_name}", [
'runner/graphql/runner_node.fragment.graphql',
'graphql_shared/fragments/pageInfo.fragment.graphql'
])
get_graphql_query_as_string("#{query_path}#{get_runners_query_name}")
end
it "#{fixtures_path}#{get_runners_query_name}.json" do
......@@ -59,9 +56,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do
get_runner_query_name = 'get_runner.query.graphql'
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runner_query_name}", [
'runner/graphql/runner_details.fragment.graphql'
])
get_graphql_query_as_string("#{query_path}#{get_runner_query_name}")
end
it "#{fixtures_path}#{get_runner_query_name}.json" do
......
......@@ -43,12 +43,14 @@ module JavaScriptFixturesHelpers
# Public: Reads a GraphQL query from the filesystem as a string
#
# query_path - file path to the GraphQL query, relative to `app/assets/javascripts`
# fragment_paths - an optional array of file paths to any fragments the query uses,
# also relative to `app/assets/javascripts`
def get_graphql_query_as_string(query_path, fragment_paths = [])
[query_path, *fragment_paths].map do |path|
File.read(File.join(Rails.root, '/app/assets/javascripts', path))
end.join("\n")
def get_graphql_query_as_string(query_path)
path = Rails.root / 'app/assets/javascripts' / query_path
queries = Gitlab::Graphql::Queries.find(path)
if queries.length == 1
queries.first.text(mode: Gitlab.ee? ? :ee : :ce )
else
raise "Could not find query file at #{path}, please check your query_path" % path
end
end
private
......
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