-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add POM for the E2E tests and update all tests #1259
Conversation
Added method and configurations Additional refactoring - methods, specs and gitignore Implemented Support page for E2E tests Fixed tests for Support page New changes on the tests
Added method and configurations Additional refactoring - methods, specs and gitignore Implemented Support page for E2E tests Fixed tests for Support page New changes on the tests Fixes on E2E tests
…e-e2e-tests' of https://github.com/podkrepi-bg/frontend into 1194-feature-create-playwright-page-object-model-for-the-e2e-tests
…-model-for-the-e2e-tests
…e-e2e-tests' of https://github.com/podkrepi-bg/frontend into 1194-feature-create-playwright-page-object-model-for-the-e2e-tests
…l-for-the-e2e-tests' of https://github.com/podkrepi-bg/frontend into 1194-feature-create-playwright-page-object-model-for-the-e2e-tests" This reverts commit 3bb8a19, reversing changes made to b18b16b.
✅ Tests will run for this PR. Once they succeed it can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job overall 💯 !
The thing I do not understand is why we need the package.json
and .gitignore
inside of the e2e folder and not on a global level. Is it so that when it's run in GH Actions we run it inside of the e2e folder and is that what we shoud do?
Also I am concerned on the speed of the tests a little, they've been quite slow running on a single worker before when they were just a few. Now we are going to be waiting a ton for a test suite to run. I don't know what we can do about it though
node_modules/ | ||
/playwright/.cache/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
/e2e-reports/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe these should be in the top level gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it won't be a problem to remove this gitignore
file (it was auto-generated) and to move on the top level all these folders.
Thanks for the suggestion, I will do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the package.json
the situation is more complex. I'm definitely not an expert on such configuration topics, but I discuss that with @kachar and he agreed that it's better to separate all playwright
packages into the E2E folder.
In that case will be easier to upgrade the versions, because currently I'm hitting some issues/errors when trying to do it on the main package.json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said, I'm not an expert on this, so I will be grateful to have good discussion about Pros and Cons of such approach.
Thanks overall for your comments, @dimitur2204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no problem in having these folders ignored in the current folder .gitignore
file
/** | ||
* Check if H1 heading is visible by text with timeout | ||
* @param {LanguagesEnum} language | ||
* @param {string} headingBg | ||
* @param {string | null} headingEn | ||
*/ | ||
async isH1HeadingVisible(language: LanguagesEnum, headingBg: string, headingEn: string | null): Promise<boolean> { | ||
return this.isHeadingVisibleBySelector(this.h1HeadingsSelector, language, headingBg, headingEn); | ||
} | ||
|
||
/** | ||
* Check if H4 heading is visible by text with timeout | ||
* @param {LanguagesEnum} language | ||
* @param {string} headingBg | ||
* @param {string | null} headingEn | ||
*/ | ||
async isH4HeadingVisible(language: LanguagesEnum, headingBg: string, headingEn: string | null): Promise<boolean> { | ||
return this.isHeadingVisibleBySelector(this.h4HeadingsSelector, language, headingBg, headingEn); | ||
} | ||
|
||
/** | ||
* Check if H5 heading is visible by text with timeout | ||
* @param {LanguagesEnum} language | ||
* @param {string} headingBg | ||
* @param {string | null} headingEn | ||
*/ | ||
async isH5HeadingVisible(language: LanguagesEnum, headingBg: string, headingEn: string | null): Promise<boolean> { | ||
return this.isHeadingVisibleBySelector(this.h5HeadingsSelector, language, headingBg, headingEn); | ||
} | ||
|
||
/** | ||
* Check if H6 heading is visible by text with timeout | ||
* @param {LanguagesEnum} language | ||
* @param {string} headingBg | ||
* @param {string | null} headingEn | ||
*/ | ||
async isH6HeadingVisible(language: LanguagesEnum, headingBg: string, headingEn: string | null): Promise<boolean> { | ||
return this.isHeadingVisibleBySelector(this.h6HeadingsSelector, language, headingBg, headingEn); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can probably be one function with an option of 'h1'|'h2'|'h3' ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How and where do you suggest to pass the parameter?
I think it's better to wrap each method as like now, because it is easier when we have less arguments.
import { expectCopied } from '../../../utils/helpers' | ||
import { HomePage } from '../../../pages/web-pages/home.page'; | ||
|
||
// TODO: Refactor this spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is irrelevant at this point I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think so, but I don't want to remove it yet.
test.describe.skip('user bank transfer donation flow', () => { | ||
test('check copied values', async ({ page }) => { | ||
// Choose a predefined value from the radio buttons | ||
await page.locator('input[value="bank"]').check() | ||
expect(await page.locator('text="Копирай"').count()).toBe(4) | ||
|
||
if (page.context().browser()?.browserType().name() === 'chromium') { | ||
await page.context().grantPermissions(['clipboard-read', 'clipboard-write']) | ||
await page.locator('text="Копирай"').nth(0).click() | ||
await expectCopied(page, 'Сдружение Подкрепи БГ') | ||
await page.locator('text="Копирай"').nth(1).click() | ||
await expectCopied(page, 'Уникредит Булбанк') | ||
await page.locator('text="Копирай"').nth(2).click() | ||
await expectCopied(page, 'BG66UNCR70001524349032') | ||
await page.locator('text="Копирай"').nth(3).click() | ||
const reference = await page.locator('p[data-testid="payment-reference-field"]').innerText() | ||
await expectCopied(page, reference) | ||
} | ||
}) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should only leave this test running since we don't have it in the new files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will review and leave some appropriate scenarios. I just didn't have enough time for all specs.
Additional fix
|
||
export const anonDonationTestData = { | ||
cardNumber: '4242 4242 4242 4242', | ||
cardExpDate: '04 / 24', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move the year to say: 42 (👍🌌) ?
We don't want those tests to stop working in 18 months...
if (language === LanguagesEnum.BG) { | ||
return this.isStepActiveByLabelText(this.bgSelectAmountSectionText); | ||
} else if (language === LanguagesEnum.EN) { | ||
return this.isStepActiveByLabelText(this.enSelectAmountSectionText); | ||
} else { | ||
throw new Error("Language not found!"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those ifs create unnecessary code duplication.
It would be better to have a localization map or even different configuration files per language.
and then just say:
return this.isStepActiveByLabelText(t(lang, 'select-amount-section-text'));
private readonly bgMainCampaignsHeading = bgLocalizationCampaigns.campaigns; | ||
private readonly enMainCampaignsHeading = enLocalizationCampaigns.campaigns; | ||
private readonly bgSupportCauseTodayHeading = bgLocalizationCampaigns.cta['support-cause-today']; | ||
private readonly enSupportCauseTodayHeading = enLocalizationCampaigns.cta['support-cause-today']; | ||
private readonly bgSupportNowActionButtonText = bgLocalizationCampaigns.cta['support-now']; | ||
private readonly enSupportNowActionButtonText = enLocalizationCampaigns.cta['support-now']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a way to use the t() function?
Hardcoding those seems like a lot of code duplication to me.
@DanielTakev @dimitur2204 @slavcho Let's move on with this topic and get the initial version merged. We can enhance it once we have the foundation settled in. What's blocking this PR from getting merged except for the conflict and the failing next.js build? |
Closed in favor of #1265 |
Closes #{#1188, #1194 }
Motivation and context
This change is important because we need stable E2E tests and reusable code.
e
) from a few files (ex.: public/locales/bg/common.json)localhost
New or updated dependencies:
e2e
TODO: