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
......
This diff is collapsed.
......@@ -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