Skip to content
Snippets Groups Projects
Commit 15e69d09 authored by Dheeraj Joshi's avatar Dheeraj Joshi :one:
Browse files

Merge branch 'leipert-remove-startup-css-one' into 'master'

Stop compiling startup css in the asset pipeline

See merge request !135232



Merged-by: default avatarDheeraj Joshi <djoshi@gitlab.com>
Approved-by: default avatarMario Celi <mcelicalderon@gitlab.com>
Approved-by: default avatarLucas Charles <me@lucascharles.me>
Approved-by: default avatarThomas Randolph <trandolph@gitlab.com>
Approved-by: default avatarDheeraj Joshi <djoshi@gitlab.com>
Co-authored-by: Lukas Eipert's avatarLukas Eipert <leipert@gitlab.com>
parents a099b965 23d5a20e
No related branches found
No related tags found
1 merge request!135232Stop compiling startup css in the asset pipeline
Pipeline #1051523188 failed
Pipeline: E2E Omnibus GitLab EE

#1051640629

    Pipeline: GitLab

    #1051548697

      Pipeline: E2E GDK

      #1051530270

        +21
        ......@@ -1913,7 +1913,6 @@ RSpec/FeatureCategory:
        - 'spec/frontend/fixtures/search.rb'
        - 'spec/frontend/fixtures/sessions.rb'
        - 'spec/frontend/fixtures/snippet.rb'
        - 'spec/frontend/fixtures/startup_css.rb'
        - 'spec/frontend/fixtures/tabs.rb'
        - 'spec/frontend/fixtures/tags.rb'
        - 'spec/frontend/fixtures/timezones.rb'
        ......
        ......@@ -35,7 +35,6 @@ RSpec/RepeatedExampleGroupDescription:
        - 'spec/features/projects/new_project_spec.rb'
        - 'spec/features/security/project/private_access_spec.rb'
        - 'spec/finders/ci/pipelines_for_merge_request_finder_spec.rb'
        - 'spec/frontend/fixtures/startup_css.rb'
        - 'spec/helpers/admin/user_actions_helper_spec.rb'
        - 'spec/helpers/dropdowns_helper_spec.rb'
        - 'spec/helpers/gitlab_routing_helper_spec.rb'
        ......
        ......@@ -3,7 +3,6 @@ import './autosize';
        import initCollapseSidebarOnWindowResize from './collapse_sidebar_on_window_resize';
        import initCopyToClipboard from './copy_to_clipboard';
        import installGlEmojiElement from './gl_emoji';
        import { loadStartupCSS } from './load_startup_css';
        import initCopyAsGFM from './markdown/copy_as_gfm';
        import './quick_submit';
        import './requires_input';
        ......@@ -13,8 +12,6 @@ import { initGlobalAlerts } from './global_alerts';
        import './toggler_behavior';
        import './preview_markdown';
        loadStartupCSS();
        installGlEmojiElement();
        initCopyAsGFM();
        ......
        export const loadStartupCSS = () => {
        // We need to fallback to dispatching `load` in case our event listener was added too late
        // or the browser environment doesn't load media=print.
        // Do this on `window.load` so that the default deferred behavior takes precedence.
        // https://gitlab.com/gitlab-org/gitlab/-/issues/239357
        window.addEventListener(
        'load',
        () => {
        document
        .querySelectorAll('link[media=print]')
        .forEach((x) => x.dispatchEvent(new Event('load')));
        },
        { once: true },
        );
        };
        ......@@ -31,7 +31,3 @@
        @media print {
        @import 'print';
        }
        /* Rules for overriding cloaking in startup-general.scss */
        @import 'startup/cloaking';
        @include cloak-startup-scss(block);
        ......@@ -270,8 +270,6 @@ class Application < Rails::Application
        config.assets.precompile << "application_utilities_dark.css"
        config.assets.precompile << "application_dark.css"
        config.assets.precompile << "startup/*.css"
        config.assets.precompile << "print.css"
        config.assets.precompile << "mailer.css"
        config.assets.precompile << "mailer_client_specific.css"
        ......
        import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
        import { loadStartupCSS } from '~/behaviors/load_startup_css';
        describe('behaviors/load_startup_css', () => {
        let loadListener;
        const setupListeners = () => {
        document
        .querySelectorAll('link')
        .forEach((x) => x.addEventListener('load', () => loadListener(x)));
        };
        beforeEach(() => {
        loadListener = jest.fn();
        setHTMLFixture(`
        <meta charset="utf-8" />
        <link media="print" src="./lorem-print.css" />
        <link media="print" src="./ipsum-print.css" />
        <link media="all" src="./dolar-all.css" />
        `);
        setupListeners();
        loadStartupCSS();
        });
        afterEach(() => {
        resetHTMLFixture();
        });
        it('does nothing at first', () => {
        expect(loadListener).not.toHaveBeenCalled();
        });
        describe('on window load', () => {
        beforeEach(() => {
        window.dispatchEvent(new Event('load'));
        });
        it('dispatches load to the print links', () => {
        expect(loadListener.mock.calls.map(([el]) => el.getAttribute('src'))).toEqual([
        './lorem-print.css',
        './ipsum-print.css',
        ]);
        });
        });
        });
        # frozen_string_literal: true
        require 'spec_helper'
        RSpec.describe 'Startup CSS fixtures', type: :controller do
        include JavaScriptFixturesHelpers
        let(:use_full_html) { true }
        render_views
        shared_examples 'startup css project fixtures' do |type|
        let(:user) { create(:user, :admin) }
        let(:project) { create(:project, :public, :repository, description: 'Code and stuff', creator: user) }
        before do
        # We want vNext badge to be included and com/canary don't remove/hide any other elements.
        # This is why we're turning com and canary on by default for now.
        allow(Gitlab).to receive(:canary?).and_return(true)
        sign_in(user)
        end
        it "startup_css/project-#{type}.html" do
        get :show, params: {
        namespace_id: project.namespace.to_param,
        id: project
        }
        expect(response).to be_successful
        end
        it "startup_css/project-#{type}-signed-out.html" do
        sign_out(user)
        get :show, params: {
        namespace_id: project.namespace.to_param,
        id: project
        }
        expect(response).to be_successful
        end
        # This ensures that the correct css is generated for super sidebar
        it "startup_css/project-#{type}-super-sidebar.html" do
        user.update!(use_new_navigation: true)
        get :show, params: {
        namespace_id: project.namespace.to_param,
        id: project
        }
        expect(response).to be_successful
        end
        end
        describe ProjectsController, '(Startup CSS fixtures)', :saas, type: :controller do
        it_behaves_like 'startup css project fixtures', 'general'
        end
        describe ProjectsController, '(Startup CSS fixtures)', :saas, type: :controller do
        before do
        user.update!(theme_id: 11)
        end
        it_behaves_like 'startup css project fixtures', 'dark'
        end
        describe SessionsController, '(Startup CSS fixtures)', type: :controller do
        include DeviseHelpers
        before do
        set_devise_mapping(context: request)
        end
        it 'startup_css/sign-in.html' do
        get :new
        expect(response).to be_successful
        end
        it 'startup_css/sign-in-old.html' do
        stub_feature_flags(restyle_login_page: false)
        get :new
        expect(response).to be_successful
        end
        end
        end
        ......@@ -4311,7 +4311,6 @@
        - './spec/frontend/fixtures/search.rb'
        - './spec/frontend/fixtures/sessions.rb'
        - './spec/frontend/fixtures/snippet.rb'
        - './spec/frontend/fixtures/startup_css.rb'
        - './spec/frontend/fixtures/tabs.rb'
        - './spec/frontend/fixtures/tags.rb'
        - './spec/frontend/fixtures/timezones.rb'
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment