mirror of
https://github.com/penpot/penpotqa.git
synced 2024-07-06 04:51:46 +00:00
1806,1807,1808,1809,1810,1811,1802,1813,1805,1803,1804,1815 tests added
This commit is contained in:
parent
2e9716c691
commit
e3f6326a64
|
@ -38,11 +38,13 @@ async function listMessages(auth, email) {
|
|||
const spamMessages = await searchMessages('SPAM', email);
|
||||
const messages = [...inboxMessages, ...spamMessages];
|
||||
|
||||
const msg = await gmail.users.messages.get({
|
||||
userId: 'me',
|
||||
id: messages[0].id,
|
||||
});
|
||||
return Buffer.from(msg.data.payload.parts[0].parts[0].body.data, 'base64').toString('utf-8');
|
||||
if(messages.length > 0) {
|
||||
const msg = await gmail.users.messages.get({
|
||||
userId: 'me',
|
||||
id: messages[0].id,
|
||||
});
|
||||
return Buffer.from(msg.data.payload.parts[0].parts[0].body.data, 'base64').toString('utf-8');
|
||||
}
|
||||
}
|
||||
|
||||
async function messagesCount(auth, email, count) {
|
||||
|
@ -76,18 +78,20 @@ async function checkMessagesCount(email, count) {
|
|||
async function getRegisterMessage(email) {
|
||||
return authorize().then(async (auth) => {
|
||||
const body = await listMessages(auth, email);
|
||||
const urlRegex = /(https?:\/\/[^\s]+)/;
|
||||
const match = body.match(urlRegex);
|
||||
if (match) {
|
||||
const url = match[0];
|
||||
const remainingText = body.replace(url, '').trim();
|
||||
return {
|
||||
inviteUrl: url,
|
||||
inviteText: remainingText
|
||||
};
|
||||
} else {
|
||||
console.log('No URL found in the text.');
|
||||
return null;
|
||||
if (body) {
|
||||
const urlRegex = /(https?:\/\/[^\s]+)/;
|
||||
const match = body.match(urlRegex);
|
||||
if (match) {
|
||||
const url = match[0];
|
||||
const remainingText = body.replace(url, '').trim();
|
||||
return {
|
||||
inviteUrl: url,
|
||||
inviteText: remainingText,
|
||||
};
|
||||
} else {
|
||||
console.log('No URL found in the text.');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}).catch(console.error);
|
||||
}
|
||||
|
@ -152,5 +156,25 @@ async function checkNewEmailText(text, name, newEmail) {
|
|||
await expect(text).toBe(messageText);
|
||||
}
|
||||
|
||||
module.exports = {checkInviteText, getRegisterMessage, checkRegisterText, checkRecoveryText, checkNewEmailText, checkMessagesCount};
|
||||
async function waitMessage(page , email, timeoutSec= 40) {
|
||||
const timeout = timeoutSec*1000;
|
||||
const interval = 4000;
|
||||
const startTime = Date.now();
|
||||
let invite;
|
||||
|
||||
await page.waitForTimeout(interval);
|
||||
while (Date.now() - startTime < timeout) {
|
||||
invite = await getRegisterMessage(email);
|
||||
if (invite) {
|
||||
return invite;
|
||||
}
|
||||
await page.waitForTimeout(interval);
|
||||
}
|
||||
|
||||
if (!invite.inviteUrl) {
|
||||
throw new Error('Timeout reached: invite.inviteUrl is still undefined');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {checkInviteText, getRegisterMessage, checkRegisterText, checkRecoveryText, checkNewEmailText, checkMessagesCount, waitMessage};
|
||||
|
||||
|
|
|
@ -198,6 +198,10 @@ exports.BasePage = class BasePage {
|
|||
await this.page.keyboard.press('Enter');
|
||||
}
|
||||
|
||||
async clickOnESC() {
|
||||
await this.page.keyboard.press('Escape');
|
||||
}
|
||||
|
||||
async isHeaderDisplayed(title) {
|
||||
await expect(this.header).toHaveText(title);
|
||||
}
|
||||
|
|
|
@ -136,9 +136,18 @@ exports.DashboardPage = class DashboardPage extends BasePage {
|
|||
this.onboardingContinueBtn = page.locator('button[class="main_ui_onboarding_newsletter__accept-btn"]');
|
||||
this.onboardingHeader = page.locator('h1[data-test="onboarding-welcome"]');
|
||||
this.planingToUsingDropdown = page.locator('div[class*="custom-select"]');
|
||||
this.planingToUsingDropdownLabel = page.locator('div[class*="custom-select"] span').first();
|
||||
this.planingOtherInput = page.locator('#planning-other');
|
||||
this.toolOtherInput = page.locator('#experience-design-tool-other[type="text"]');
|
||||
this.responsabilityOtherInput = page.locator('#role-other');
|
||||
this.roleOtherInput = page.locator('#responsability-other');
|
||||
this.startWithOtherInput = page.locator('#start-with-other[type="text"]');
|
||||
this.refererOtherInput = page.locator('#referer-other[type="text"]');
|
||||
this.nextButton = page.locator('button[label="Next"]');
|
||||
this.previousButton = page.locator('button[class*="prev-button"]');
|
||||
this.startButton = page.locator('button[label="Start"]');
|
||||
this.figmaTool = page.locator('//input[@id="experience-design-tool-figma"]/..');
|
||||
this.toolsButton = page.locator('label[class*="components_forms__radio-label-image"]');
|
||||
this.otherRole = page.locator('label[for="role-other"]').first();
|
||||
this.otherRoleInput = page.locator('input[id="role-other"][type="text"]');
|
||||
this.onboardingNewsHeader = page.locator('*[data-test="onboarding-newsletter-title"]');
|
||||
|
@ -149,6 +158,8 @@ exports.DashboardPage = class DashboardPage extends BasePage {
|
|||
this.onboardingContinueWithoutTeamBtn = page.locator('button[class*="onboarding_team_choice__accept-button"]').nth(1);
|
||||
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.onboardingPaginator = page.locator('div[class*="onboarding_questions__paginator"]');
|
||||
|
||||
this.onboardingFirstHeader = page.locator('*[class*="onboarding_questions__modal-title"]');
|
||||
}
|
||||
|
@ -629,6 +640,10 @@ exports.DashboardPage = class DashboardPage extends BasePage {
|
|||
await this.nextButton.click();
|
||||
}
|
||||
|
||||
async clickOnPrevButton() {
|
||||
await this.previousButton.click();
|
||||
}
|
||||
|
||||
async clickOnStartButton() {
|
||||
await this.startButton.click();
|
||||
}
|
||||
|
@ -719,6 +734,10 @@ exports.DashboardPage = class DashboardPage extends BasePage {
|
|||
await this.clickOnStartButton();
|
||||
}
|
||||
|
||||
async isOnboardingFirstQuestionsVisible() {
|
||||
await expect(this.onboardingFirstHeader).toHaveText('Help us get to know you');
|
||||
}
|
||||
|
||||
async selectRadioButton(name) {
|
||||
await this.page.locator(`label[class*="radio-label"]:has-text("${name}") span`).first().click();
|
||||
}
|
||||
|
@ -733,6 +752,24 @@ exports.DashboardPage = class DashboardPage extends BasePage {
|
|||
await optionSelector.click();
|
||||
}
|
||||
|
||||
async selectLastDropdownOptions() {
|
||||
await this.planingToUsingDropdown.click();
|
||||
const optionSelector = await this.page.locator(`li span[class*="select__label"]`).last();
|
||||
await optionSelector.click();
|
||||
}
|
||||
|
||||
async selectLastTool() {
|
||||
await this.toolsButton.last().click();
|
||||
}
|
||||
|
||||
async checkDropdownValue(value) {
|
||||
await expect(this.planingToUsingDropdownLabel).toHaveText(value);
|
||||
}
|
||||
|
||||
async checkRadioButtonLabel(value) {
|
||||
await expect(this.selectedRadioButtonLabel).toHaveText(value);
|
||||
}
|
||||
|
||||
async selectKindOfWork(option) {
|
||||
await this.planingToUsingDropdown.first().click();
|
||||
const optionSelector = await this.page.locator(`li span:has-text("${option}")`);
|
||||
|
@ -750,4 +787,84 @@ exports.DashboardPage = class DashboardPage extends BasePage {
|
|||
? await this.onboardingContinueWithoutTeamBtn.click()
|
||||
: null;
|
||||
}
|
||||
|
||||
async isPlaningOtherInputVisible() {
|
||||
await expect(this.planingOtherInput).toBeVisible();
|
||||
}
|
||||
|
||||
async enterPlaningOther(value) {
|
||||
await this.planingOtherInput.fill(value);
|
||||
}
|
||||
|
||||
async isToolOtherInputVisible() {
|
||||
await expect(this.toolOtherInput).toBeVisible();
|
||||
}
|
||||
|
||||
async enterOtherToolName(value) {
|
||||
await this.toolOtherInput.fill(value);
|
||||
}
|
||||
|
||||
async isRoleOtherInputVisible() {
|
||||
await expect(this.roleOtherInput).toBeVisible();
|
||||
}
|
||||
|
||||
async enterOtherRoleName(value) {
|
||||
await this.roleOtherInput.fill(value);
|
||||
}
|
||||
|
||||
async isStartWithOtherInputVisible() {
|
||||
await expect(this.startWithOtherInput).toBeVisible();
|
||||
}
|
||||
|
||||
async enterOtherStartWith(value) {
|
||||
await this.startWithOtherInput.fill(value);
|
||||
}
|
||||
|
||||
async isKindOfWorkOtherInputVisible() {
|
||||
await expect(this.responsabilityOtherInput).toBeVisible();
|
||||
}
|
||||
|
||||
async enterOtherKindOfWork(value) {
|
||||
await this.responsabilityOtherInput.fill(value);
|
||||
}
|
||||
|
||||
async isReferOtherInputVisible() {
|
||||
await expect(this.refererOtherInput).toBeVisible();
|
||||
}
|
||||
|
||||
async enterOtherRefer(value) {
|
||||
await this.refererOtherInput.fill(value);
|
||||
}
|
||||
|
||||
async isNextBtnDisabled() {
|
||||
await expect(this.nextButton).toBeDisabled();
|
||||
}
|
||||
|
||||
async isStartBtnDisabled() {
|
||||
await expect(this.startButton).toBeDisabled();
|
||||
}
|
||||
|
||||
async selectLastKindOfWork() {
|
||||
await this.planingToUsingDropdown.first().click();
|
||||
const optionSelector = await this.page.locator(`li span[class*="select__label"]`).last();
|
||||
await optionSelector.click();
|
||||
}
|
||||
|
||||
async selectLastRole() {
|
||||
await this.planingToUsingDropdown.nth(1).click();
|
||||
const optionSelector = await this.page.locator(`li span[class*="select__label"]`).last();
|
||||
await optionSelector.click();
|
||||
}
|
||||
|
||||
async selectLastGetStartedQuestion() {
|
||||
await this.page.locator(`span[class*="forms__image-text"]`).last().click();
|
||||
}
|
||||
|
||||
async selectLastRadioButton() {
|
||||
await this.page.locator(`label[class*="radio-label"] span`).last().click();
|
||||
}
|
||||
|
||||
async checkPageNumber(number) {
|
||||
await expect(this.onboardingPaginator).toHaveText(`${number}/5`);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@ const { RegisterPage } = require('../pages/register-page');
|
|||
const { updateTestResults } = require('./../helpers/saveTestResults.js');
|
||||
const { qase } = require('playwright-qase-reporter/dist/playwright');
|
||||
const { random } = require('../helpers/string-generator');
|
||||
const { getRegisterMessage, checkRegisterText, checkRecoveryText } = require('../helpers/gmail');
|
||||
const { getRegisterMessage, checkRegisterText, waitMessage } = require('../helpers/gmail');
|
||||
const { DashboardPage } = require('../pages/dashboard/dashboard-page');
|
||||
const { TeamPage } = require('../pages/dashboard/team-page');
|
||||
const { ProfilePage } = require('../pages/profile-page');
|
||||
|
@ -73,7 +73,6 @@ test.describe(() => {
|
|||
await registerPage.isRegisterEmailCorrect(email);
|
||||
await page.waitForTimeout(30000);
|
||||
invite = await getRegisterMessage(email);
|
||||
console.log(invite.inviteUrl);
|
||||
});
|
||||
|
||||
test(qase(28,'ON-1 Sign up with an email address'), async ({ page }) => {
|
||||
|
@ -87,18 +86,6 @@ test.describe(() => {
|
|||
const dashboardPage = new DashboardPage(page);
|
||||
const teamPage = new TeamPage(page);
|
||||
await page.goto(invite.inviteUrl);
|
||||
// await dashboardPage.isOnboardingNextBtnDisplayed();
|
||||
// await dashboardPage.clickOnOnboardingNextBtn();
|
||||
// await dashboardPage.checkOnboardingWelcomeHeader('Before you start');
|
||||
// await dashboardPage.clickOnOnboardingNextBtn();
|
||||
// await dashboardPage.selectPlaningToUsing('Start to work on my project');
|
||||
// await dashboardPage.clickOnNextButton();
|
||||
// await dashboardPage.fillSecondOnboardPage('none', 'some', 'a-lot');
|
||||
// await dashboardPage.selectFigmaTool();
|
||||
// await dashboardPage.clickOnNextButton();
|
||||
// await dashboardPage.selectOnboardingOtherRole('QA');
|
||||
// await dashboardPage.selectTeamSize('11-30');
|
||||
// await dashboardPage.clickOnStartButton();
|
||||
await dashboardPage.fillOnboardingFirstQuestions();
|
||||
await dashboardPage.isOnboardingNewsHeaderDisplayed();
|
||||
await dashboardPage.isOnboardingNewsUpdatesCheckboxDisplayed();
|
||||
|
|
98
tests/survey-questions.spec.js
Normal file
98
tests/survey-questions.spec.js
Normal file
|
@ -0,0 +1,98 @@
|
|||
const { test } = require('@playwright/test');
|
||||
const { LoginPage } = require('../pages/login-page');
|
||||
const { RegisterPage } = require('../pages/register-page');
|
||||
const { updateTestResults } = require('./../helpers/saveTestResults.js');
|
||||
const { qase } = require('playwright-qase-reporter/dist/playwright');
|
||||
const { random } = require('../helpers/string-generator');
|
||||
const { waitMessage } = require('../helpers/gmail');
|
||||
const { DashboardPage } = require('../pages/dashboard/dashboard-page');
|
||||
|
||||
test.describe(() => {
|
||||
let randomName,email,invite;
|
||||
test.beforeEach(async ({ page }, testInfo) => {
|
||||
await testInfo.setTimeout(testInfo.timeout + 30000);
|
||||
randomName = random().concat('autotest');
|
||||
email = `${process.env.GMAIL_NAME}+${randomName}@gmail.com`;
|
||||
const loginPage = new LoginPage(page);
|
||||
const registerPage = new RegisterPage(page);
|
||||
await loginPage.goto();
|
||||
await loginPage.acceptCookie();
|
||||
await loginPage.clickOnCreateAccount();
|
||||
await registerPage.isRegisterPageOpened();
|
||||
await registerPage.enterEmail(email);
|
||||
await registerPage.enterPassword(process.env.LOGIN_PWD);
|
||||
await registerPage.clickOnCreateAccountBtn();
|
||||
|
||||
await registerPage.enterFullName(randomName);
|
||||
await registerPage.clickOnAcceptTermsCheckbox();
|
||||
await registerPage.clickOnCreateAccountSecondBtn();
|
||||
await registerPage.isRegisterEmailCorrect(email);
|
||||
invite = await waitMessage(page, email, 40);
|
||||
await page.goto(invite.inviteUrl);
|
||||
});
|
||||
|
||||
test(qase([1803,1804,1806,1807,1808,1809,1810,1811,1815],'Question - "Other" option at final place, Click "Next" button with empty "Other" text field'), async ({ page }) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.checkPageNumber(1);
|
||||
await dashboardPage.selectRadioButton('Work');
|
||||
await dashboardPage.selectLastDropdownOptions();
|
||||
await dashboardPage.checkDropdownValue('Other');
|
||||
await dashboardPage.isPlaningOtherInputVisible();
|
||||
await dashboardPage.isNextBtnDisabled();
|
||||
await dashboardPage.enterPlaningOther('test');
|
||||
await dashboardPage.clickOnNextButton();
|
||||
await dashboardPage.checkPageNumber(2);
|
||||
await dashboardPage.isNextBtnDisabled();
|
||||
await dashboardPage.selectLastTool();
|
||||
await dashboardPage.isToolOtherInputVisible();
|
||||
await dashboardPage.isNextBtnDisabled();
|
||||
await dashboardPage.enterOtherToolName('test tool');
|
||||
await dashboardPage.clickOnNextButton();
|
||||
await dashboardPage.checkPageNumber(3);
|
||||
await dashboardPage.selectLastKindOfWork();
|
||||
await dashboardPage.isKindOfWorkOtherInputVisible();
|
||||
await dashboardPage.selectLastRole();
|
||||
await dashboardPage.isRoleOtherInputVisible();
|
||||
await dashboardPage.enterOtherKindOfWork('test');
|
||||
await dashboardPage.enterOtherRoleName('test role');
|
||||
await dashboardPage.selectTeamSize('11-30');
|
||||
await dashboardPage.clickOnNextButton();
|
||||
await dashboardPage.checkPageNumber(4);
|
||||
await dashboardPage.selectLastGetStartedQuestion();
|
||||
await dashboardPage.isStartWithOtherInputVisible();
|
||||
await dashboardPage.isNextBtnDisabled();
|
||||
await dashboardPage.enterOtherStartWith('test');
|
||||
await dashboardPage.clickOnNextButton();
|
||||
await dashboardPage.checkPageNumber(5);
|
||||
await dashboardPage.selectLastRadioButton();
|
||||
await dashboardPage.isReferOtherInputVisible();
|
||||
await dashboardPage.isStartBtnDisabled();
|
||||
await dashboardPage.enterOtherRefer('test');
|
||||
await dashboardPage.clickOnStartButton();
|
||||
await dashboardPage.isOnboardingNewsHeaderDisplayed();
|
||||
});
|
||||
|
||||
test(qase([1802,1813],'Reload the page while questions survey is opened, Press "ESC" button to close question slides'), async ({ page }) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.selectRadioButton('Work');
|
||||
await dashboardPage.selectLastDropdownOptions();
|
||||
await dashboardPage.reloadPage();
|
||||
await dashboardPage.isOnboardingFirstQuestionsVisible();
|
||||
await dashboardPage.clickOnESC();
|
||||
await dashboardPage.isOnboardingFirstQuestionsVisible();
|
||||
});
|
||||
|
||||
test(qase([1805],'Select any option, click "Next" button and comebacks to previous question'), async ({ page }) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.selectRadioButton('Work');
|
||||
await dashboardPage.selectDropdownOptions('Testing before self-hosting');
|
||||
await dashboardPage.clickOnNextButton();
|
||||
await dashboardPage.clickOnPrevButton();
|
||||
await dashboardPage.checkRadioButtonLabel('Work');
|
||||
await dashboardPage.checkDropdownValue('Testing before self-hosting');
|
||||
});
|
||||
|
||||
});
|
||||
test.afterEach(async ({ page }, testInfo) => {
|
||||
await updateTestResults(testInfo.status, testInfo.retry)
|
||||
});
|
Loading…
Reference in New Issue
Block a user