diff options
Diffstat (limited to 'spec/frontend/editor')
4 files changed, 71 insertions, 20 deletions
diff --git a/spec/frontend/editor/schema/ci/ci_schema_spec.js b/spec/frontend/editor/schema/ci/ci_schema_spec.js index 77c7f0d49a8..0f380f13679 100644 --- a/spec/frontend/editor/schema/ci/ci_schema_spec.js +++ b/spec/frontend/editor/schema/ci/ci_schema_spec.js @@ -36,6 +36,7 @@ import HooksYaml from './yaml_tests/positive_tests/hooks.yml'; import SecretsYaml from './yaml_tests/positive_tests/secrets.yml'; import ServicesYaml from './yaml_tests/positive_tests/services.yml'; import NeedsParallelMatrixYaml from './yaml_tests/positive_tests/needs_parallel_matrix.yml'; +import ScriptYaml from './yaml_tests/positive_tests/script.yml'; // YAML NEGATIVE TEST import ArtifactsNegativeYaml from './yaml_tests/negative_tests/artifacts.yml'; @@ -60,6 +61,7 @@ import ServicesNegativeYaml from './yaml_tests/negative_tests/services.yml'; import NeedsParallelMatrixNumericYaml from './yaml_tests/negative_tests/needs/parallel_matrix/numeric.yml'; import NeedsParallelMatrixWrongParallelValueYaml from './yaml_tests/negative_tests/needs/parallel_matrix/wrong_parallel_value.yml'; import NeedsParallelMatrixWrongMatrixValueYaml from './yaml_tests/negative_tests/needs/parallel_matrix/wrong_matrix_value.yml'; +import ScriptNegativeYaml from './yaml_tests/negative_tests/script.yml'; const ajv = new Ajv({ strictTypes: false, @@ -101,6 +103,7 @@ describe('positive tests', () => { ServicesYaml, SecretsYaml, NeedsParallelMatrixYaml, + ScriptYaml, }), )('schema validates %s', (_, input) => { // We construct a new "JSON" from each main key that is inside a @@ -144,6 +147,7 @@ describe('negative tests', () => { NeedsParallelMatrixNumericYaml, NeedsParallelMatrixWrongParallelValueYaml, NeedsParallelMatrixWrongMatrixValueYaml, + ScriptNegativeYaml, }), )('schema validates %s', (_, input) => { // We construct a new "JSON" from each main key that is inside a diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/script.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/script.yml new file mode 100644 index 00000000000..f5bf3f54f6f --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/script.yml @@ -0,0 +1,14 @@ +script: echo "invalid global script" + +default: + before_script: 0.1 + after_script: 1 + +invalid_script_type: + script: true + +empty_array_script: + script: [] + +empty_string_script: + script: "" diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/script.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/script.yml new file mode 100644 index 00000000000..0ffb1f3e89e --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/script.yml @@ -0,0 +1,52 @@ +default: + before_script: + - echo "default before_script" + after_script: | + echo "default after_script" + +valid_job_with_empty_string_script: + before_script: "" + after_script: "" + script: + - echo "overwrite default before_script and after_script" + +valid_job_with_empty_array_script: + before_script: [] + after_script: [] + script: + - echo "overwrite default before_script and after_script" + +valid_job_with_string_scripts: + before_script: echo before_script + script: echo script + after_script: echo after_script + +valid_job_with_multi_line_scripts: + before_script: | + echo multiline + echo before_script + script: | + echo multiline + echo script + after_script: | + echo multiline + echo after_script + +valid_job_with_array_scripts: + before_script: + - echo array + - echo before_script + script: + - echo array + - echo script + after_script: + - echo array + - echo after_script + +valid_job_with_nested_array_scripts: + before_script: + - [echo nested_array, echo before_script] + script: + - [echo nested_array, echo script] + after_script: + - [echo nested_array, echo after_script] diff --git a/spec/frontend/editor/source_editor_spec.js b/spec/frontend/editor/source_editor_spec.js index 6a8e7b296aa..f66de61da1e 100644 --- a/spec/frontend/editor/source_editor_spec.js +++ b/spec/frontend/editor/source_editor_spec.js @@ -9,21 +9,6 @@ import SourceEditor from '~/editor/source_editor'; import { DEFAULT_THEME, themes } from '~/ide/lib/themes'; import { joinPaths } from '~/lib/utils/url_utility'; -jest.mock('~/helpers/startup_css_helper', () => { - return { - waitForCSSLoaded: jest.fn().mockImplementation((cb) => { - // We have to artificially put the callback's execution - // to the end of the current call stack to be able to - // test that the callback is called after waitForCSSLoaded. - // setTimeout with 0 delay does exactly that. - // Otherwise we might end up with false positive results - setTimeout(() => { - cb.apply(); - }, 0); - }), - }; -}); - describe('Base editor', () => { let editorEl; let editor; @@ -161,7 +146,7 @@ describe('Base editor', () => { expect(instance.getModel()).toBeNull(); }); - it('resets the layout in waitForCSSLoaded callback', async () => { + it('resets the layout in createInstance', () => { const layoutSpy = jest.fn(); jest.spyOn(monacoEditor, 'create').mockReturnValue({ layout: layoutSpy, @@ -170,10 +155,6 @@ describe('Base editor', () => { dispose: jest.fn(), }); editor.createInstance(defaultArguments); - expect(layoutSpy).not.toHaveBeenCalled(); - - // We're waiting for the waitForCSSLoaded mock to kick in - await jest.runOnlyPendingTimers(); expect(layoutSpy).toHaveBeenCalled(); }); |