From a57b6bf36de5cdce54c409c62d599a0fb3604c27 Mon Sep 17 00:00:00 2001 From: Staschalapko Date: Fri, 21 Jun 2024 18:01:21 +0300 Subject: [PATCH] 1801,1812,1814 tests added --- helpers/gmail.js | 37 +++++++++-- pages/dashboard/dashboard-page.js | 5 ++ tests/dashboard/dashboard-teams.spec.js | 86 ++++++++++--------------- tests/forgot-password.spec.js | 9 ++- tests/profile.spec.js | 7 +- tests/signup.spec.js | 3 +- tests/survey-questions.spec.js | 30 +++++++++ 7 files changed, 107 insertions(+), 70 deletions(-) diff --git a/helpers/gmail.js b/helpers/gmail.js index 8e97709..c991a2d 100644 --- a/helpers/gmail.js +++ b/helpers/gmail.js @@ -47,7 +47,7 @@ async function listMessages(auth, email) { } } -async function messagesCount(auth, email, count) { +async function messagesCount(auth, email) { const gmail = google.gmail({ version: 'v1', auth }); async function searchMessages(label, email) { @@ -69,12 +69,17 @@ async function messagesCount(auth, email, count) { async function checkMessagesCount(email, count) { return authorize().then(async (auth) => { - const actualCount = await messagesCount(auth, email, count); - console.log(actualCount) + const actualCount = await messagesCount(auth, email); expect(actualCount).toEqual(count); }).catch(console.error); } +async function getMessagesCount(email) { + return authorize().then(async (auth) => { + return await messagesCount(auth, email); + }).catch(console.error); +} + async function getRegisterMessage(email) { return authorize().then(async (auth) => { const body = await listMessages(auth, email); @@ -171,10 +176,30 @@ async function waitMessage(page , email, timeoutSec= 40) { await page.waitForTimeout(interval); } - if (!invite.inviteUrl) { - throw new Error('Timeout reached: invite.inviteUrl is still undefined'); + if (!invite) { + throw new Error('Timeout reached: invite is still undefined'); } } -module.exports = {checkInviteText, getRegisterMessage, checkRegisterText, checkRecoveryText, checkNewEmailText, checkMessagesCount, waitMessage}; +async function waitSecondMessage(page , email, timeoutSec= 40) { + const timeout = timeoutSec*1000; + const interval = 4000; + const startTime = Date.now(); + let count; + + await page.waitForTimeout(interval); + while (Date.now() - startTime < timeout) { + count = await getMessagesCount(email); + if (count === 2) { + return 1; + } + await page.waitForTimeout(interval); + } + + if (count !== 2) { + throw new Error('Timeout reached: second messages is still undefined'); + } +} + +module.exports = {checkInviteText, getRegisterMessage, checkRegisterText, checkRecoveryText, checkNewEmailText, checkMessagesCount, waitMessage, waitSecondMessage}; diff --git a/pages/dashboard/dashboard-page.js b/pages/dashboard/dashboard-page.js index 2132504..a9933be 100644 --- a/pages/dashboard/dashboard-page.js +++ b/pages/dashboard/dashboard-page.js @@ -159,6 +159,7 @@ exports.DashboardPage = class DashboardPage extends BasePage { this.onboardingInviteInput = page.locator('input[class*="components_forms__inside-input"]'); this.onboardingCreateTeamButton = page.locator('button[class*="main_ui_onboarding_team_choice__accept-button"]'); this.selectedRadioButtonLabel = page.locator('label[class*="components_forms__radio-label checked"]').first(); + this.selectedRadioImageLabel = page.locator('label[class*="checked"] span[class*="text"]').first(); this.onboardingPaginator = page.locator('div[class*="onboarding_questions__paginator"]'); this.onboardingFirstHeader = page.locator('*[class*="onboarding_questions__modal-title"]'); @@ -770,6 +771,10 @@ exports.DashboardPage = class DashboardPage extends BasePage { await expect(this.selectedRadioButtonLabel).toHaveText(value); } + async checkRadioImageLabel(value) { + await expect(this.selectedRadioImageLabel).toHaveText(value); + } + async selectKindOfWork(option) { await this.planingToUsingDropdown.first().click(); const optionSelector = await this.page.locator(`li span:has-text("${option}")`); diff --git a/tests/dashboard/dashboard-teams.spec.js b/tests/dashboard/dashboard-teams.spec.js index a8077ba..b82fb38 100644 --- a/tests/dashboard/dashboard-teams.spec.js +++ b/tests/dashboard/dashboard-teams.spec.js @@ -7,7 +7,7 @@ const { MainPage } = require('../../pages/workspace/main-page'); const { random } = require('../../helpers/string-generator'); const { updateTestResults } = require('./../../helpers/saveTestResults.js'); const { qase } = require('playwright-qase-reporter/dist/playwright'); -const { getRegisterMessage, checkInviteText, checkMessagesCount } = require('../../helpers/gmail'); +const { getRegisterMessage, checkInviteText, checkMessagesCount, waitMessage, waitSecondMessage } = require('../../helpers/gmail'); const { LoginPage } = require('../../pages/login-page'); const { RegisterPage } = require('../../pages/register-page'); @@ -508,9 +508,8 @@ test.describe(() => { 'Editor', 'Pending' ); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); - const secondInvite = await getRegisterMessage(secondEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); + const secondInvite = await waitMessage(page, secondEmail, 40); const user = process.env.CI ? 'QA Engineer' : 'QA Engineer';//'k8q6byz'; await checkInviteText(firstInvite.inviteText, team, user); await checkInviteText(secondInvite.inviteText, team, user); @@ -597,8 +596,7 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Admin'); await teamPage.enterEmailToInviteMembersPopUp(mainEmail); await teamPage.clickSendInvitationButton(); - await page.waitForTimeout(30000); - const mainInvite = await getRegisterMessage(mainEmail); + const mainInvite = await waitMessage(page, mainEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -632,9 +630,8 @@ test.describe(() => { 'Admin', 'Pending' ); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); - const secondInvite = await getRegisterMessage(secondEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); + const secondInvite = await waitMessage(page, secondEmail, 40); await checkInviteText(firstInvite.inviteText, team, mainAdmin); await checkInviteText(secondInvite.inviteText, team, mainAdmin); await profilePage.logout(); @@ -702,8 +699,7 @@ test.describe(() => { await registerPage.clickOnAcceptTermsCheckbox(); await registerPage.clickOnCreateAccountSecondBtn(); await registerPage.isRegisterEmailCorrect(secondEmail); - await page.waitForTimeout(30000); - const register = await getRegisterMessage(secondEmail); + const register = await waitMessage(page, secondEmail, 40); await page.goto(register.inviteUrl); await dashboardPage.fillOnboardingQuestions(); @@ -722,7 +718,7 @@ test.describe(() => { await teamPage.clickSendInvitationButton(); await profilePage.logout(); await loginPage.isLoginPageOpened(); - await page.waitForTimeout(30000); + await waitSecondMessage(page, secondEmail, 40); const invite = await getRegisterMessage(secondEmail); await loginPage.enterEmail(secondEmail); await loginPage.enterPwd(process.env.LOGIN_PWD); @@ -756,8 +752,7 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Admin'); await teamPage.enterEmailToInviteMembersPopUp(mainEmail); await teamPage.clickSendInvitationButton(); - await page.waitForTimeout(30000); - const mainInvite = await getRegisterMessage(mainEmail); + const mainInvite = await waitMessage(page, mainEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -786,11 +781,11 @@ test.describe(() => { 'Admin', 'Pending' ); - await page.waitForTimeout(20000); + await page.waitForTimeout(5000); await teamPage.resendInvitation(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); + await waitSecondMessage(page, secondEmail, 40); await checkMessagesCount(secondEmail, 2); }, ); @@ -818,8 +813,7 @@ test.describe(() => { await teamPage.enterEmailToInviteMembersPopUp(secondEmail); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const secondInvite = await getRegisterMessage(secondEmail) + const secondInvite = await waitMessage(page, secondEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -891,9 +885,8 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Admin'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); - const secondInvite = await getRegisterMessage(secondEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); + const secondInvite = await waitMessage(page, secondEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -989,9 +982,8 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Editor'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); - const secondInvite = await getRegisterMessage(secondEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); + const secondInvite = await waitMessage(page, secondEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1057,8 +1049,7 @@ test.describe(() => { await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); await teamPage.clickInviteMembersToTeamButton(); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1112,9 +1103,8 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Editor'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); - const secondInvite = await getRegisterMessage(secondEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); + const secondInvite = await waitMessage(page, secondEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1159,8 +1149,7 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Admin'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1202,8 +1191,7 @@ test.describe(() => { await teamPage.enterEmailToInviteMembersPopUp(firstEmail); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1246,8 +1234,7 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Admin'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1305,9 +1292,8 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Admin'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); - const secondInvite = await getRegisterMessage(secondEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); + const secondInvite = await waitMessage(page, secondEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1382,9 +1368,8 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Editor'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); - const secondInvite = await getRegisterMessage(secondEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); + const secondInvite = await waitMessage(page, secondEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1459,8 +1444,7 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Editor'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1536,8 +1520,7 @@ test.describe(() => { await registerPage.clickOnAcceptTermsCheckbox(); await registerPage.clickOnCreateAccountSecondBtn(); await registerPage.isRegisterEmailCorrect(secondEmail); - await page.waitForTimeout(30000); - const register = await getRegisterMessage(secondEmail); + const register = await waitMessage(page, secondEmail, 40); await page.goto(register.inviteUrl); await dashboardPage.fillOnboardingQuestions(); @@ -1556,7 +1539,7 @@ test.describe(() => { await teamPage.clickSendInvitationButton(); await profilePage.logout(); await loginPage.isLoginPageOpened(); - await page.waitForTimeout(30000); + await waitSecondMessage(page, secondEmail, 40); const invite = await getRegisterMessage(secondEmail); await loginPage.enterEmail(secondEmail); await loginPage.enterPwd(process.env.LOGIN_PWD); @@ -1617,8 +1600,7 @@ test.describe(() => { await registerPage.clickOnAcceptTermsCheckbox(); await registerPage.clickOnCreateAccountSecondBtn(); await registerPage.isRegisterEmailCorrect(secondEmail); - await page.waitForTimeout(30000); - const register = await getRegisterMessage(secondEmail); + const register = await waitMessage(page, secondEmail, 40); await page.goto(register.inviteUrl); await dashboardPage.fillOnboardingQuestions(); @@ -1636,7 +1618,7 @@ test.describe(() => { await teamPage.clickSendInvitationButton(); await profilePage.logout(); await loginPage.isLoginPageOpened(); - await page.waitForTimeout(30000); + await waitSecondMessage(page, secondEmail, 40); const invite = await getRegisterMessage(secondEmail); await loginPage.enterEmail(secondEmail); await loginPage.enterPwd(process.env.LOGIN_PWD); @@ -1694,8 +1676,7 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Admin'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); - const firstInvite = await getRegisterMessage(firstEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); @@ -1751,10 +1732,9 @@ test.describe(() => { await teamPage.selectInvitationRoleInPopUp('Admin'); await teamPage.clickSendInvitationButton(); await teamPage.isSuccessMessageDisplayed('Invitation sent successfully'); - await page.waitForTimeout(30000); await teamPage.deleteInvitation(); await teamPage.isInvitationRecordRemoved(); - const firstInvite = await getRegisterMessage(firstEmail); + const firstInvite = await waitMessage(page, firstEmail, 40); await profilePage.logout(); await loginPage.isLoginPageOpened(); diff --git a/tests/forgot-password.spec.js b/tests/forgot-password.spec.js index e921bef..b213f2e 100644 --- a/tests/forgot-password.spec.js +++ b/tests/forgot-password.spec.js @@ -5,7 +5,7 @@ const { updateTestResults } = require('./../helpers/saveTestResults.js'); const { qase } = require('playwright-qase-reporter/dist/playwright'); const { random } = require('../helpers/string-generator'); const { RegisterPage } = require('../pages/register-page'); -const { getRegisterMessage, checkRecoveryText } = require('../helpers/gmail'); +const { getRegisterMessage, checkRecoveryText, waitMessage, waitSecondMessage } = require('../helpers/gmail'); const { DashboardPage } = require('../pages/dashboard/dashboard-page'); const { ProfilePage } = require('../pages/profile-page'); @@ -50,8 +50,7 @@ test.describe(() => { await registerPage.clickOnAcceptTermsCheckbox(); await registerPage.clickOnCreateAccountSecondBtn(); await registerPage.isRegisterEmailCorrect(email); - await page.waitForTimeout(30000); - invite = await getRegisterMessage(email); + invite = await waitMessage(page, email, 40); await page.goto(invite.inviteUrl); await dashboardPage.fillOnboardingQuestions(); }); @@ -67,7 +66,7 @@ test.describe(() => { await loginPage.clickOnForgotPassword(); await forgotPasswordPage.enterEmail(email); await forgotPasswordPage.clickRecoverPasswordButton(); - await page.waitForTimeout(30000); + await waitSecondMessage(page, email, 40); const forgotPass = await getRegisterMessage(email); await checkRecoveryText(forgotPass.inviteText, randomName); await page.goto(forgotPass.inviteUrl); @@ -93,7 +92,7 @@ test.describe(() => { await loginPage.clickOnForgotPassword(); await forgotPasswordPage.enterEmail(email); await forgotPasswordPage.clickRecoverPasswordButton(); - await page.waitForTimeout(30000); + await waitSecondMessage(page, email, 40); const forgotPass = await getRegisterMessage(email); await checkRecoveryText(forgotPass.inviteText, randomName); await page.goto(forgotPass.inviteUrl); diff --git a/tests/profile.spec.js b/tests/profile.spec.js index 437445b..09d3d7d 100644 --- a/tests/profile.spec.js +++ b/tests/profile.spec.js @@ -6,7 +6,7 @@ const { expect, test } = require('@playwright/test'); const { updateTestResults } = require('./../helpers/saveTestResults.js'); const { qase } = require('playwright-qase-reporter/dist/playwright'); const { RegisterPage } = require('../pages/register-page'); -const { getRegisterMessage, checkNewEmailText } = require('../helpers/gmail'); +const { getRegisterMessage, checkNewEmailText, waitMessage, waitSecondMessage } = require('../helpers/gmail'); const { DashboardPage } = require('../pages/dashboard/dashboard-page'); mainTest(qase(187,'PR-1 Edit profile name'), async ({ page }) => { @@ -126,8 +126,7 @@ test.describe(() => { await registerPage.clickOnAcceptTermsCheckbox(); await registerPage.clickOnCreateAccountSecondBtn(); await registerPage.isRegisterEmailCorrect(email); - await page.waitForTimeout(30000); - invite = await getRegisterMessage(email); + invite = await waitMessage(page, email, 40); console.log(invite.inviteUrl); }); @@ -139,7 +138,7 @@ test.describe(() => { await page.goto(invite.inviteUrl); await dashboardPage.fillOnboardingQuestions(); await profilePage.changeEmail(newEmail); - await page.waitForTimeout(30000); + await waitSecondMessage(page, email, 40); const changeEmail = await getRegisterMessage(email); console.log(changeEmail.inviteUrl); await checkNewEmailText(changeEmail.inviteText, randomName, newEmail); diff --git a/tests/signup.spec.js b/tests/signup.spec.js index 82bed7f..7df4905 100644 --- a/tests/signup.spec.js +++ b/tests/signup.spec.js @@ -71,8 +71,7 @@ test.describe(() => { await registerPage.clickOnAcceptTermsCheckbox(); await registerPage.clickOnCreateAccountSecondBtn(); await registerPage.isRegisterEmailCorrect(email); - await page.waitForTimeout(30000); - invite = await getRegisterMessage(email); + invite = await waitMessage(page, email, 40); }); test(qase(28,'ON-1 Sign up with an email address'), async ({ page }) => { diff --git a/tests/survey-questions.spec.js b/tests/survey-questions.spec.js index 9cd4d1f..644a770 100644 --- a/tests/survey-questions.spec.js +++ b/tests/survey-questions.spec.js @@ -92,6 +92,36 @@ test.describe(() => { await dashboardPage.checkDropdownValue('Testing before self-hosting'); }); + test(qase([1812,1814],'Deselect chosen option, Change chosen option'), async ({ page }) => { + const dashboardPage = new DashboardPage(page); + await dashboardPage.selectRadioButton('Work'); + await dashboardPage.selectRadioButton('Work'); + await dashboardPage.checkRadioButtonLabel('Work'); + + await dashboardPage.selectDropdownOptions('Testing before self-hosting'); + await dashboardPage.clickOnNextButton(); + await dashboardPage.selectFigmaTool(); + await dashboardPage.clickOnNextButton(); + await dashboardPage.selectKindOfWork('Development'); + await dashboardPage.selectRole('Team member'); + await dashboardPage.selectTeamSize('11-30'); + await dashboardPage.clickOnNextButton(); + await dashboardPage.selectGetStartedQuestion('Wireframing'); + await dashboardPage.checkRadioImageLabel('Wireframing'); + await dashboardPage.selectGetStartedQuestion('Prototyping'); + await dashboardPage.checkRadioImageLabel('Prototyping'); + }); + + test(qase([1801],'Close and reopen penpot page while questions survey is opened'), async ({ page , context}) => { + const dashboardPage = new DashboardPage(page); + await dashboardPage.isOnboardingFirstQuestionsVisible(); + await page.close(); + const newPage = await context.newPage(); + await newPage.goto(invite.inviteUrl); + const dashboardPage2 = new DashboardPage(newPage); + await dashboardPage2.isOnboardingFirstQuestionsVisible(); + }); + }); test.afterEach(async ({ page }, testInfo) => { await updateTestResults(testInfo.status, testInfo.retry)