Skip to content

Add FactoryBot DSL for end-to-end Resources

Dan Davison requested to merge dj-add-factorybot-dsl-to-e2e into master

What does this MR do and why?

Adds FactoryBot DSL for end-to-end resources.

Adds three factories:

  1. Groups
  2. Projects
  3. Issues

Each factory a representative of their respective QA::Resource::* class.

Example

Instead of writing the following:

RSpec.describe 'my test' do
  let(:project) do
    Resource::Project.fabricate_via_api! do |project|
      project.name = 'My Project'
    end
  end

  let(:issue) do
    Resource::Project.fabricate_via_api! do |issue|
      issue.name = 'My Issue'
      issue.confidential = false
    end
  end
end

We become closer with how backend/frontend are familiar with fabricating resources in lower-level tests by using FactoryBot.

RSpec.describe 'my test' do
  let(:project) { create(:project, name: 'My Project') }
  let(:issue) { create(:issue, :confidential, name: 'My Issue') }
end

Closes gitlab-org/quality/quality-engineering/team-tasks#1894 (closed)

Screenshots or screen recordings

pry(#<RSpec::ExampleGroups::Plan::IssueComments>)> issue
{ "name": "issue", "description": "description" }
pry(#<RSpec::ExampleGroups::Plan::IssueComments>)> issue.class
QA::Resource::Issue

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Checkout this branch
  2. $ bundle exec bin/qa Test::Instance::All http://gdk.test:3000 -- qa/specs/features/browser_ui/2_plan/issue/comment_issue_spec.rb:14

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Dan Davison

Merge request reports

Loading