Skip to content

[QA] Refactor playwright test code to pass data in array #13565

@PrajwolAmatya

Description

@PrajwolAmatya

Description

Currently, while rewriting the gherkin tests to playwright. And for the steps like below:

 And "Alice" shares the following resource using API
       | resource       | recipient | type | role                                | resourceType |
       | folderPublic   | Brian     | user | Can edit with versions and trashbin | folder       |
       | emptyFolder    | Brian     | user | Can edit with versions and trashbin | folder       |
       | testavatar.jpg | Brian     | user | Can edit with versions and trashbin | file         |

We are calling the function userHasSharedResource multiple times, depending on the number of resources listed in data table as:

    await api.userHasSharedResource({
      usersEnvironment,
      stepUser: 'Alice',
      resource: 'folderPublic',
      recipient: 'Brian',
      type: 'user',
      role: 'Can edit with versions and trashbin',
      resourceType: 'folder'
    })
    await api.userHasSharedResource({
      usersEnvironment,
      stepUser: 'Alice',
      resource: 'emptyFolder',
      recipient: 'Brian',
      type: 'user',
      role: 'Can edit with versions and trashbin',
      resourceType: 'folder'
    })
    await api.userHasSharedResource({
      usersEnvironment,
      stepUser: 'Alice',
      resource: 'testavatar.jpg',
      recipient: 'Brian',
      type: 'user',
      role: 'Can edit with versions and trashbin',
      resourceType: 'file'
    })

Instead of this we can pass the data in array of objects as:

await api.userHasSharedResource({
      usersEnvironment,
      stepUser: 'Alice',
      resources: [
        { name: 'folderPublic', recipient: 'Brian', type: 'user', role: 'Can edit with versions and trashbin', resourceType: 'folder' },
        { name: 'emptyFolder', recipient: 'Brian', type: 'user', role: 'Can edit with versions and trashbin', resourceType: 'folder' },
        { name: 'testavatar.jpg', recipient: 'Brian', type: 'user', role: 'Can edit with versions and trashbin', resourceType: 'file' }
      ]
    })

This will make our test codes shorter and more readable.

There are other steps as well where we call the functions multiple times, and those codes also need to be refactored.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions