Skip to content

Commit 5734891

Browse files
andrewleithCopilot
andauthored
Separate react code into reusable bundle (#2686)
* feat: optimize React bundle by adding vendor chunking and including react.vendor.min.js * feat: update script inclusion for scheduler and add vendor script for React Co-authored-by: Copilot <copilot@github.com> * chore: regen js * chore: fix flaky unrelated test 😬 * fix failing link test * Fix broken tests Co-authored-by: Copilot <copilot@github.com> * chore: formatting --------- Co-authored-by: Copilot <copilot@github.com>
1 parent 8bd3f11 commit 5734891

11 files changed

Lines changed: 37 additions & 14 deletions

File tree

app/assets/javascripts/react.vendor.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/javascripts/scheduler.min.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/javascripts/tiptap.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/templates/main_template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
{% include 'partials/google-analytics.html' %}
199199

200200
{% block page_script %}
201+
<script nonce="{{ request_nonce }}" type="text/javascript" src="{{ asset_url('javascripts/react.vendor.min.js') }}"></script>
201202
<script nonce="{{ request_nonce }}" type="text/javascript" src="{{ asset_url('javascripts/index.min.js') }}"></script>
202203
<script nonce="{{ request_nonce }}" type="text/javascript" src="{{ asset_url('javascripts/all.min.js') }}"></script>
203204

app/templates/views/check/ok.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ <h2 class="heading-medium">{{ _('Preview of one message out of {}').format(count
130130
</form>
131131
</div>
132132

133-
<script nonce="{{ request_nonce }}" type="text/javascript" src="{{ asset_url('javascripts/scheduler.min.js') }}"></script>
133+
{% endblock %}
134134

135+
{% block page_script %}
136+
{{ super() }}
137+
<script nonce="{{ request_nonce }}" type="text/javascript" src="{{ asset_url('javascripts/scheduler.min.js') }}"></script>
135138
{% endblock %}

app/templates/views/storybook.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ <h1 class="text-lg font-bold mb-4">Components</h1>
2727
</div>
2828

2929
{% endblock %}
30+
31+
{% block page_script %}
32+
{{ super() }}
33+
34+
{% if component == 'scheduler' %}
35+
<script nonce="{{ request_nonce }}" type="text/javascript" src="{{ asset_url('javascripts/scheduler.min.js') }}"></script>
36+
{% endif %}
37+
{% endblock %}

app/templates/views/storybook/scheduler.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@
1717
</button>
1818
</form>
1919
</div>
20-
<script nonce="{{ request_nonce }}" type="text/javascript" src="{{ asset_url('javascripts/scheduler.min.js') }}"></script>
2120

2221
{% endblock %}

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const javascripts = () => {
9494
.pipe(plugins.concat("all.min.js"))
9595
.pipe(
9696
plugins.addSrc.prepend([
97+
paths.src + "javascripts/react.vendor.min.js",
9798
paths.src + "javascripts/index.min.js",
9899
paths.src + "javascripts/scheduler.min.js",
99100
paths.src + "javascripts/tiptap.min.js",

tests_cypress/cypress/e2e/admin/components/rte/Links.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ describe("Link tests", () => {
496496
cy.scrollTo("top");
497497
RichTextEditor.Components.Editor()
498498
.find('a[href="https://example.com"]')
499-
.click();
499+
.realClick();
500500

501501
// Open the link modal again (cursor is now inside the existing link)
502502
RichTextEditor.Components.LinkButton().click();

tests_cypress/cypress/e2e/admin/components/rte/LiveRegion.cy.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ describe("Live region announces context as user navigates the editor", () => {
101101
});
102102

103103
it("announces Blockquote when arrowing into a blockquote", () => {
104-
RichTextEditor.Components.Editor().find("blockquote").prev().click();
104+
RichTextEditor.Components.Editor().find("ol li").last().click();
105+
cy.realPress("End");
105106
cy.realPress("ArrowDown");
106107
RichTextEditor.Components.EditorAnnouncer().should(
107108
"contain.text",
@@ -174,13 +175,9 @@ describe("Live region announces context as user navigates the editor", () => {
174175
});
175176

176177
// TODO: put this back in when we fix #3111
177-
it.skip("announces Link when cursor is in a link", () => {
178-
RichTextEditor.Components.Editor()
179-
.find("a")
180-
.first()
181-
.closest("p")
182-
.click("left");
183-
cy.realPress("End");
178+
it("announces Link when cursor is in a link", () => {
179+
RichTextEditor.Components.Editor().find("a").first().click();
180+
RichTextEditor.Components.Editor().realPress("ArrowLeft");
184181
RichTextEditor.Components.EditorAnnouncer().should("contain.text", "Link");
185182
});
186183

0 commit comments

Comments
 (0)