summaryrefslogtreecommitdiff
path: root/spec/frontend/static_site_editor
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/static_site_editor')
-rw-r--r--spec/frontend/static_site_editor/mock_data.js6
-rw-r--r--spec/frontend/static_site_editor/pages/home_spec.js1
-rw-r--r--spec/frontend/static_site_editor/services/generate_branch_name_spec.js8
-rw-r--r--spec/frontend/static_site_editor/services/renderers/render_image_spec.js10
-rw-r--r--spec/frontend/static_site_editor/services/submit_content_changes_spec.js23
5 files changed, 25 insertions, 23 deletions
diff --git a/spec/frontend/static_site_editor/mock_data.js b/spec/frontend/static_site_editor/mock_data.js
index 8bc65c6ce31..8d64e1799b8 100644
--- a/spec/frontend/static_site_editor/mock_data.js
+++ b/spec/frontend/static_site_editor/mock_data.js
@@ -55,7 +55,7 @@ export const mergeRequestTemplates = [
export const submitChangesError = 'Could not save changes';
export const commitBranchResponse = {
- web_url: '/tree/root-master-patch-88195',
+ web_url: '/tree/root-main-patch-88195',
};
export const commitMultipleResponse = {
short_id: 'ed899a2f4b5',
@@ -84,8 +84,8 @@ export const mounts = [
},
];
-export const branch = 'master';
+export const branch = 'main';
-export const baseUrl = '/user1/project1/-/sse/master%2Ftest.md';
+export const baseUrl = '/user1/project1/-/sse/main%2Ftest.md';
export const imageRoot = 'source/images/';
diff --git a/spec/frontend/static_site_editor/pages/home_spec.js b/spec/frontend/static_site_editor/pages/home_spec.js
index 0936ba3011c..eb056469603 100644
--- a/spec/frontend/static_site_editor/pages/home_spec.js
+++ b/spec/frontend/static_site_editor/pages/home_spec.js
@@ -275,6 +275,7 @@ describe('static_site_editor/pages/home', () => {
formattedMarkdown,
project,
sourcePath,
+ targetBranch: branch,
username,
images,
mergeRequestMeta,
diff --git a/spec/frontend/static_site_editor/services/generate_branch_name_spec.js b/spec/frontend/static_site_editor/services/generate_branch_name_spec.js
index 0624fc3b7b4..7e437506a16 100644
--- a/spec/frontend/static_site_editor/services/generate_branch_name_spec.js
+++ b/spec/frontend/static_site_editor/services/generate_branch_name_spec.js
@@ -1,7 +1,7 @@
-import { DEFAULT_TARGET_BRANCH, BRANCH_SUFFIX_COUNT } from '~/static_site_editor/constants';
+import { BRANCH_SUFFIX_COUNT } from '~/static_site_editor/constants';
import generateBranchName from '~/static_site_editor/services/generate_branch_name';
-import { username } from '../mock_data';
+import { username, branch as targetBranch } from '../mock_data';
describe('generateBranchName', () => {
const timestamp = 12345678901234;
@@ -11,11 +11,11 @@ describe('generateBranchName', () => {
});
it('generates a name that includes the username and target branch', () => {
- expect(generateBranchName(username)).toMatch(`${username}-${DEFAULT_TARGET_BRANCH}`);
+ expect(generateBranchName(username, targetBranch)).toMatch(`${username}-${targetBranch}`);
});
it(`adds the first ${BRANCH_SUFFIX_COUNT} numbers of the current timestamp`, () => {
- expect(generateBranchName(username)).toMatch(
+ expect(generateBranchName(username, targetBranch)).toMatch(
timestamp.toString().substring(BRANCH_SUFFIX_COUNT),
);
});
diff --git a/spec/frontend/static_site_editor/services/renderers/render_image_spec.js b/spec/frontend/static_site_editor/services/renderers/render_image_spec.js
index e9e40835982..d3298aa0b26 100644
--- a/spec/frontend/static_site_editor/services/renderers/render_image_spec.js
+++ b/spec/frontend/static_site_editor/services/renderers/render_image_spec.js
@@ -47,11 +47,11 @@ describe('rich_content_editor/renderers/render_image', () => {
it.each`
destination | isAbsolute | src
${'http://test.host/absolute/path/to/image.png'} | ${true} | ${'http://test.host/absolute/path/to/image.png'}
- ${'/relative/path/to/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/default/source/relative/path/to/image.png'}
- ${'/target/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/source/with/target/image.png'}
- ${'relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/relative/to/current/image.png'}
- ${'./relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/./relative/to/current/image.png'}
- ${'../relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/../relative/to/current/image.png'}
+ ${'/relative/path/to/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/main/default/source/relative/path/to/image.png'}
+ ${'/target/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/main/source/with/target/image.png'}
+ ${'relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/main/relative/to/current/image.png'}
+ ${'./relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/main/./relative/to/current/image.png'}
+ ${'../relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/main/../relative/to/current/image.png'}
`('returns an image with the correct attributes', ({ destination, isAbsolute, src }) => {
node.destination = destination;
diff --git a/spec/frontend/static_site_editor/services/submit_content_changes_spec.js b/spec/frontend/static_site_editor/services/submit_content_changes_spec.js
index d4cbc5d235e..d9bceb76a37 100644
--- a/spec/frontend/static_site_editor/services/submit_content_changes_spec.js
+++ b/spec/frontend/static_site_editor/services/submit_content_changes_spec.js
@@ -3,7 +3,6 @@ import Api from '~/api';
import { convertObjectPropsToSnakeCase } from '~/lib/utils/common_utils';
import {
- DEFAULT_TARGET_BRANCH,
SUBMIT_CHANGES_BRANCH_ERROR,
SUBMIT_CHANGES_COMMIT_ERROR,
SUBMIT_CHANGES_MERGE_REQUEST_ERROR,
@@ -25,6 +24,7 @@ import {
createMergeRequestResponse,
mergeRequestMeta,
sourcePath,
+ branch as targetBranch,
sourceContentYAML as content,
trackingCategory,
images,
@@ -33,7 +33,7 @@ import {
jest.mock('~/static_site_editor/services/generate_branch_name');
describe('submitContentChanges', () => {
- const branch = 'branch-name';
+ const sourceBranch = 'branch-name';
let trackingSpy;
let origPage;
@@ -41,6 +41,7 @@ describe('submitContentChanges', () => {
username,
projectId,
sourcePath,
+ targetBranch,
content,
images,
mergeRequestMeta,
@@ -54,7 +55,7 @@ describe('submitContentChanges', () => {
.spyOn(Api, 'createProjectMergeRequest')
.mockResolvedValue({ data: createMergeRequestResponse });
- generateBranchName.mockReturnValue(branch);
+ generateBranchName.mockReturnValue(sourceBranch);
origPage = document.body.dataset.page;
document.body.dataset.page = trackingCategory;
@@ -69,8 +70,8 @@ describe('submitContentChanges', () => {
it('creates a branch named after the username and target branch', () => {
return submitContentChanges(buildPayload()).then(() => {
expect(Api.createBranch).toHaveBeenCalledWith(projectId, {
- ref: DEFAULT_TARGET_BRANCH,
- branch,
+ ref: targetBranch,
+ branch: sourceBranch,
});
});
});
@@ -86,7 +87,7 @@ describe('submitContentChanges', () => {
describe('committing markdown formatting changes', () => {
const formattedMarkdown = `formatted ${content}`;
const commitPayload = {
- branch,
+ branch: sourceBranch,
commit_message: `${DEFAULT_FORMATTING_CHANGES_COMMIT_MESSAGE}\n\n${DEFAULT_FORMATTING_CHANGES_COMMIT_DESCRIPTION}`,
actions: [
{
@@ -116,7 +117,7 @@ describe('submitContentChanges', () => {
it('commits the content changes to the branch when creating branch succeeds', () => {
return submitContentChanges(buildPayload()).then(() => {
expect(Api.commitMultiple).toHaveBeenCalledWith(projectId, {
- branch,
+ branch: sourceBranch,
commit_message: mergeRequestMeta.title,
actions: [
{
@@ -140,7 +141,7 @@ describe('submitContentChanges', () => {
const payload = buildPayload({ content: contentWithoutImages });
return submitContentChanges(payload).then(() => {
expect(Api.commitMultiple).toHaveBeenCalledWith(projectId, {
- branch,
+ branch: sourceBranch,
commit_message: mergeRequestMeta.title,
actions: [
{
@@ -169,8 +170,8 @@ describe('submitContentChanges', () => {
convertObjectPropsToSnakeCase({
title,
description,
- targetBranch: DEFAULT_TARGET_BRANCH,
- sourceBranch: branch,
+ targetBranch,
+ sourceBranch,
}),
);
});
@@ -194,7 +195,7 @@ describe('submitContentChanges', () => {
});
it('returns the branch name', () => {
- expect(result).toMatchObject({ branch: { label: branch } });
+ expect(result).toMatchObject({ branch: { label: sourceBranch } });
});
it('returns commit short id and web url', () => {