diff options
Diffstat (limited to 'spec/frontend/editor')
12 files changed, 105 insertions, 38 deletions
diff --git a/spec/frontend/editor/schema/ci/ci_schema_spec.js b/spec/frontend/editor/schema/ci/ci_schema_spec.js index c59806a5d60..c9010fbec0c 100644 --- a/spec/frontend/editor/schema/ci/ci_schema_spec.js +++ b/spec/frontend/editor/schema/ci/ci_schema_spec.js @@ -2,7 +2,7 @@ import Ajv from 'ajv'; import AjvFormats from 'ajv-formats'; import CiSchema from '~/editor/schema/ci.json'; -// JSON POSITIVE TESTS +// JSON POSITIVE TESTS (LEGACY) import AllowFailureJson from './json_tests/positive_tests/allow_failure.json'; import EnvironmentJson from './json_tests/positive_tests/environment.json'; import GitlabCiDependenciesJson from './json_tests/positive_tests/gitlab-ci-dependencies.json'; @@ -14,7 +14,7 @@ import TerraformReportJson from './json_tests/positive_tests/terraform_report.js import VariablesMixStringAndUserInputJson from './json_tests/positive_tests/variables_mix_string_and_user_input.json'; import VariablesJson from './json_tests/positive_tests/variables.json'; -// JSON NEGATIVE TESTS +// JSON NEGATIVE TESTS (LEGACY) import DefaultNoAdditionalPropertiesJson from './json_tests/negative_tests/default_no_additional_properties.json'; import InheritDefaultNoAdditionalPropertiesJson from './json_tests/negative_tests/inherit_default_no_additional_properties.json'; import JobVariablesMustNotContainObjectsJson from './json_tests/negative_tests/job_variables_must_not_contain_objects.json'; @@ -24,14 +24,17 @@ import ReleaseAssetsLinksMissingJson from './json_tests/negative_tests/release_a import RetryUnknownWhenJson from './json_tests/negative_tests/retry_unknown_when.json'; // YAML POSITIVE TEST +import ArtifactsYaml from './yaml_tests/positive_tests/artifacts.yml'; import CacheYaml from './yaml_tests/positive_tests/cache.yml'; import FilterYaml from './yaml_tests/positive_tests/filter.yml'; import IncludeYaml from './yaml_tests/positive_tests/include.yml'; import RulesYaml from './yaml_tests/positive_tests/rules.yml'; // YAML NEGATIVE TEST +import ArtifactsNegativeYaml from './yaml_tests/negative_tests/artifacts.yml'; import CacheNegativeYaml from './yaml_tests/negative_tests/cache.yml'; import IncludeNegativeYaml from './yaml_tests/negative_tests/include.yml'; +import RulesNegativeYaml from './yaml_tests/negative_tests/rules.yml'; const ajv = new Ajv({ strictTypes: false, @@ -59,6 +62,7 @@ describe('positive tests', () => { VariablesJson, // YAML + ArtifactsYaml, CacheYaml, FilterYaml, IncludeYaml, @@ -82,8 +86,10 @@ describe('negative tests', () => { RetryUnknownWhenJson, // YAML + ArtifactsNegativeYaml, CacheNegativeYaml, IncludeNegativeYaml, + RulesNegativeYaml, }), )('schema validates %s', (_, input) => { expect(input).not.toValidateJsonSchema(schema); diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/artifacts.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/artifacts.yml new file mode 100644 index 00000000000..f5670376efc --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/artifacts.yml @@ -0,0 +1,18 @@ +# invalid artifact:reports:cyclonedx + +cyclonedx no paths: + artifacts: + reports: + cyclonedx: + +cyclonedx not a report: + artifacts: + cyclonedx: foo + +cyclonedx not an array or string: + artifacts: + reports: + cyclonedx: + paths: + - foo + - bar diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml index ee533f54d3b..04020c06753 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml @@ -1,15 +1,13 @@ -# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70779 stages: - prepare -# invalid cache:when value -job1: +# invalid cache:when values +when no integer: stage: prepare cache: when: 0 -# invalid cache:when value -job2: +when must be a reserved word: stage: prepare cache: when: 'never' diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/include.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/include.yml index 287150a765f..1e16bb55405 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/include.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/include.yml @@ -1,16 +1,14 @@ -# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70779 stages: - prepare -# missing file property -childPipeline: +# invalid trigger:include +trigger missing file property: stage: prepare trigger: include: - project: 'my-group/my-pipeline-library' -# missing project property -childPipeline2: +trigger missing project property: stage: prepare trigger: include: diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/rules.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/rules.yml new file mode 100644 index 00000000000..d74a681b23b --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/rules.yml @@ -0,0 +1,14 @@ +# invalid rules:changes +unnecessary ref declaration: + script: exit 0 + rules: + - changes: + paths: + - README.md + compare_to: { ref: 'main' } + +wrong path declaration: + script: exit 0 + rules: + - changes: + paths: { file: 'DOCKER' } diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/artifacts.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/artifacts.yml new file mode 100644 index 00000000000..20c1fc2c50f --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/artifacts.yml @@ -0,0 +1,25 @@ +# valid artifact:reports:cyclonedx + +cyclonedx string path: + artifacts: + reports: + cyclonedx: foo + +cyclonedx glob path: + artifacts: + reports: + cyclonedx: "*.foo" + +cylonedx list of string paths: + artifacts: + reports: + cyclonedx: + - foo + - ./bar/baz + +cylonedx mixed list of string paths and globs: + artifacts: + reports: + cyclonedx: + - ./foo + - "bar/*.baz" diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml index 436c7d72699..d83e14fdc6a 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml @@ -1,8 +1,7 @@ -# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70779 stages: - prepare -# test for cache:when values +# valid cache:when values job1: stage: prepare script: diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/filter.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/filter.yml index 2b29c24fa3c..f82ea71dcf3 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/filter.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/filter.yml @@ -1,5 +1,5 @@ -# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79335 -deploy-template: +# valid only/except values +only and except as array of strings: script: - echo "hello world" only: @@ -7,12 +7,10 @@ deploy-template: except: - bar -# null value allowed -deploy-without-only: +only as null value: extends: deploy-template only: -# null value allowed -deploy-without-except: +except as null value: extends: deploy-template except: diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/include.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/include.yml index 3497be28058..c00ab0d464a 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/include.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/include.yml @@ -1,17 +1,15 @@ -# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70779 +stages: + - prepare -# test for include:rules +# valid include:rules include: - local: builds.yml rules: - if: '$INCLUDE_BUILDS == "true"' when: always -stages: - - prepare - -# test for trigger:include -childPipeline: +# valid trigger:include +trigger:include accepts project and file properties: stage: prepare script: - echo 'creating pipeline...' @@ -20,8 +18,7 @@ childPipeline: - project: 'my-group/my-pipeline-library' file: '.gitlab-ci.yml' -# accepts optional ref property -childPipeline2: +trigger:include accepts optional ref property: stage: prepare script: - echo 'creating pipeline...' diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/rules.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/rules.yml index 27a199cff13..37cae6b4264 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/rules.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/rules.yml @@ -1,13 +1,28 @@ -# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74164 +# valid workflow:rules:changes +rules:changes with paths and compare_to properties: + script: exit 0 + rules: + - changes: + paths: + - README.md + compare_to: main + +rules:changes as array of strings: + script: exit 0 + rules: + - changes: + - README.md -# test for workflow:rules:changes and workflow:rules:exists +# valid workflow:rules:exists +# valid rules:changes:path workflow: rules: + - changes: + paths: + - README.md - if: '$CI_PIPELINE_SOURCE == "schedule"' exists: - Dockerfile - changes: - - Dockerfile variables: IS_A_FEATURE: 'true' when: always diff --git a/spec/frontend/editor/source_editor_instance_spec.js b/spec/frontend/editor/source_editor_instance_spec.js index 99c4ff4f3fa..1223fee320e 100644 --- a/spec/frontend/editor/source_editor_instance_spec.js +++ b/spec/frontend/editor/source_editor_instance_spec.js @@ -423,7 +423,7 @@ describe('Source Editor Instance', () => { 'changes language of an attached model to "$expectedLanguage" when filepath is "$path"', ({ path, expectedLanguage }) => { seInstance.updateModelLanguage(path); - expect(instanceModel.getLanguageIdentifier().language).toBe(expectedLanguage); + expect(instanceModel.getLanguageId()).toBe(expectedLanguage); }, ); }); diff --git a/spec/frontend/editor/source_editor_spec.js b/spec/frontend/editor/source_editor_spec.js index 74aae7b899b..6a8e7b296aa 100644 --- a/spec/frontend/editor/source_editor_spec.js +++ b/spec/frontend/editor/source_editor_spec.js @@ -267,7 +267,6 @@ describe('Base editor', () => { let editorEl2; let inst1; let inst2; - const readOnlyIndex = '78'; // readOnly option has the internal index of 78 in the editor's options beforeEach(() => { setHTMLFixture('<div id="editor1"></div><div id="editor2"></div>'); @@ -331,10 +330,10 @@ describe('Base editor', () => { }); inst1 = editor.createInstance(inst1Args); - expect(inst1.getOption(readOnlyIndex)).toBe(true); + expect(inst1.getRawOptions().readOnly).toBe(true); inst2 = editor.createInstance(inst2Args); - expect(inst2.getOption(readOnlyIndex)).toBe(true); + expect(inst2.getRawOptions().readOnly).toBe(true); }); it('allows overriding editor options on the instance level', () => { @@ -346,7 +345,7 @@ describe('Base editor', () => { readOnly: false, }); - expect(inst1.getOption(readOnlyIndex)).toBe(false); + expect(inst1.getRawOptions().readOnly).toBe(false); }); it('disposes instances and relevant models independently from each other', () => { |