Draft: [72234] Workflows UX improvement: Show workflows by type#22294
Draft: [72234] Workflows UX improvement: Show workflows by type#22294
Conversation
| end | ||
|
|
||
| if @state != :edit | ||
| unless %i[index edit].include?(@state) |
There was a problem hiding this comment.
I'm a slow convert to the AS convenience method:
| unless %i[index edit].include?(@state) | |
| unless @state.in?(%i[index edit] |
| it "lists all the types" do | ||
| expect(page).to have_heading("Workflows") | ||
|
|
||
| within "[role=table]" do |
There was a problem hiding this comment.
I believe the following should work - thanks to Capybara Accessible Selectors (which is where the have_heading selector comes from in fact).
| within "[role=table]" do | |
| within(:role, :table) do |
| expect(page).to have_css(".Box-row[role=row]", count: 3) | ||
| types.each do |type| | ||
| expect(page).to have_css(".Box-row[role=row] a[href='#{edit_workflow_path(type)}']", text: type.name) | ||
| end |
There was a problem hiding this comment.
CAS also provides a row selector.
| expect(page).to have_css(".Box-row[role=row]", count: 3) | |
| types.each do |type| | |
| expect(page).to have_css(".Box-row[role=row] a[href='#{edit_workflow_path(type)}']", text: type.name) | |
| end | |
| expect(page).to have_row(:row, class: "Box-row", count: 3) | |
| types.each do |type| | |
| expect(page).to have_row(:row, class: "Box-row", count: 3) do |row| | |
| expect(row).to have_link(type.name, href: edit_workflow_path(type)) | |
| emd | |
| end |
See also:
spec/features/workflows/summary_spec.rbspec/components/op_primer/border_box_table_component_spec.rb
| visit url_for(controller: "/workflows", action: :index) | ||
| end | ||
|
|
||
| it "lists all the types" do |
There was a problem hiding this comment.
When you're simply asserting that something renders—rather than testing user interactions—I'd advocate for writing component specs. They're relatively cheap.
I'd also argue that feature specs shouldn't assert that specific classes are shown (unless it's legacy frontend code that uses CSS classes rather than data attributes as handles or for applying behaviour).
There are some shared examples available here with this in mind (N.B. although they probably work with feature specs, they're intended for use with component specs):
spec/support/shared/components/border_box_table_component.rb
There was a problem hiding this comment.
We should probably establish the habit of accessibility testing with all new feature specs. This is possible with our RSpec-AXe integration:
expect(page).to be_axe_clean.within("#content")The only caveat is that you'll need to switch to the Selenium driver for this to work.
|
|
||
| require "spec_helper" | ||
|
|
||
| RSpec.describe "Workflows index" do |
There was a problem hiding this comment.
N.B. this feature will run without JavaScript unless you explicitly add the :js.
@myabc No worries, thank you for the early feedback, it helps me to figure out the project test strategy. To be honest, I just tried to replicate the existing specs about workflows for my new page. As this piece of software has been untouched for quite some time, maybe it’s not on par with the current testing standards. I’ll try to come up with something more up-to-date on the reviewable PR 👌 |
468eb9f to
6edf688
Compare
6edf688 to
09f36d9
Compare
Let's keep it simple here. We have precedence for BorderBox tables without a more icon, or even an edit action (for example Also, let's not change the positioning of the Workflow page in Admin setting. This is not in the scope of this feature. And such a change should ideally also be discussed within the work package rather than the PR, since it would be quite a structural change. The changes to the workflow page in the context of the current epic is a result of prior discussions, notably between @oliverguenther and Niels, who's set the scope for this. If there are better ideas, we can certainly consider them, but not in a PR comment; else, we'll have trouble keeping everyone in sync on decisions that were already taken. They might not always be the best decisions or ones we agree with; they can always be discussed/challenged, but ideally not during implementation in a PR comment. |
e172da5 to
f69e2da
Compare
f69e2da to
61ba746
Compare
| let(:table) do | ||
| instance_double( | ||
| Workflows::TableComponent, | ||
| columns: %i[name], | ||
| main_column?: false, | ||
| mobile_columns: %i[name], | ||
| mobile_labels: %i[name], | ||
| column_title: "Type", | ||
| has_actions?: false | ||
| ) | ||
| end |
There was a problem hiding this comment.
I don’t like this implementation details noise. The simplest way to get rid of it is to instantiate the actual TableComponent:
| let(:table) do | |
| instance_double( | |
| Workflows::TableComponent, | |
| columns: %i[name], | |
| main_column?: false, | |
| mobile_columns: %i[name], | |
| mobile_labels: %i[name], | |
| column_title: "Type", | |
| has_actions?: false | |
| ) | |
| end | |
| let(:table) { Workflows::TableComponent.new(rows: [type]) } |
That’s obviously the version closest to real life — I had to figure out the right return values for the instance_double to render the expected HTML and not some variations of the a11y roles. But we tend no to instantiate real objects to prevent tight coupling… Is that such a big deal here, considering that the TableComponent and RowComponent are tightly-coupled by a naming convention?
Another way of testing the content of the row I found in the repository is in the TableComponent spec itself. You’ll find my attempt in the file below, line 64. I usually prefer unit-testing classes in their own spec file, but with this tightly-coupled classes, a broken RowComponent will break the TableComponent spec anyway… And in the end, the spec does not read that bad when there is just a few test cases like in my case.
Is there a preferred/deprecated/use-your-own-judgement way?
Found examples:
|
@psatyal sorry! I should have kept the design "thinking out loud" for the ticket or open door. |

Ticket
https://community.openproject.org/wp/72234
What are you trying to accomplish?
Screenshots
What approach did you choose and why?
type_idis now a required URL param, not a optional query param;WorkflowsController#showin nowWorkflowsController#summarizedto prevent any confusion with a usual RESTfulshowaction.Merge checklist