Skip to content

Playwright: Create a New Collection and Validate Rejection of Duplicate Collection Creation. #4691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ved-bruno
Copy link
Collaborator

@ved-bruno ved-bruno commented May 16, 2025

Description

Contribution Checklist:

  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Jira: BRU-1037

}

test('Create a New Collection and Verify the Duplicate Collection Creation Should Not be Allowed', async ({ page }) => {
const collection_location = '/Users/vedpr/Documents/bruno_tests';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please make sure we use a dynamic path that will work on any system/environment
  2. Please use camelCase naming pattern for variables for consistency

const { execSync } = require('child_process');



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unnecessary line breaks. Keep just one line break here

await page.getByLabel('Location').fill(await collection_location);
await page.getByRole('button', { name: 'Create', exact: true }).click();

//await page.pause();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unwanted commented codes

await page.getByLabel('Name').press('Tab');
await page.getByLabel('Location').fill(collection_location);
await page.getByRole('button', { name: 'Create', exact: true }).click();
await expect(page.getByText('An error occurred while')).toBeVisible();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a line break between assertions and page interactions.
I think it makes more sense and readable if we can put the portion of error message which states duplicate collection or collection already exists

const collection_location = '/Users/vedpr/Documents/bruno_tests';
const collectionName = generateRandomCollectionName();
// ------------code from playwright------------ //
await page.getByRole('img').first().click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to start adding reliable element hooks or use ids so the tests wont fail when new elements are added to the page

const randomWord = () => Math.random().toString(36).substring(2, 6);
const adj = adjectives[Math.floor(Math.random() * adjectives.length)];
const noun = nouns[Math.floor(Math.random() * nouns.length)];
return `${adj}-${noun}-${randomWord()}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a line break above return statement for better readability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants