Skip to content

Commit 221140d

Browse files
authored
Flake: make import a synchronous submit (#1563)
We're seeing some build flake when the JS hasn't attached by the time that we attach the file, so the auto-submit doesn't work. In this case, I think making it a standard form element works just as well, and maybe a bit more intuitively.
1 parent 08cab8a commit 221140d

7 files changed

Lines changed: 9 additions & 51 deletions

File tree

.rubocop_todo.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ RSpec/DescribeClass:
116116
Exclude:
117117
- 'spec/integration/feed_importing_spec.rb'
118118

119-
# Offense count: 68
119+
# Offense count: 70
120120
# Configuration parameters: Max, CountAsOne.
121121
RSpec/ExampleLength:
122122
Exclude:
@@ -138,6 +138,7 @@ RSpec/ExampleLength:
138138
- 'spec/system/feed_show_spec.rb'
139139
- 'spec/system/feeds_index_spec.rb'
140140
- 'spec/system/good_job_spec.rb'
141+
- 'spec/system/import_spec.rb'
141142
- 'spec/system/keyboard_shortcuts_spec.rb'
142143
- 'spec/system/starred_spec.rb'
143144
- 'spec/system/stories_index_spec.rb'

app/javascript/controllers/auto_submit_controller.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/javascript/controllers/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
import {application} from "./application";
88

9-
import AutoSubmitController from "./auto_submit_controller";
10-
application.register("auto-submit", AutoSubmitController);
11-
129
import DialogController from "./dialog_controller";
1310
application.register("dialog", DialogController);
1411

app/views/imports/new.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
</p>
1515
<hr />
1616

17-
<%= form_with(url: "/feeds/import", id: "import", multipart: true, data: { controller: "auto-submit" }) do %>
18-
<input id="opml_file" name="opml_file" type="file" title="<%= t('import.fields.import') %>" aria-label="<%= t('import.fields.import') %>" class="btn-primary" data-action="change->auto-submit#submit" />
17+
<%= form_with(url: "/feeds/import", id: "import", multipart: true) do %>
18+
<input id="opml_file" name="opml_file" type="file" title="<%= t('import.fields.choose_file') %>" aria-label="<%= t('import.fields.choose_file') %>" required />
19+
<%= submit_tag(t('import.fields.import'), class: "btn btn-primary") %>
1920
<a href="/setup/tutorial" id="skip" class="btn float-end"><%= t('import.fields.not_now') %></a>
2021
<% end %>
2122
</div>

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ en:
6060
import:
6161
description: Import your feeds from another service.
6262
fields:
63+
choose_file: Choose file
6364
import: Import
6465
not_now: Not now
6566
subtitle: Let's setup your feeds.

spec/javascript/controllers/auto_submit_controller_spec.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

spec/system/import_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
file_path = Rails.root.join("spec/fixtures/feeds.opml")
1717

1818
attach_file("opml_file", file_path, visible: false)
19+
within("#import") { click_on("Import") }
1920

2021
expect(page).to have_text("We're getting you some stories to read")
2122
end
@@ -26,13 +27,15 @@
2627
file_path = Rails.root.join("spec/fixtures/invalid.opml")
2728

2829
attach_file("opml_file", file_path, visible: false)
30+
within("#import") { click_on("Import") }
2931

3032
expect(page).to have_text("We're getting you some stories to read")
3133
end
3234

3335
def import_grouped_opml
3436
file_path = Rails.root.join("spec/fixtures/feeds.opml")
3537
attach_file("opml_file", file_path, visible: false)
38+
within("#import") { click_on("Import") }
3639
expect(page).to have_text("We're getting you some stories to read")
3740
end
3841

0 commit comments

Comments
 (0)