DEV: uses local playwright chromium for now (#32613)

We have had multiple issues while using the chrome channel:
- super slow start of the spec, I can confirm I don't have it on
chromium
- more risk of different failures between local dev machines and CI

There was a test not working on chromium, as it doesn't have mp4 codecs
out of the box. I changed the spec to use webm instead and it's now
working correctly.

This commit also fixes a bug with the video/trace paths which were
incorrect, and also makes another test less flakey with uploads event
though Im not very clear on what is going on here, we need to dig this.

We now need to figure out a way to have this on the test image, but this
is for now a better solution.
This commit is contained in:
Joffrey JAFFEUX
2025-05-07 10:17:25 +02:00
committed by GitHub
parent b16fb6a60b
commit addaa03192
7 changed files with 22 additions and 16 deletions

View File

@ -274,6 +274,10 @@ jobs:
if: matrix.build_type == 'system'
run: script/assemble_ember_build.rb
- name: Install playwright
if: matrix.build_type == 'system'
run: pnpm playwright install --with-deps --no-shell chromium
- name: Core System Tests
if: matrix.build_type == 'system' && matrix.target == 'core'
env:

View File

@ -60,6 +60,8 @@ if !system "pnpm", "--dir=#{RAILS_ROOT}", "install"
exit 1
end
system "pnpm", "playwright", "install", "--with-deps", "--no-shell", "chromium"
pnpm_env = {
"TERM" => "dumb", # simple output from ember-cli, so we can parse/forward it more easily
}

BIN
spec/fixtures/media/small.webm vendored Normal file

Binary file not shown.

View File

@ -459,7 +459,7 @@ RSpec.configure do |config|
driver_options = {
browser_type: :chromium,
channel: :chrome,
channel: :chromium,
headless: (ENV["PLAYWRIGHT_HEADLESS"].presence || ENV["SELENIUM_HEADLESS"].presence) != "0",
args: apply_base_chrome_args,
acceptDownloads: true,
@ -684,7 +684,7 @@ RSpec.configure do |config|
if !ENV["CI"]
puts "\n🎥 Recorded video for: #{example.metadata[:full_description]}\n"
puts "#{File.join(Rails.root, saved_path)}\n"
puts "#{saved_path}\n"
end
end
end
@ -701,7 +701,7 @@ RSpec.configure do |config|
if !ENV["CI"]
puts "\n🧭 Saved trace for: #{example.metadata[:full_description]}\n"
puts "Open with `pnpm playwright show-trace #{File.join(Rails.root, saved_path)}`\n"
puts "Open with `pnpm playwright show-trace #{saved_path}`\n"
end
end
end

View File

@ -366,7 +366,7 @@ describe "Composer - ProseMirror editor", type: :system do
cdp.copy_paste("https://example.com/x")
composer.type_content(:space).type_content("and").type_content(:space)
cdp.paste
composer.type_content("\n")
composer.type_content(:enter)
expect(rich).to have_css(
"a.inline-onebox[href='https://example.com/x']",

View File

@ -4,7 +4,9 @@ describe "Composer using review_media", type: :system do
fab!(:current_user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:topic) { Fabricate(:topic, category: Category.find(SiteSetting.uncategorized_category_id)) }
fab!(:post) { Fabricate(:post, topic: topic) }
let(:topic_page) { PageObjects::Pages::Topic.new }
let(:composer) { PageObjects::Components::Composer.new }
before do
SiteSetting.skip_review_media_groups = Group::AUTO_GROUPS[:trust_level_3]
@ -25,14 +27,12 @@ describe "Composer using review_media", type: :system do
it "flags a post with an image" do
topic_page.visit_topic_and_open_composer(topic)
topic_page.fill_in_composer(" this one has an upload: ")
attach_file "file-uploader",
"#{Rails.root}/spec/fixtures/images/logo.jpg",
make_visible: {
display: "block",
visibility: "visible",
opacity: 1,
}
attach_file(file_from_fixtures("logo.jpg", "images").path) do
composer.click_toolbar_button("upload")
end
within(".d-editor-preview") { expect(page).to have_css("img") }
topic_page.send_reply
expect(page).to have_css(".post-enqueued-modal")

View File

@ -40,7 +40,7 @@ describe "Uploading files in the composer", type: :system do
context "when video thumbnails are enabled" do
before do
SiteSetting.video_thumbnails_enabled = true
SiteSetting.authorized_extensions += "|mp4"
SiteSetting.authorized_extensions += "|webm"
end
it "generates a topic preview thumbnail from the video" do
@ -48,7 +48,7 @@ describe "Uploading files in the composer", type: :system do
expect(composer).to be_opened
topic.fill_in_composer_title("Video upload test")
file_path_1 = file_from_fixtures("small.mp4", "media").path
file_path_1 = file_from_fixtures("small.webm", "media").path
attach_file(file_path_1) { composer.click_toolbar_button("upload") }
expect(composer).to have_no_in_progress_uploads
@ -65,7 +65,7 @@ describe "Uploading files in the composer", type: :system do
expect(composer).to be_opened
topic.fill_in_composer_title("Video upload test")
file_path_1 = file_from_fixtures("small.mp4", "media").path
file_path_1 = file_from_fixtures("small.webm", "media").path
attach_file(file_path_1) { composer.click_toolbar_button("upload") }
expect(composer).to have_no_in_progress_uploads
@ -99,7 +99,7 @@ describe "Uploading files in the composer", type: :system do
HTMLVideoElement.prototype.__defineGetter__('videoHeight', function() { return 0; });
JS
file_path_1 = file_from_fixtures("small.mp4", "media").path
file_path_1 = file_from_fixtures("small.webm", "media").path
attach_file(file_path_1) { composer.click_toolbar_button("upload") }
expect(composer).to have_no_in_progress_uploads
@ -131,7 +131,7 @@ describe "Uploading files in the composer", type: :system do
};
JS
file_path_1 = file_from_fixtures("small.mp4", "media").path
file_path_1 = file_from_fixtures("small.webm", "media").path
attach_file(file_path_1) { composer.click_toolbar_button("upload") }
expect(composer).to have_no_in_progress_uploads