FIX: Don't let table-build automatically fill empty headers with default values (#27894)

* FIX: Don't let table-build automatically fill empty headers with default values

The old table builder would fill empty headers with default values A~Z when editing.
This commit makes table-builder respect the old empty headers

related meta topic: https://meta.discourse.org/t/editing-a-table-with-empty-headers-fills-them-in-with-the-default-text-column-a-column-b/268472
This commit is contained in:
锦心
2024-07-13 00:41:18 +08:00
committed by GitHub
parent 271cbcefa9
commit 63ca30ccb4
2 changed files with 34 additions and 3 deletions

View File

@ -5,6 +5,7 @@ describe "Table Builder", type: :system do
let(:composer) { PageObjects::Components::Composer.new }
let(:insert_table_modal) { PageObjects::Modals::InsertTable.new }
fab!(:topic) { Fabricate(:topic, user: user) }
fab!(:topic2) { Fabricate(:topic, user: user) }
fab!(:post1) { create_post(user: user, topic: topic, raw: <<~RAW) }
|Make | Model | Year|
|--- | --- | ---|
@ -12,6 +13,12 @@ describe "Table Builder", type: :system do
|Nissan | Skyline | 1999|
|Honda | S2000 | 2001|
RAW
fab!(:post2) { create_post(user: user, topic: topic2, raw: <<~RAW) }
| | | |
|--- | --- | ---|
|Some | content | here|
|1 | 2 | 3|
RAW
let(:topic_page) { PageObjects::Pages::Topic.new }
@ -108,6 +115,25 @@ describe "Table Builder", type: :system do
end
end
it "should respect the original empty header" do
topic_page.visit_topic(topic2)
topic_page.find(".btn-edit-table", visible: :all).click
expect(page).to have_selector(".insert-table-modal")
insert_table_modal.type_in_cell(0, 0, " updated")
insert_table_modal.click_insert_table
updated_post = <<~RAW
| | | |
|--- | --- | ---|
|Some updated | content | here|
|1 | 2 | 3|
RAW
try_until_success do
expect(normalize_value(post2.reload.raw)).to eq(normalize_value(updated_post))
end
end
context "when adding an edit reason" do
it "should add the edit reason to the edit history" do
edit_reason = "Updated Nissan model"