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

Automatic merge of gitlab-org/gitlab master

parents cfa0e2dc 526e99ae
- if any_projects?(@projects) - 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!" } %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') = 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] = 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 ...@@ -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 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 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 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 [personal API token](https://gitlab.com/-/profile/personal_access_tokens?name=GitLab+Dangerbot&scopes=api)
using that API token instead. Making the variable 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 [masked](../ci/variables/index.md#mask-a-cicd-variable) makes sure it
doesn't show up in the job logs. The variable cannot be doesn't show up in the job logs. The variable cannot be
[protected](../ci/variables/index.md#protect-a-cicd-variable), as it needs [protected](../ci/variables/index.md#protect-a-cicd-variable), as it needs
......
This diff is collapsed.
...@@ -891,14 +891,13 @@ describe GraphQL::Query, type: :request do ...@@ -891,14 +891,13 @@ describe GraphQL::Query, type: :request do
include GraphqlHelpers include GraphqlHelpers
all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql' all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql'
fragment_paths = ['releases/graphql/fragments/release.fragment.graphql']
before(:all) do before(:all) do
clean_frontend_fixtures('graphql/releases/') clean_frontend_fixtures('graphql/releases/')
end end
it "graphql/#{all_releases_query_path}.json" do 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 }) post_graphql(query, current_user: admin, variables: { fullPath: project.full_path })
...@@ -910,10 +909,6 @@ end ...@@ -910,10 +909,6 @@ end
This will create a new fixture located at This will create a new fixture located at
`tmp/tests/frontend/fixtures-ee/graphql/releases/graphql/queries/all_releases.query.graphql.json`. `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 You can import the JSON fixture in a Jest test using the `getJSONFixture` method
[as described below](#use-fixtures). [as described below](#use-fixtures).
......
...@@ -11,7 +11,6 @@ import { ...@@ -11,7 +11,6 @@ import {
import validation from '~/vue_shared/directives/validation'; import validation from '~/vue_shared/directives/validation';
import { import {
activateLabel, activateLabel,
fieldRequiredMessage,
INVALID_CODE_ERROR, INVALID_CODE_ERROR,
INVALID_CODE_ERROR_MESSAGE, INVALID_CODE_ERROR_MESSAGE,
subscriptionActivationForm, subscriptionActivationForm,
...@@ -37,7 +36,6 @@ export default { ...@@ -37,7 +36,6 @@ export default {
acceptTerms: subscriptionActivationForm.acceptTerms, acceptTerms: subscriptionActivationForm.acceptTerms,
activateLabel, activateLabel,
activationCode: subscriptionActivationForm.activationCode, activationCode: subscriptionActivationForm.activationCode,
fieldRequiredMessage,
pasteActivationCode: subscriptionActivationForm.pasteActivationCode, pasteActivationCode: subscriptionActivationForm.pasteActivationCode,
}, },
directives: { directives: {
...@@ -74,6 +72,10 @@ export default { ...@@ -74,6 +72,10 @@ export default {
}; };
}, },
computed: { 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() { isRequestingActivation() {
return this.isLoading; return this.isLoading;
}, },
...@@ -142,11 +144,7 @@ export default { ...@@ -142,11 +144,7 @@ export default {
/> />
</gl-form-group> </gl-form-group>
<gl-form-group <gl-form-group class="gl-mb-0" data-testid="form-group-terms">
class="gl-mb-0"
:invalid-feedback="$options.i18n.fieldRequiredMessage"
data-testid="form-group-terms"
>
<gl-form-checkbox <gl-form-checkbox
id="subscription-form-terms-check" id="subscription-form-terms-check"
v-model="form.fields.terms.value" v-model="form.fields.terms.value"
...@@ -155,7 +153,7 @@ export default { ...@@ -155,7 +153,7 @@ export default {
name="terms" name="terms"
required required
> >
<span class="gl-text-gray-900!"> <span :class="checkboxLabelClass">
<gl-sprintf :message="$options.i18n.acceptTerms"> <gl-sprintf :message="$options.i18n.acceptTerms">
<template #link="{ content }"> <template #link="{ content }">
<gl-link href="https://about.gitlab.com/terms/" target="_blank">{{ <gl-link href="https://about.gitlab.com/terms/" target="_blank">{{
......
...@@ -3,7 +3,6 @@ import activateSubscriptionMutation from './graphql/mutations/activate_subscript ...@@ -3,7 +3,6 @@ import activateSubscriptionMutation from './graphql/mutations/activate_subscript
import getCurrentLicense from './graphql/queries/get_current_license.query.graphql'; import getCurrentLicense from './graphql/queries/get_current_license.query.graphql';
import getLicenseHistory from './graphql/queries/get_license_history.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 subscriptionMainTitle = s__('SuperSonics|Your subscription');
export const subscriptionActivationNotificationText = s__( export const subscriptionActivationNotificationText = s__(
`SuperSonics|Your subscription was successfully activated. You can see the details below.`, `SuperSonics|Your subscription was successfully activated. You can see the details below.`,
......
...@@ -7,7 +7,6 @@ import SubscriptionActivationForm, { ...@@ -7,7 +7,6 @@ import SubscriptionActivationForm, {
} from 'ee/admin/subscriptions/show/components/subscription_activation_form.vue'; } from 'ee/admin/subscriptions/show/components/subscription_activation_form.vue';
import { import {
CONNECTIVITY_ERROR, CONNECTIVITY_ERROR,
fieldRequiredMessage,
INVALID_CODE_ERROR, INVALID_CODE_ERROR,
subscriptionQueries, subscriptionQueries,
} from 'ee/admin/subscriptions/show/constants'; } from 'ee/admin/subscriptions/show/constants';
...@@ -20,11 +19,11 @@ import { activateLicenseMutationResponse } from '../mock_data'; ...@@ -20,11 +19,11 @@ import { activateLicenseMutationResponse } from '../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(VueApollo); localVue.use(VueApollo);
describe('CloudLicenseApp', () => { describe('SubscriptionActivationForm', () => {
let wrapper; let wrapper;
const fakeActivationCode = 'gEg959hDCkvM2d4Der5RyktT '; const fakeActivationCodeTrimmed = 'aaasddfffdddas';
const fakeActivationCodeTrimmed = 'gEg959hDCkvM2d4Der5RyktT'; const fakeActivationCode = `${fakeActivationCodeTrimmed} `;
const createMockApolloProvider = (resolverMock) => { const createMockApolloProvider = (resolverMock) => {
localVue.use(VueApollo); localVue.use(VueApollo);
...@@ -34,7 +33,8 @@ describe('CloudLicenseApp', () => { ...@@ -34,7 +33,8 @@ describe('CloudLicenseApp', () => {
const findActivateButton = () => wrapper.findByTestId('activate-button'); const findActivateButton = () => wrapper.findByTestId('activate-button');
const findAgreementCheckbox = () => wrapper.findComponent(GlFormCheckbox); const findAgreementCheckbox = () => wrapper.findComponent(GlFormCheckbox);
const findAgreementCheckboxInput = () => findAgreementCheckbox().find('input'); 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 findActivationCodeFormGroup = () => wrapper.findByTestId('form-group-activation-code');
const findActivationCodeInput = () => wrapper.findComponent(GlFormInput); const findActivationCodeInput = () => wrapper.findComponent(GlFormInput);
const findActivateSubscriptionForm = () => wrapper.findComponent(GlForm); const findActivateSubscriptionForm = () => wrapper.findComponent(GlForm);
...@@ -67,7 +67,7 @@ describe('CloudLicenseApp', () => { ...@@ -67,7 +67,7 @@ describe('CloudLicenseApp', () => {
wrapper.destroy(); wrapper.destroy();
}); });
describe('Subscription Activation Form', () => { describe('component setup', () => {
beforeEach(() => createComponentWithApollo()); beforeEach(() => createComponentWithApollo());
it('presents a form', () => { it('presents a form', () => {
...@@ -78,6 +78,10 @@ describe('CloudLicenseApp', () => { ...@@ -78,6 +78,10 @@ describe('CloudLicenseApp', () => {
expect(findActivationCodeInput().exists()).toBe(true); 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', () => { it('has an `Activate` button', () => {
expect(findActivateButton().text()).toBe('Activate'); expect(findActivateButton().text()).toBe('Activate');
}); });
...@@ -91,26 +95,20 @@ describe('CloudLicenseApp', () => { ...@@ -91,26 +95,20 @@ describe('CloudLicenseApp', () => {
}); });
}); });
describe('form errors', () => { describe('form validation', () => {
const mutationMock = jest.fn(); const mutationMock = jest.fn();
beforeEach(() => { beforeEach(async () => {
createComponentWithApollo({ mutationMock }); createComponentWithApollo({ mutationMock, mountMethod: mount });
await findAgreementCheckbox().vm.$emit('input', false);
findActivateSubscriptionForm().vm.$emit('submit', createFakeEvent());
}); });
it('shows an error for the text field', async () => { it('shows an error for the text field', () => {
await findActivateSubscriptionForm().vm.$emit('submit', createFakeEvent()); expect(findActivationCodeFormGroup().text()).toContain('Please fill out this field.');
expect(findActivationCodeFormGroup().attributes('invalid-feedback')).toBe(
'Please fill out this field.',
);
}); });
it('shows an error for the checkbox field', async () => { it('applies the correct class', () => {
await findActivationCodeInput().vm.$emit('input', fakeActivationCode); expect(findAgreementCheckboxFormGroupSpan().attributes('class')).toBe('');
expect(findAgreementCheckboxFormGroup().attributes('invalid-feedback')).toBe(
fieldRequiredMessage,
);
}); });
it('does not perform any mutation', () => { it('does not perform any mutation', () => {
......
...@@ -31524,9 +31524,6 @@ msgstr "" ...@@ -31524,9 +31524,6 @@ msgstr ""
msgid "SuperSonics|There is a connectivity issue." msgid "SuperSonics|There is a connectivity issue."
msgstr "" msgstr ""
msgid "SuperSonics|This field is required."
msgstr ""
msgid "SuperSonics|This is the highest peak of users on your installation since the license started." msgid "SuperSonics|This is the highest peak of users on your installation since the license started."
msgstr "" msgstr ""
......
...@@ -61,13 +61,12 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do ...@@ -61,13 +61,12 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do
clean_frontend_fixtures('graphql/projects/access_tokens') clean_frontend_fixtures('graphql/projects/access_tokens')
end end
fragment_paths = ['graphql_shared/fragments/pageInfo.fragment.graphql']
base_input_path = 'access_tokens/graphql/queries/' base_input_path = 'access_tokens/graphql/queries/'
base_output_path = 'graphql/projects/access_tokens/' base_output_path = 'graphql/projects/access_tokens/'
query_name = 'get_projects.query.graphql' query_name = 'get_projects.query.graphql'
it "#{base_output_path}#{query_name}.json" do 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 }) post_graphql(query, current_user: user, variables: { search: '', first: 2 })
......
...@@ -133,15 +133,13 @@ RSpec.describe 'Releases (JavaScript fixtures)' do ...@@ -133,15 +133,13 @@ RSpec.describe 'Releases (JavaScript fixtures)' do
all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql' all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql'
one_release_query_path = 'releases/graphql/queries/one_release.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' 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 before(:all) do
clean_frontend_fixtures('graphql/releases/') clean_frontend_fixtures('graphql/releases/')
end end
it "graphql/#{all_releases_query_path}.json" do 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 }) post_graphql(query, current_user: admin, variables: { fullPath: project.full_path })
...@@ -150,7 +148,7 @@ RSpec.describe 'Releases (JavaScript fixtures)' do ...@@ -150,7 +148,7 @@ RSpec.describe 'Releases (JavaScript fixtures)' do
end end
it "graphql/#{one_release_query_path}.json" do 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 }) post_graphql(query, current_user: admin, variables: { fullPath: project.full_path, tagName: release.tag })
...@@ -159,7 +157,7 @@ RSpec.describe 'Releases (JavaScript fixtures)' do ...@@ -159,7 +157,7 @@ RSpec.describe 'Releases (JavaScript fixtures)' do
end end
it "graphql/#{one_release_for_editing_query_path}.json" do 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 }) post_graphql(query, current_user: admin, variables: { fullPath: project.full_path, tagName: release.tag })
......
...@@ -36,10 +36,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do ...@@ -36,10 +36,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do
get_runners_query_name = 'get_runners.query.graphql' get_runners_query_name = 'get_runners.query.graphql'
let_it_be(:query) do let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runners_query_name}", [ get_graphql_query_as_string("#{query_path}#{get_runners_query_name}")
'runner/graphql/runner_node.fragment.graphql',
'graphql_shared/fragments/pageInfo.fragment.graphql'
])
end end
it "#{fixtures_path}#{get_runners_query_name}.json" do it "#{fixtures_path}#{get_runners_query_name}.json" do
...@@ -59,9 +56,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do ...@@ -59,9 +56,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do
get_runner_query_name = 'get_runner.query.graphql' get_runner_query_name = 'get_runner.query.graphql'
let_it_be(:query) do let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runner_query_name}", [ get_graphql_query_as_string("#{query_path}#{get_runner_query_name}")
'runner/graphql/runner_details.fragment.graphql'
])
end end
it "#{fixtures_path}#{get_runner_query_name}.json" do it "#{fixtures_path}#{get_runner_query_name}.json" do
......
...@@ -43,12 +43,14 @@ module JavaScriptFixturesHelpers ...@@ -43,12 +43,14 @@ module JavaScriptFixturesHelpers
# Public: Reads a GraphQL query from the filesystem as a string # Public: Reads a GraphQL query from the filesystem as a string
# #
# query_path - file path to the GraphQL query, relative to `app/assets/javascripts` # 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, def get_graphql_query_as_string(query_path)
# also relative to `app/assets/javascripts` path = Rails.root / 'app/assets/javascripts' / query_path
def get_graphql_query_as_string(query_path, fragment_paths = []) queries = Gitlab::Graphql::Queries.find(path)
[query_path, *fragment_paths].map do |path| if queries.length == 1
File.read(File.join(Rails.root, '/app/assets/javascripts', path)) queries.first.text(mode: Gitlab.ee? ? :ee : :ce )
end.join("\n") else
raise "Could not find query file at #{path}, please check your query_path" % path
end
end end
private 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