Skip to content
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

test(Button): improve button tests #1756

Merged
merged 10 commits into from
Aug 23, 2024
Merged

test(Button): improve button tests #1756

merged 10 commits into from
Aug 23, 2024

Conversation

itwillwork
Copy link
Contributor

No description provided.

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@gravity-ui-bot
Copy link
Contributor

Visual Tests Report is ready.

@itwillwork itwillwork changed the title test(Button): Improve button tests test(Button): improve button tests Aug 16, 2024
@@ -10,6 +10,7 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
const expectScreenshot: ExpectScreenshotFixture = async ({
component,
screenshotName,
screenshotPostfix,
Copy link
Contributor Author

@itwillwork itwillwork Aug 16, 2024

Choose a reason for hiding this comment

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

For multiple screenshots per test

 test(........., () => {
      await expectScreenshot();

      //...

      await expectScreenshot({
          screenshotPostfix: 'after hover',
      });
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe screenshotNameSuffix?

options?: Options,
) => {
const scenarioDetails: ScenarioDetails = {
tag: ['@smoke', ...(options?.additionalTags || [])],
};

const scenarioName: ScenarioName = `smoke scenario${options?.scenarioName ? ` ${options?.scenarioName}` : ''}`;
Copy link
Contributor Author

@itwillwork itwillwork Aug 16, 2024

Choose a reason for hiding this comment

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

For a more declarative name of the generated test name

before
image

after
image

Copy link
Contributor

Choose a reason for hiding this comment

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

What if we shorten this to smoke [default] or smoke [view: action], omit scenario and props words


await expectScreenshot({
screenshotPostfix: 'after hover',
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added hover test for the button

@@ -10,6 +10,7 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
const expectScreenshot: ExpectScreenshotFixture = async ({
component,
screenshotName,
screenshotPostfix,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe screenshotNameSuffix?

await root.getByTestId(qa).hover();

await expectScreenshot({
screenshotPostfix: 'after hover',
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use hovered, thus screenshot name will be more readable: Button-smoke-hovered-...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed

options?: Options,
) => {
const scenarioDetails: ScenarioDetails = {
tag: ['@smoke', ...(options?.additionalTags || [])],
};

const scenarioName: ScenarioName = `smoke scenario${options?.scenarioName ? ` ${options?.scenarioName}` : ''}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we shorten this to smoke [default] or smoke [view: action], omit scenario and props words

@@ -10,6 +10,7 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
const expectScreenshot: ExpectScreenshotFixture = async ({
component,
screenshotName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove screenshotName (it's not used anywhere), and instead of screenshotPostfix introduce nameSuffix option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

image

@itwillwork itwillwork requested a review from amje August 22, 2024 09:38
@itwillwork itwillwork merged commit 442ce85 into main Aug 23, 2024
6 checks passed
@itwillwork itwillwork deleted the improve-button-tests branch August 23, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants