Update tests by removing try catch block (#5671)

Signed-off-by: Jasmin <jasmin@hardcoreeng.com>
This commit is contained in:
JasminMus 2024-05-27 18:19:28 +02:00 committed by GitHub
parent 6b48cc17a1
commit 99c5387f19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 290 additions and 295 deletions

View File

@ -5,23 +5,21 @@ import { ApplicationsPage } from '../model/recruiting/applications-page'
import { ApplicationsDetailsPage } from '../model/recruiting/applications-details-page' import { ApplicationsDetailsPage } from '../model/recruiting/applications-details-page'
import { TalentName } from '../model/recruiting/types' import { TalentName } from '../model/recruiting/types'
import { LeftSideMenuPage } from '../model/left-side-menu-page' import { LeftSideMenuPage } from '../model/left-side-menu-page'
// ADDED NEW
test.use({ test.use({
storageState: PlatformSetting storageState: PlatformSetting
}) })
test.describe('Collaborative tests for Application', () => { test.describe('Collaborative tests for Application', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`)
}) })
test.skip('Add comment from several users', async ({ page, browser }) => { test.skip('Add comment from several users', async ({ page, browser }) => {
const vacancyName = 'Software Engineer' const vacancyName = 'Software Engineer'
let talentName: TalentName let talentName: TalentName
// open second page
const { page: userSecondPage, context } = await getSecondPage(browser) const { page: userSecondPage, context } = await getSecondPage(browser)
try {
await test.step('User1. Add collaborators and comment from user1', async () => { await test.step('User1. Add collaborators and comment from user1', async () => {
const navigationMenuPage = new NavigationMenuPage(page) const navigationMenuPage = new NavigationMenuPage(page)
await navigationMenuPage.clickButtonApplications() await navigationMenuPage.clickButtonApplications()
@ -40,7 +38,7 @@ test.describe('Collaborative tests for Application', () => {
}) })
await test.step('User2. Check notification and add comment from user2', async () => { await test.step('User2. Check notification and add comment from user2', async () => {
await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/recruit`)
const leftSideMenuPageSecond = new LeftSideMenuPage(userSecondPage) const leftSideMenuPageSecond = new LeftSideMenuPage(userSecondPage)
await leftSideMenuPageSecond.checkExistNewNotification() await leftSideMenuPageSecond.checkExistNewNotification()
@ -53,7 +51,7 @@ test.describe('Collaborative tests for Application', () => {
// 'You have been added to collaborators' // 'You have been added to collaborators'
// ) // )
await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/recruit`)
const navigationMenuPageSecond = new NavigationMenuPage(userSecondPage) const navigationMenuPageSecond = new NavigationMenuPage(userSecondPage)
await navigationMenuPageSecond.clickButtonApplications() await navigationMenuPageSecond.clickButtonApplications()
@ -78,7 +76,7 @@ test.describe('Collaborative tests for Application', () => {
// 'left a comment' // 'left a comment'
// ) // )
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`)
const navigationMenuPage = new NavigationMenuPage(page) const navigationMenuPage = new NavigationMenuPage(page)
await navigationMenuPage.clickButtonApplications() await navigationMenuPage.clickButtonApplications()
@ -88,9 +86,8 @@ test.describe('Collaborative tests for Application', () => {
const applicationsDetailsPage = new ApplicationsDetailsPage(page) const applicationsDetailsPage = new ApplicationsDetailsPage(page)
await applicationsDetailsPage.checkCommentExist('Test Comment from user2') await applicationsDetailsPage.checkCommentExist('Test Comment from user2')
}) })
} finally {
await userSecondPage.close() await userSecondPage.close()
await context.close() await context.close()
}
}) })
}) })

View File

@ -8,7 +8,7 @@ import { generateId, getSecondPage, PlatformSetting, PlatformURI } from '../util
test.use({ test.use({
storageState: PlatformSetting storageState: PlatformSetting
}) })
// ADDED NEW
test.describe('Collaborative test for issue', () => { test.describe('Collaborative test for issue', () => {
let leftSideMenuPage: LeftSideMenuPage let leftSideMenuPage: LeftSideMenuPage
let issuesPage: IssuesPage let issuesPage: IssuesPage
@ -40,7 +40,12 @@ test.describe('Collaborative test for issue', () => {
// open second page // open second page
const { page: userSecondPage, context } = await getSecondPage(browser) const { page: userSecondPage, context } = await getSecondPage(browser)
try {
const closePages = async (): Promise<void> => {
await userSecondPage.close()
await context.close()
}
await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished() await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished()
// create a new issue by first user // create a new issue by first user
@ -69,10 +74,8 @@ test.describe('Collaborative test for issue', () => {
milestone: 'Milestone', milestone: 'Milestone',
estimation: '2h' estimation: '2h'
}) })
} finally {
await userSecondPage.close() await closePages()
await context.close()
}
}) })
test('Issues status can be changed by another users', async ({ page, browser }) => { test('Issues status can be changed by another users', async ({ page, browser }) => {
@ -84,7 +87,11 @@ test.describe('Collaborative test for issue', () => {
// open second page // open second page
const { page: userSecondPage, context } = await getSecondPage(browser) const { page: userSecondPage, context } = await getSecondPage(browser)
try { const closePages = async (): Promise<void> => {
await userSecondPage.close()
await context.close()
}
if (userSecondPage.url() !== `${PlatformURI}/workbench/sanity-ws/tracker/`) { if (userSecondPage.url() !== `${PlatformURI}/workbench/sanity-ws/tracker/`) {
await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished() await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished()
} }
@ -117,10 +124,8 @@ test.describe('Collaborative test for issue', () => {
...issue, ...issue,
status: 'In Progress' status: 'In Progress'
}) })
} finally {
await userSecondPage.close() await closePages()
await context.close()
}
}) })
test('First user change assignee, second user should see assigned issue', async ({ page, browser }) => { test('First user change assignee, second user should see assigned issue', async ({ page, browser }) => {
@ -132,7 +137,12 @@ test.describe('Collaborative test for issue', () => {
// open second page // open second page
const { page: userSecondPage, context } = await getSecondPage(browser) const { page: userSecondPage, context } = await getSecondPage(browser)
try {
const closePages = async (): Promise<void> => {
await userSecondPage.close()
await context.close()
}
await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished() await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished()
await test.step(`user1. change assignee to ${newAssignee}`, async () => { await test.step(`user1. change assignee to ${newAssignee}`, async () => {
@ -168,9 +178,7 @@ test.describe('Collaborative test for issue', () => {
const issuesDetailsPageSecond = new IssuesDetailsPage(userSecondPage) const issuesDetailsPageSecond = new IssuesDetailsPage(userSecondPage)
await issuesDetailsPageSecond.checkIssue({ ...issue }) await issuesDetailsPageSecond.checkIssue({ ...issue })
}) })
} finally {
await userSecondPage.close() await closePages()
await context.close()
}
}) })
}) })

View File

@ -12,18 +12,17 @@ test.describe('Documents link tests', () => {
title: `Document Public link revoke-${generateId()}`, title: `Document Public link revoke-${generateId()}`,
space: 'Default' space: 'Default'
} }
// ADDED NEW
const newContext = await browser.newContext({ storageState: PlatformSetting }) const newContext = await browser.newContext({ storageState: PlatformSetting })
const page = await newContext.newPage() const page = await newContext.newPage()
try {
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() await page.goto(`${PlatformURI}/workbench/sanity-ws`)
const leftSideMenuPage = new LeftSideMenuPage(page) const leftSideMenuPage = new LeftSideMenuPage(page)
await leftSideMenuPage.clickDocuments() await leftSideMenuPage.clickDocuments()
const documentsPage = new DocumentsPage(page) const documentsPage = new DocumentsPage(page)
await documentsPage.clickOnButtonCreateDocument() await documentsPage.clickOnButtonCreateDocument()
await documentsPage.createDocument(publicLinkDocument) await documentsPage.createDocument(publicLinkDocument)
await documentsPage.openDocument(publicLinkDocument.title) await documentsPage.openDocument(publicLinkDocument.title)
@ -40,10 +39,9 @@ test.describe('Documents link tests', () => {
const clearSession = await browser.newContext() const clearSession = await browser.newContext()
const clearPage = await clearSession.newPage() const clearPage = await clearSession.newPage()
try {
await test.step('Check guest access to the document', async () => { await test.step('Check guest access to the document', async () => {
await clearPage.goto(link) await clearPage.goto(link)
const documentContentClearPage = new DocumentContentPage(clearPage) const documentContentClearPage = new DocumentContentPage(clearPage)
await documentContentClearPage.checkDocumentTitle(publicLinkDocument.title) await documentContentClearPage.checkDocumentTitle(publicLinkDocument.title)
expect(clearPage.url()).toContain('guest') expect(clearPage.url()).toContain('guest')
@ -58,13 +56,10 @@ test.describe('Documents link tests', () => {
await clearPage.goto(link) await clearPage.goto(link)
await expect(clearPage.locator('div.antiPopup > h1')).toHaveText('Public link was revoked') await expect(clearPage.locator('div.antiPopup > h1')).toHaveText('Public link was revoked')
}) })
} finally {
await clearPage.close() await clearPage.close()
await clearSession.close() await clearSession.close()
}
} finally {
await page.close() await page.close()
await newContext.close() await newContext.close()
}
}) })
}) })

View File

@ -8,7 +8,7 @@ import { DocumentContentPage } from '../model/documents/document-content-page'
test.use({ test.use({
storageState: PlatformSetting storageState: PlatformSetting
}) })
// ADDED NEW
test.describe('Documents tests', () => { test.describe('Documents tests', () => {
let leftSideMenuPage: LeftSideMenuPage let leftSideMenuPage: LeftSideMenuPage
let documentsPage: DocumentsPage let documentsPage: DocumentsPage
@ -19,7 +19,7 @@ test.describe('Documents tests', () => {
documentsPage = new DocumentsPage(page) documentsPage = new DocumentsPage(page)
documentContentPage = new DocumentContentPage(page) documentContentPage = new DocumentContentPage(page)
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() await page.goto(`${PlatformURI}/workbench/sanity-ws`)
}) })
test('Create a document', async () => { test('Create a document', async () => {
@ -35,7 +35,7 @@ test.describe('Documents tests', () => {
await documentContentPage.checkDocumentTitle(newDocument.title) await documentContentPage.checkDocumentTitle(newDocument.title)
}) })
test('Edit document', async ({ page }) => { test('Edit document', async () => {
const contentOne = ' * Text first line' const contentOne = ' * Text first line'
const contentTwo = ' * Text second line' const contentTwo = ' * Text second line'
const newDocumentTitle = `Edit Updated Document Title-${generateId()}` const newDocumentTitle = `Edit Updated Document Title-${generateId()}`
@ -43,11 +43,13 @@ test.describe('Documents tests', () => {
title: `Edit Document Title-${generateId()}`, title: `Edit Document Title-${generateId()}`,
space: 'Default' space: 'Default'
} }
await leftSideMenuPage.clickDocuments() await leftSideMenuPage.clickDocuments()
await documentsPage.clickOnButtonCreateDocument() await documentsPage.clickOnButtonCreateDocument()
await documentsPage.createDocument(editDocument) await documentsPage.createDocument(editDocument)
await documentsPage.openDocument(editDocument.title) await documentsPage.openDocument(editDocument.title)
await documentContentPage.checkDocumentTitle(editDocument.title) await documentContentPage.checkDocumentTitle(editDocument.title)
let content = await documentContentPage.addContentToTheNewLine(contentOne) let content = await documentContentPage.addContentToTheNewLine(contentOne)
await documentContentPage.checkContent(content) await documentContentPage.checkContent(content)
content = await documentContentPage.addContentToTheNewLine(contentTwo) content = await documentContentPage.addContentToTheNewLine(contentTwo)
@ -56,7 +58,7 @@ test.describe('Documents tests', () => {
await documentContentPage.checkDocumentTitle(newDocumentTitle) await documentContentPage.checkDocumentTitle(newDocumentTitle)
}) })
test('Move document', async ({ page }) => { test('Move document', async () => {
const contentFirst = 'Text first line' const contentFirst = 'Text first line'
const moveDocument: NewDocument = { const moveDocument: NewDocument = {
title: `Move Document Title-${generateId()}`, title: `Move Document Title-${generateId()}`,
@ -85,12 +87,12 @@ test.describe('Documents tests', () => {
await documentContentPage.checkDocumentTitle(moveDocument.title) await documentContentPage.checkDocumentTitle(moveDocument.title)
}) })
test('Collarabotive edit document content', async ({ page, browser }) => { test('Collaborative edit document content', async ({ page, browser }) => {
let content = '' let content = ''
const contentFirstUser = 'First first!!! This string come from from the first user' const contentFirstUser = 'First first!!! This string comes from the first user'
const contentSecondUser = 'Second second!!! This string come from from the second user' const contentSecondUser = 'Second second!!! This string comes from the second user'
const colDocument: NewDocument = { const colDocument: NewDocument = {
title: `Collarabotive edit Title-${generateId()}`, title: `Collaborative edit Title-${generateId()}`,
space: 'Default' space: 'Default'
} }
@ -107,23 +109,21 @@ test.describe('Documents tests', () => {
await test.step('User2. Add content second user', async () => { await test.step('User2. Add content second user', async () => {
const { page: userSecondPage, context } = await getSecondPage(browser) const { page: userSecondPage, context } = await getSecondPage(browser)
try {
await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished()
await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws`)
const leftSideMenuPageSecond = new LeftSideMenuPage(userSecondPage) const leftSideMenuPageSecond = new LeftSideMenuPage(userSecondPage)
await leftSideMenuPageSecond.clickDocuments() await leftSideMenuPageSecond.clickDocuments()
const documentsPageSecond = new DocumentsPage(userSecondPage) const documentsPageSecond = new DocumentsPage(userSecondPage)
await documentsPageSecond.openTeamspace(colDocument.space) await documentsPageSecond.openTeamspace(colDocument.space)
await documentsPageSecond.openDocument(colDocument.title) await documentsPageSecond.openDocument(colDocument.title)
const documentContentPageSecond = new DocumentContentPage(page) const documentContentPageSecond = new DocumentContentPage(userSecondPage)
await documentContentPageSecond.checkDocumentTitle(colDocument.title) await documentContentPageSecond.checkDocumentTitle(colDocument.title)
await documentContentPageSecond.checkContent(content) await documentContentPageSecond.checkContent(content)
content = await documentContentPageSecond.addContentToTheNewLine(contentSecondUser) content = await documentContentPageSecond.addContentToTheNewLine(contentSecondUser)
await documentContentPageSecond.checkContent(content) await documentContentPageSecond.checkContent(content)
} finally {
await userSecondPage.close() await userSecondPage.close()
await context.close() await context.close()
}
}) })
await test.step('User1. Check final content', async () => { await test.step('User1. Check final content', async () => {
@ -132,7 +132,7 @@ test.describe('Documents tests', () => {
}) })
}) })
test('Add Link to the Document', async ({ page }) => { test('Add Link to the Document', async () => {
const contentLink = 'Lineforthelink' const contentLink = 'Lineforthelink'
const linkDocument: NewDocument = { const linkDocument: NewDocument = {
title: `Links Document Title-${generateId()}`, title: `Links Document Title-${generateId()}`,

View File

@ -17,8 +17,8 @@ test.describe('Tracker public link issues tests', () => {
await test.step('Get public link from popup', async () => { await test.step('Get public link from popup', async () => {
const newContext = await browser.newContext({ storageState: PlatformSetting }) const newContext = await browser.newContext({ storageState: PlatformSetting })
const page = await newContext.newPage() const page = await newContext.newPage()
try {
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() await page.goto(`${PlatformURI}/workbench/sanity-ws`)
const leftSideMenuPage = new LeftSideMenuPage(page) const leftSideMenuPage = new LeftSideMenuPage(page)
await leftSideMenuPage.clickTracker() await leftSideMenuPage.clickTracker()
@ -29,10 +29,9 @@ test.describe('Tracker public link issues tests', () => {
const publicLinkPopup = new PublicLinkPopup(page) const publicLinkPopup = new PublicLinkPopup(page)
link = await publicLinkPopup.getPublicLink() link = await publicLinkPopup.getPublicLink()
} finally {
await page.close() await page.close()
await newContext.close() await newContext.close()
}
}) })
await test.step('Check guest access to the issue', async () => { await test.step('Check guest access to the issue', async () => {
@ -41,7 +40,7 @@ test.describe('Tracker public link issues tests', () => {
await clearSession.clearPermissions() await clearSession.clearPermissions()
const clearPage = await clearSession.newPage() const clearPage = await clearSession.newPage()
try {
await clearPage.goto(link) await clearPage.goto(link)
const clearIssuesDetailsPage = new IssuesDetailsPage(clearPage) const clearIssuesDetailsPage = new IssuesDetailsPage(clearPage)
@ -51,10 +50,9 @@ test.describe('Tracker public link issues tests', () => {
status: 'Backlog' status: 'Backlog'
}) })
expect(clearPage.url()).toContain('guest') expect(clearPage.url()).toContain('guest')
} finally {
await clearPage.close() await clearPage.close()
await clearSession.close() await clearSession.close()
}
}) })
}) })
@ -67,9 +65,9 @@ test.describe('Tracker public link issues tests', () => {
const newContext = await browser.newContext({ storageState: PlatformSetting }) const newContext = await browser.newContext({ storageState: PlatformSetting })
const page = await newContext.newPage() const page = await newContext.newPage()
let link: string let link: string
try {
await test.step('Get public link from popup', async () => { await test.step('Get public link from popup', async () => {
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() await page.goto(`${PlatformURI}/workbench/sanity-ws`)
const leftSideMenuPage = new LeftSideMenuPage(page) const leftSideMenuPage = new LeftSideMenuPage(page)
await leftSideMenuPage.clickTracker() await leftSideMenuPage.clickTracker()
@ -84,7 +82,7 @@ test.describe('Tracker public link issues tests', () => {
const clearSession = await browser.newContext() const clearSession = await browser.newContext()
const clearPage = await clearSession.newPage() const clearPage = await clearSession.newPage()
try {
await test.step('Check guest access to the issue', async () => { await test.step('Check guest access to the issue', async () => {
await clearPage.goto(link) await clearPage.goto(link)
@ -106,13 +104,10 @@ test.describe('Tracker public link issues tests', () => {
await clearPage.goto(link) await clearPage.goto(link)
await expect(clearPage.locator('div.antiPopup > h1')).toHaveText('Public link was revoked') await expect(clearPage.locator('div.antiPopup > h1')).toHaveText('Public link was revoked')
}) })
} finally {
await clearPage.close() await clearPage.close()
await clearSession.close() await clearSession.close()
}
} finally {
await page.close() await page.close()
await newContext.close() await newContext.close()
}
}) })
}) })