discourse/spec/system/page_objects/pages/group_activity_posts.rb
Keegan George d886c55f63
DEV: Reusable post-list component (#30312)
This update adds a  _new_ `<PostList />` component, along with it's child components (`<PostListItem/>` and `<PostListItemDetails />`). This new generic component can be used to show a list of posts.

It can be used like so:
```js
/**
 * A component that renders a list of posts
 *
 * @component PostList
 *
 * @args {Array<Object>} posts - The array of post objects to display
 * @args {Function} fetchMorePosts - A function that fetches more posts. Must return a Promise that resolves to an array of new posts.
 * @args {String} emptyText (optional) - Custom text to display when there are no posts
 * @args {String|Array} additionalItemClasses (optional) - Additional classes to add to each post list item
 * @args {String} titleAriaLabel (optional) - Custom Aria label for the post title
 * 
*/
```
```hbs
<PostList
    @posts={{this.posts}}
    @fetchMorePosts={{this.loadMorePosts}}
    @emptyText={{i18n "custom_identifier.empty"}}
    @additionalItemClasses="custom-class"
 />
```
2024-12-19 09:20:25 -08:00

23 lines
513 B
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class GroupActivityPosts < PageObjects::Pages::Base
def visit(group)
page.visit("/g/#{group.name}/activity/posts")
self
end
def has_user_stream_item?(count:)
has_css?(".post-list-item", count: count)
end
def scroll_to_last_item
page.execute_script <<~JS
document.querySelector('.post-list-item:last-of-type').scrollIntoView(true);
JS
end
end
end
end