From fcaa224e7142e1954355f520599c0e673c954a0a Mon Sep 17 00:00:00 2001 From: bobby Date: Thu, 24 Aug 2023 17:39:45 +0530 Subject: [PATCH 01/15] playwright login test --- e2e-tests/base.test.ts | 892 +----------------- e2e-tests/myFixtures.ts | 33 + e2e-tests/obsStroy.test.ts | 107 --- e2e-tests/textTranslation.test.ts | 296 ------ package.json | 1 - playwright.config.ts | 2 +- .../src/components/Profile/UserProfile.js | 2 +- 7 files changed, 75 insertions(+), 1258 deletions(-) create mode 100644 e2e-tests/myFixtures.ts delete mode 100644 e2e-tests/obsStroy.test.ts delete mode 100644 e2e-tests/textTranslation.test.ts diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index f0f034323..76c11ed24 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -1,11 +1,10 @@ // @ts-check -// import { _electron as electron } from 'playwright'; -import { removeUser } from '../renderer/src/core/Login/removeUser'; -import { test, expect } from '@playwright/test'; +import { test, expect } from './myFixtures'; +import packageInfo from '../package.json'; const fs = require('fs'); -const { _electron: electron } = require('playwright'); +const { _electron: electron } = require('@playwright/test'); let electronApp; let appPath; @@ -19,863 +18,52 @@ test('Check for Scribe Scripture app render', async () => { // await electronApp.close(); }); -test('Create a new user and Navigate the projects page', async () => { - await window.getByRole('button', {name: 'Create New Account'}).click() - await window.getByPlaceholder('Username').fill('playwright user') - await window.click('[type=submit]'); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); -}); - -/* Translation Project */ -test('Click New and Fill translation project page details to create a new project', async () => { - await window.getByRole('link', {name : 'new'}).click() - await window.fill('#project_name', 'translation project'); - await window.fill('#project_description', 'test version'); - await window.fill('#version_abbreviated', 'tv'); - await window.click('#open-advancesettings'); - await window.click('[aria-label=new-testament]'); - await window.click('[aria-label=close-custombiblenavigation]'); - await window.click('[aria-label=create]'); -}); - -// test('Click user and Navigate projects', async () => { -// await window.getByRole('button', {name: "playwright user"}).click() -// const title = await window.textContent('[aria-label=projects]'); -// expect(title).toBe('Projects'); -// }); - - -test('Star the project', async () => { - await window.getByRole('button', {name: 'unstar-project'}).click() -}); - -test('Untar the project', async () => { - await window.getByRole('button', {name: 'star-project'}).click() -}); - -test('Search and test translation for resulting project', async () => { - await window.fill('#search_box', 'translation'); - const projectname = await window.innerText( - '[aria-label=unstar-project-name]', - ); - expect(projectname).toBe('translation project'); -}); - -test('Click on a project to open the editor page for textTranslation', async () => { - await window.click('id=translation project'); - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -test('Check textTranslation project name', async () => { - const projectname = await window.innerText( - '[aria-label=editor-project-name]', - ); - expect(projectname).toBe('TRANSLATION PROJECT'); -}); - -test('Increase font size of textTranslation project', async () => { - await window.click('[aria-label=increase-font]'); - await window.click('[aria-label=increase-font]'); -}); - -test('Decrease font size textTranslation project', async () => { - await window.click('[aria-label=decrease-font]'); - await window.click('[aria-label=decrease-font]'); -}); - -test('Check textTranslation project Notifications', async () => { - await window.getByRole('button', {name: "notification-button"}).click() - const title = await window.innerText('[aria-label=notification-title]'); - expect(title).toBe('NOTIFICATIONS'); - await window.getByRole('button', {name: "close-notification"}).click() - -}); - -test('About and Licence of textTranslation Scribe Scripture', async () => { - await window.click('[aria-label=about-button]'); - const developedby = await window.innerText('[aria-label=developed-by]'); - expect(developedby).toBe('Developed by Bridge Connectivity Solutions'); - await window.click('[aria-label=license-button]'); - await window.click('[aria-label=close-about]'); -}); - -test('Write full name book MAT of textTranslation Scribe Scripture', async () => { - await window.locator('p:has-text("MAT")').fill("MATTHEW") - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -// // test('Add verse in the book of MAT of textTranslation Scribe Scripture', async () => { -// // await window.locator('#ch1v1').click()("MATTHEWThis is the genealogy[a] of Jesus the Messiah[b] the son of David") -// // const editorpane = await window.innerText('[aria-label=editor-pane]'); -// // expect(editorpane).toBe('EDITOR'); -// // }); - -test('Return to projects page', async () => { - await window.getByRole('button', {name: "Back"}).click(); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); -}); - -test('Edit the text translation project along with change target project', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "translation project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('[aria-label=unstar-menu-project]').click() - await window.getByRole('menuitem', {name: "edit-project"}).click() - await window.getByText('test version').fill('edit test version') - await window.locator('input[name="version_abbreviated"]').fill('tvs') - await window.getByRole('button', {name:"save-edit-project"}).click(); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects') - } - - } - - } -}) - - -///Obs translation project -test('Click New and Fill OBS project page details to create a new project.', async () => { - await window.getByRole('link', {name: 'new'}).click() - await window.click('[aria-label=open-popover]') - await window.getByRole('link', {name: 'OBS'}).click() - await window.fill('#project_name', 'Obs project'); - await window.fill('#project_description', 'test version'); - await window.fill('#version_abbreviated', 'op'); - await window.click('[aria-label=create]'); -}) - -test('Create an OBS project with Urdu language and license.', async () => { - await window.getByRole('link', {name: 'new'}).click() - await window.click('[aria-label=open-popover]') - await window.getByRole('link', {name: 'OBS'}).click() - await window.fill('#project_name', 'urdu project'); - await window.fill('#project_description', 'test version'); - await window.fill('#version_abbreviated', 'up'); - //adding a urdu language - await window.getByRole('button', {name: 'add-language'}).click() - await window.locator('input[name="language"]').fill('urdu new') - await window.locator('input[name="code"]').fill('un') - await window.locator('input[type="radio"]').nth(1).click() - await window.getByRole('button', {name: 'edit-language'}).click() - //select a new license - await window.getByRole('button', {name: 'CC BY-SA'}).click() - await window.getByRole('option', {name: 'CC BY'}).click() - await window.click('[aria-label=create]'); -}) - -test('Update the Urdu project', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "urdu project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('[aria-label=unstar-menu-project]').click() - await window.getByRole('menuitem', {name: "edit-project"}).click() - await window.getByText('test version').fill('edit test version') - await window.locator('input[name="version_abbreviated"]').fill('ep') - await window.getByRole('button', {name:"save-edit-project"}).click(); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } - -}) - -test('Star the obs project', async () => { - const table = window.locator('table#tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Obs project") { - console.log(await tds.nth(1).textContent()) - await tds.first().locator('[aria-label=unstar-project]').click() - // expect(await tds.nth(1).textContent()).toBe("Obs project") - } - - } - +test('Check whether the app is being logged IN', async ({userName}) => { + const textVisible = await window.locator('//h1["@aria-label=projects"]').isVisible() + if (textVisible) { + const title = await window.textContent('[aria-label=projects]'); + await expect(title).toBe('Projects') + await window.getByRole('button', {name: "Open user menu"}).click() + const currentUser = await window.textContent('[aria-label="userName"]') + await window.getByRole('menuitem', {name: "Sign out"}).click() + expect(await window.title()).toBe('Scribe Scripture'); + }else { + const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') + expect(welcome).toBe('Welcome!'); } }); -test('Unstar the obs project', async () => { - const table = window.locator('table#tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Obs project") { - console.log(await tds.nth(1).textContent()) - await tds.first().locator('[aria-label=star-project]').click() - // expect(await tds.nth(1).textContent()).toBe("Obs project") - } - } - } -}); - -test('Search and test obs project for resulting project', async () => { - await window.fill('#search_box', 'obs'); - const projectname = await window.innerText( - '[aria-label=unstar-project-name]', - ); - expect(projectname).toBe('Obs project'); -}); - -test('Click on the project to open the OBS editor page', async () => { - await window.click('id=Obs project'); - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -test('Check the OBS project name', async () => { - const projectname = await window.innerText( - '[aria-label=editor-project-name]', - ); - expect(projectname).toBe('OBS PROJECT'); -}); - -test('Increase the font size of the OBS project.', async () => { - await window.click('[aria-label=increase-font]'); - await window.click('[aria-label=increase-font]'); -}); - -test('Decrease the font size of the OBS project.', async () => { - await window.click('[aria-label=decrease-font]'); - await window.click('[aria-label=decrease-font]'); -}); - -test('Check OBS project Notifications', async () => { - await window.getByRole('button', {name: "notification-button"}).click() - const title = await window.innerText('[aria-label=notification-title]'); - expect(title).toBe('NOTIFICATIONS'); - await window.getByRole('button', {name: "close-notification"}).click() - -}); - -test('About and Licence of OBS Scribe Scripture', async () => { - await window.click('[aria-label=about-button]'); - const developedby = await window.innerText('[aria-label=developed-by]'); - expect(developedby).toBe('Developed by Bridge Connectivity Solutions'); - await window.click('[aria-label=license-button]'); - await window.click('[aria-label=close-about]'); -}); - -test('Edit the OBS editor heading title ', async () => { - await window.getByText('1. The Creation').fill("1. The Creation edit"); - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); -test('Add content in verses 1 and 2 OBS editor.', async () => { - await window.locator('div:nth-child(2) > .flex-grow').fill("god created heavens and earth"); - await window.locator('div:nth-child(3) > .flex-grow').fill("story content added in verse 3"); - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -test('Change the obs navigation story from 1 to 12 and edit the title', async () => { - await window.getByRole('button', {name:"obs-navigation"}).click(); - await window.getByRole('button', {name:"12"}).click(); - await window.getByText('12. The Exodus').fill("12. The Exodus edit"); - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -test('Lock/Unlock the OBS editor', async () => { - await window.click('[aria-label=close-lock]'); - await window.click('[aria-label=open-lock]'); - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -test('Change the OBS font-family', async () => { - await window.getByRole('button', {name: "select-menu-file"}).click() - await window.getByRole('none', {name: "selected-font"}).click() - await window.getByRole('option', {name: "aakar"}).click() - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -// test("Add obs panel", async ()=> { -// window.getByRole('button', {name:"add-panels"}).click(); -// let title = await window.innerText('[aria-label=number-of-panels]'); -// expect(title).toBe('1'); -// // await window.click('[aria-label=add-panels]'); -// // title = await window.innerText('[aria-label=number-of-panels]'); -// // expect(title).toBe('2'); - -// // await window.click('[aria-label=add-panels]'); -// // title = await window.innerText('[aria-label=number-of-panels]'); -// // expect(title).toBe('0'); -// }) - -test('Return to the projects page to see all projects have been created already.', async () => { - await window.getByRole('button', {name: "Back"}).click(); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); -}); - -test('Edit the Obs project', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Obs project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('[aria-label=unstar-menu-project]').click() - await window.getByRole('menuitem', {name: "edit-project"}).click() - await window.getByText('test version').fill('edit test version for obs') - await window.locator('input[name="version_abbreviated"]').fill('ep') - await window.getByRole('button', {name:"save-edit-project"}).click(); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } -}) - - -/////Audio project -test('Click New and Fill Audio project page details to create a new project', async () => { - await window.getByRole('link', {name: 'new'}).click() - await window.click('[aria-label=open-popover]') - await window.getByRole('link', {name: 'Audio'}).click() - await window.fill('#project_name', 'Audio project'); - await window.fill('#project_description', 'test version'); - await window.fill('#version_abbreviated', 'ap'); - await window.click('#open-advancesettings'); - await window.click('[aria-label=new-testament]'); - await window.click('[aria-label=close-custombiblenavigation]'); - await window.click('[aria-label=create]'); -}) - -test('Star the audio project', async () => { - const table = window.locator('table#tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Audio project") { - console.log(await tds.nth(1).textContent()) - await tds.first().locator('[aria-label=unstar-project]').click() - // expect(await tds.nth(1).textContent()).toBe("Obs project") - } - } - } -}); - -test('Untar the audio project', async () => { - const table = window.locator('table#tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Audio project") { - console.log(await tds.nth(1).textContent()) - await tds.first().locator('[aria-label=star-project]').click() - // expect(await tds.nth(1).textContent()).toBe("Obs project") - } - } - } - -}); - -test('Search and test audio for resulting project', async () => { - await window.fill('#search_box', 'audio'); - const projectname = await window.innerText( - '[aria-label=unstar-project-name]', - ); - expect(projectname).toBe('Audio project'); -}); - -test('Click on the Audio project to open the editor page.', async () => { - await window.click('id=Audio project'); - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -test('Check the Audio project name', async () => { - const projectname = await window.innerText( - '[aria-label=editor-project-name]', - ); - expect(projectname).toBe('AUDIO PROJECT'); -}); - -test('Increase font size Audio project', async () => { - await window.click('[aria-label=increase-font]'); - await window.click('[aria-label=increase-font]'); -}); - -test('Decrease font size of Audio project', async () => { - await window.click('[aria-label=decrease-font]'); - await window.click('[aria-label=decrease-font]'); -}); - -test('Check Audio projects Notifications', async () => { - await window.getByRole('button', {name: "notification-button"}).click() - const title = await window.innerText('[aria-label=notification-title]'); - expect(title).toBe('NOTIFICATIONS'); - await window.getByRole('button', {name: "close-notification"}).click() - -}); - -test('About and Licence of Audio Scribe Scripture', async () => { - await window.getByRole('button', {name: "about-button"}).click() - const developedby = await window.innerText('[aria-label=developed-by]'); - expect(developedby).toBe('Developed by Bridge Connectivity Solutions'); - await window.getByRole('button', {name: "license-button"}).click() - await window.getByRole('button', {name: "close-about"}).click() -}); - -test('Check Audio book bookmarks and close', async () => { - await window.getByRole('button', {name: "select-menu-file"}).click() - await window.getByRole('button', {name: "select-bookmarks"}).click() - await window.getByRole('button', {name: "close-button"}).click() -}); - -test('Saving bookmark for the Audio book and check the all bookmarks', async ()=>{ - await window.getByRole('button', {name: "save-bookmark"}).click() - await window.getByRole('button', {name: "select-menu-file"}).click() - await window.getByRole('button', {name: "select-bookmarks"}).click() - await window.getByRole('button', {name: "close-button"}).click() - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -} ) - -test('Lock/Unlock the Audio editor', async () => { - await window.getByRole('button', {name: "select-menu-file"}).click() - await window.getByRole('none', {name: "selected-font"}).click() - await window.getByRole('option', {name: "aakar"}).click() - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -test('Record the audio for verse 1', async () => { - await window.getByRole('button', {name: "1"}).first().click() - await window.locator('.flex > div > .p-2').first().click() - await window.waitForTimeout(4000) - await window.locator('div:nth-child(2) > .p-2').first().click() - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}) - -test('Rewind the audio verse 1', async () => { - await window.getByRole('button', {name: "1"}).first().click() - await window.locator('div:nth-child(4) > div > .p-2').first().click() - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}) -test('Playing the audio verse 1', async () => { - await window.getByRole('button', {name: "1"}).first().click() - await window.locator('div:nth-child(4) > div:nth-child(2) > .p-2').first().click() - await window.waitForTimeout(4000) - // const editorpane = await window.innerText('[aria-label=editor-pane]'); - // expect(editorpane).toBe('EDITOR'); -}) - -test('Stop the audio verse 1', async () => { - await window.locator('div:nth-child(3) > .p-2').first().click() - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}) - -test('Increase/Decrease the volume of the audio verse 1', async () => { - await window.getByRole('button', {name: "1"}).first().click(); - // await window.locator('div:nth-child(4) > div:nth-child(2) > .p-2').first().click() - //decrease volume - await window.locator('div:nth-child(4) > div:nth-child(5) > .flex > button').first().click() - await window.locator('div:nth-child(4) > div:nth-child(5) > .flex > button').first().click() - await window.waitForTimeout(1000) - - // increase volume - await window.locator('.flex > button:nth-child(3)').first().click() - await window.locator('.flex > button:nth-child(3)').first().click() - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}) - - -// test('Delete the audio verse 1', async () => { -// await window.getByRole('button', {name: "1"}).first().click() -// await window.locator('.flex div:nth-child(4) > div:nth(2) > .p-2').first().click() -// await window.getByRole('button', {name:"Delete"}) -// const editorpane = await window.innerText('[aria-label=editor-pane]'); -// expect(editorpane).toBe('EDITOR'); -// }) - - - -test('Return and see created projects in projects page', async () => { - await window.getByRole('button', {name: "Back"}).click(); +test('Create a new user and login', async ({userName}) => { + await window.getByRole('button', {name: 'Create New Account'}).click() + await expect(window.locator('//input[@placeholder="Username"]')).toBeVisible() + await expect(window.locator('//button[@type="submit"]')).toBeVisible() + await window.getByPlaceholder('Username').fill(userName) + await window.click('[type=submit]'); + await window.waitForTimeout(2000) const title = await window.textContent('[aria-label=projects]'); expect(title).toBe('Projects'); -}); - -test('Edit the Audio project', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Audio project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('[aria-label=unstar-menu-project]').click() - await window.getByRole('menuitem', {name: "edit-project"}).click() - await window.getByText('test version').fill('edit test version for audio') - await window.locator('input[name="version_abbreviated"]').fill('ep') - await window.getByRole('button', {name:"save-edit-project"}).click(); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } - -}) - -//Export all the project -test('Export the text Translation project in Downloads folder', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "translation project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Export"}).click() - await window.locator('input[name="location"]').fill('/home/bobby/Downloads') - await window.getByRole('button', {name: "Export"}).click() - await window.waitForTimeout(1000) - await window.locator('[aria-label=unstar-arrow-up]').click() - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } -}) - -test('Export the OBS Translation project in Downloads folder', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Obs project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Export"}).click() - await window.locator('input[name="location"]').fill('/home/bobby/Downloads') - await window.getByRole('button', {name: "Export"}).click() - await window.locator('[aria-label=unstar-arrow-up]').click() - await window.waitForTimeout(1000) - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } -}) - -test('Export the Audio Translation project Downloads folder', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Audio project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Export"}).click() - await window.locator('input[name="location"]').fill('/home/bobby/Downloads') - await window.getByRole('button', {name: "Export"}).click() - await window.locator('[aria-label=unstar-arrow-up]').click() - await window.waitForTimeout(1000) - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } }) - -/////Archive projects -/////texttranslation -test('Archive the textTranslation project', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "translation project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Archive"}).click() - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } -}); - - -////OBS -test('Archive the OBS project', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Obs project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Archive"}).click() - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } -}); - - -///audio -test('Archive the Audio project', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Audio project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Archive"}).click() - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - } -}); - -/////Restore the project from archived -test('Restore the textTranslation project from the archive tab and return to the projects', async () => { - await window.getByRole('button', {name: "Archived"}).click() - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "translation project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Restore"}).click() - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Archived Projects'); - } - } - } -}); - -test('Restore the OBS project from the archive tab and return to the projects', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Obs project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Restore"}).click() - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Archived Projects'); - } - } - } -}); - -test('Restore the Audio project from the archive tab and return to the projects', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "Audio project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Restore"}).click() - await window.getByRole('button', {name: 'Active'}).click() - - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - } - } - - } -}); - -/////update the user profile -test('Update user profile', async () => { - await window.getByRole('button', {name: "Open user menu"}).click() - await window.getByRole('menuitem', {name: "Your Profile"}).click() - await window.locator('input[name="given-name"]').fill('Bobby') - await window.locator('input[name="family-name"]').fill('kumar') - await window.locator('input[name="email"]').fill('kumar@gmal.com') - await window.locator('input[name="organization"]').fill('vidya') - await window.locator('input[name="selectedregion"]').fill('india') - await window.getByRole('button', {name: "Save"}).click() -}); - -test("Update the app language for the user english to hindi and than hindi to english", async () => { - await window.getByRole('button', {name: "Open user menu"}).click() - await window.getByRole('menuitem', {name: "Your Profile"}).click() - await window.getByRole('button', {name: "English"}).click() - await window.getByRole('option', {name: "Hindi"}).click() - await window.getByRole('button', {name: "Save"}).click() - await window.getByRole('button', {name: "Hindi"}).click() - await window.getByRole('option', {name: "English"}).click() - await window.getByRole('button', {name: "सहेजें"}).click() -}) - -test('Sign out and return to Autographa app', async () => { - await window.getByRole('button', {name: "Open user menu"}).click() - await window.getByRole('menuitem', {name: "Sign out"}).click() - expect(await window.title()).toBe('Scribe Scripture'); -}); - - -////Login page -test('Click the View More button, see active users in the tab, and click See the project. ',async () => { - await window.getByRole('button', {name: "View More"}).click() - const active = await window.getByRole('tab').allInnerTexts() - expect(active[0]).toBe('Active') - await window.getByRole('tabpanel', {name: "Active"}).getByRole("button", {name: "playwright user"}).click() +test("Delete playwright test user", async ({userName}) => { + const newpath = await window.evaluate(() => Object.assign({}, window.localStorage)) + const path = require('path'); + const folder = path.join(newpath.userPath, packageInfo.name, 'users', userName.toLowerCase()); + const file = path.join(newpath.userPath, packageInfo.name, 'users', 'users.json'); + const data = await fs.readFileSync(file); + const json = JSON.parse(data); const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); -}) - -test('Sign out return app', async () => { + await expect(title).toBe('Projects') await window.getByRole('button', {name: "Open user menu"}).click() + const currentUser = await window.textContent('[aria-label="userName"]') await window.getByRole('menuitem', {name: "Sign out"}).click() expect(await window.title()).toBe('Scribe Scripture'); -}); - -test('Delete the user from the active tab',async () => { - await window.getByRole('button', {name: "View More"}).click() - await window.getByRole('tabpanel', {name: "Active"}).locator('button').click() - const active = await window.getByRole('tab').allInnerTexts() - expect(active[0]).toBe('Active') -}) - -test('Restore the deleted user from Archive tab',async () => { - // await window.getByRole('button', {name: "View More"}).click() - await window.getByRole('tab', {name: "Archived"}).click() - await window.getByRole('tabpanel', {name: "Archived"}).locator('button').click() - const archive = await window.getByRole('tab').allInnerTexts() - expect(archive[1]).toBe('Archived') + if (currentUser && await fs.existsSync(folder)) { + fs.rmSync(folder, {recursive: true, force: true}) + } + console.error('users.json', `${currentUser} data removed from json`); + const filtered = json.filter((item) => + item.username.toLowerCase() !== currentUser.toLowerCase() + ) + return await fs.writeFileSync(file, JSON.stringify(filtered)) }) - -// test('Removing user from backend', async () => { -// // const newpath = await localStorage.getItem('userPath'); -// await removeUser('playwright user') - -// }) \ No newline at end of file + \ No newline at end of file diff --git a/e2e-tests/myFixtures.ts b/e2e-tests/myFixtures.ts new file mode 100644 index 000000000..7c0318327 --- /dev/null +++ b/e2e-tests/myFixtures.ts @@ -0,0 +1,33 @@ +import {test as myTest} from "@playwright/test" + +type myFixture = { + userName: string + textProject: string, + obsProject: string, + audioProject: string, + syncName:string, + doorUser:string, + doorPassword:string, + flavorText:string, + flavorObs:string + textUnderscore:string, + obsUnderscore:string, + obsUrduProject:string, +} +const myFixtureTest = myTest.extend({ + userName : "Playwright user", + textProject: "Translation test project", + obsProject: "Obs test project", + textUnderscore: "Translation_test_project", + obsUnderscore: "Obs_test_project", + audioProject: "Audio test project", + syncName:"Sync_Collab_Test", + doorUser:"bobby", + doorPassword:"Bobby@123", + flavorText: "textTranslation", + flavorObs: "textStories", + obsUrduProject: "Obs urdu project", +}) + +export const test = myFixtureTest; +export { expect } from '@playwright/test'; \ No newline at end of file diff --git a/e2e-tests/obsStroy.test.ts b/e2e-tests/obsStroy.test.ts deleted file mode 100644 index 412dc185f..000000000 --- a/e2e-tests/obsStroy.test.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { test, expect } from '@playwright/test'; - -const fs = require('fs'); -const { _electron: electron } = require('playwright'); - -let electronApp; -let appPath; -let window; - -test('Check for autographa app render', async () => { - electronApp = await electron.launch({ args: ['main/index.js'] }); - appPath = await electronApp.evaluate(async ({ app }) => app.getAppPath()); - window = await electronApp.firstWindow(); - expect(await window.title()).toBe('Autographa'); - // await electronApp.close(); -}); - -test('Click user and Navigate projects', async () => { - await window.click('#bobby'); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); - // await electronApp.close(); -}); - -/* Translation Editor */ -test('Click on project to open editor page', async () => { - await window.click('id=obs project'); - const editorpane = await window.innerText('[aria-label=editor-pane]'); - expect(editorpane).toBe('EDITOR'); -}); - -test('Check project name', async () => { - const projectname = await window.innerText( - '[aria-label=editor-project-name]', - ); - expect(projectname).toBe('OBS PROJECT'); -}); - -test('Testing Notificaton', async () => { - await window.click('[aria-label=notification-button]'); - const title = await window.innerText('[aria-label=notification-title]'); - expect(title).toBe('NOTIFICATIONS'); - await window.click('[aria-label=close-notification]'); -}); - -test('Increase font size', async () => { - await window.click('[aria-label=increase-font]'); -}); - -test('Decrease font size', async () => { - await window.click('[aria-label=decrease-font]'); -}); - -test('Testing About', async () => { - await window.click('[aria-label=about-button]'); - const developedby = await window.innerText('[aria-label=developed-by]'); - expect(developedby).toBe('Developed by Bridge Connectivity Solutions'); - await window.click('[aria-label=license-button]'); - await window.click('[aria-label=close-about]'); -}); - -test('Testing Font Family', async () => { - await window.click('[aria-label=select-menu-file]'); - await window.click('[aria-label=selected-font]'); - await window.click('[aria-label=AnjaliOldLipi]'); -}); - -// test('Checking resources in added panel', async () => { -// await window.click('[aria-label=add-panels]'); -// let title = await window.innerText('[aria-label=number-of-panels]'); -// console.log(title); -// expect(title).toBe('2'); -// await window.hover('[aria-label=resources-panel]'); -// await window.click('[aria-label=resources-selector]'); -// title = await window.innerText('[aria-label=resources-title]'); -// expect(title).toBe('RESOURCES'); -// await window.click('[aria-label=close-resources]'); -// }); - -// test('Testing by adding the panels', async () => { -// await window.click('[aria-label=add-panels]'); -// let title = await window.innerText('[aria-label=number-of-panels]'); -// expect(title).toBe('3'); -// await window.click('[aria-label=add-panels]'); -// title = await window.innerText('[aria-label=number-of-panels]'); -// expect(title).toBe('1'); -// }); - -// test('Checking scroll lock', async () => { -// await window.click('[aria-label=add-panels]'); -// const editoreBookname = await window.innerText( -// '[aria-label=editor-bookname]', -// ); -// const panel = await window.innerText('[aria-label=number-of-panels]'); -// expect(panel).toBe('2'); -// await window.click('[aria-label=close-lock]'); -// const resourceBookname = await window.innerText( -// '[aria-label=resource-bookname]', -// ); -// expect(resourceBookname).toBe(editoreBookname); -// await window.click('[aria-label=open-lock]'); -// }); - -// test.afterAll(async () => { -// await window.context().close(); -// await window.close(); -// }); diff --git a/e2e-tests/textTranslation.test.ts b/e2e-tests/textTranslation.test.ts deleted file mode 100644 index aaea979fc..000000000 --- a/e2e-tests/textTranslation.test.ts +++ /dev/null @@ -1,296 +0,0 @@ -import * as localForage from 'localforage'; -import { test, expect } from '@playwright/test'; - -const fs = require('fs'); -const { _electron: electron } = require('playwright'); - -let electronApp; -let appPath; -let window; - -test('Check for Scribe Scripture app render', async () => { - electronApp = await electron.launch({ args: ['main/index.js'] }); - appPath = await electronApp.evaluate(async ({ app }) => app.getAppPath()); - window = await electronApp.firstWindow(); - expect(await window.title()).toBe('Scribe Scripture'); - // await electronApp.close(); -}); - -// test('Create a new user and Navigate the projects page', async () => { -// await window.getByRole('button', {name: 'Create New Account'}).click() -// await window.getByPlaceholder('Username').fill('playwright user') -// await window.click('[type=submit]'); -// const title = await window.textContent('[aria-label=projects]'); -// expect(title).toBe('Projects'); -// }); - -// test('Click New and Fill translation project page details to create a new project', async () => { -// await window.getByRole('link', {name : 'new'}).click() -// await window.fill('#project_name', 'audio project'); -// await window.fill('#project_description', 'test version'); -// await window.fill('#version_abbreviated', 'test'); -// await window.click('#open-advancesettings'); -// await window.click('[aria-label=new-testament]'); -// await window.click('[aria-label=close-custombiblenavigation]'); -// await window.click('[aria-label=create]'); -// }); - -// test('Archive the textTranslation project', async () => { -// const table = window.locator('table#tablelayout') -// const headers = table.locator('thead') -// console.log(await headers.allTextContents()); - -// const rows = table.locator('tbody tr') -// // const cols = rows.first().locator('td') -// for (let i = 0; i < await rows.count(); i++) { -// const row = rows.nth(i); -// const tds = row.locator('td'); -// for (let j = 0; j < await tds.count(); j++) { -// if (await tds.nth(j).textContent() === "translation project") { -// console.log(await tds.nth(1).textContent()) -// await tds.last().locator('[aria-label=unstar-expand-project]').click() -// await window.locator('.pl-5 > div > div').click() -// await window.getByRole('menuitem', {name: "Archive"}).click() -// const title = await window.textContent('[aria-label=projects]'); -// expect(title).toBe('Projects'); -// } - -// } - -// } -// }); - -// test('Restore the textTranslation project from the archive tab and return to the projects', async () => { -// await window.getByRole('button', {name: "Archived"}).click() -// const table = window.locator('table#tablelayout') -// const headers = table.locator('thead') -// console.log(await headers.allTextContents()); - -// const rows = table.locator('tbody tr') -// // const cols = rows.first().locator('td') -// for (let i = 0; i < await rows.count(); i++) { -// const row = rows.nth(i); -// const tds = row.locator('td'); -// for (let j = 0; j < await tds.count(); j++) { -// if (await tds.nth(j).textContent() === "translation") { -// console.log(await tds.nth(1).textContent()) -// await tds.last().locator('[aria-label=unstar-expand-project]').click() -// await window.locator('.pl-5 > div > div').click() -// await window.getByRole('menuitem', {name: "Restore"}).click() -// expect(await window.locator('[id="__next"] div:has-text("Archived Projects") >> nth=4')); -// } - -// } - -// } -// await window.getByRole('button', {name: 'Active'}).click() -// }); - -test('Export the text Translation project in Downloads folder', async () => { - const table = window.getByTestId('tablelayout') - const headers = table.locator('thead') - console.log(await headers.allTextContents()); - - const rows = table.locator('tbody tr') - // const cols = rows.first().locator('td') - for (let i = 0; i < await rows.count(); i++) { - const row = rows.nth(i); - const tds = row.locator('td'); - for (let j = 0; j < await tds.count(); j++) { - if (await tds.nth(j).textContent() === "audio project") { - console.log(await tds.nth(1).textContent()) - await tds.last().locator('[aria-label=unstar-expand-project]').click() - await window.locator('.pl-5 > div > div').click() - await window.getByRole('menuitem', {name: "Export"}).click() - await window.locator('input[name="location"]').fill('/home/bobby/Downloads') - await window.getByRole('button', {name: "Export"}).click() - } - - } - - } -}) - -// test('Export the OBS Translation project in Downloads folder', async () => { -// const table = window.getByTestId('tablelayout') -// const headers = table.locator('thead') -// console.log(await headers.allTextContents()); - -// const rows = table.locator('tbody tr') -// // const cols = rows.first().locator('td') -// for (let i = 0; i < await rows.count(); i++) { -// const row = rows.nth(i); -// const tds = row.locator('td'); -// for (let j = 0; j < await tds.count(); j++) { -// if (await tds.nth(j).textContent() === "Obs project") { -// console.log(await tds.nth(1).textContent()) -// await tds.last().locator('[aria-label=unstar-expand-project]').click() -// await window.locator('.pl-5 > div > div').click() -// await window.getByRole('menuitem', {name: "Export"}).click() -// await window.locator('input[name="location"]').fill('/home/bobby/Downloads') -// await window.getByRole('button', {name: "Export"}).click() -// } - -// } - -// } -// }) - -// test('Export the Audio Translation project Downloads folder', async () => { -// const table = window.getByTestId('tablelayout') -// const headers = table.locator('thead') -// console.log(await headers.allTextContents()); - -// const rows = table.locator('tbody tr') -// // const cols = rows.first().locator('td') -// for (let i = 0; i < await rows.count(); i++) { -// const row = rows.nth(i); -// const tds = row.locator('td'); -// for (let j = 0; j < await tds.count(); j++) { -// if (await tds.nth(j).textContent() === "Obs project") { -// console.log(await tds.nth(1).textContent()) -// await tds.last().locator('[aria-label=unstar-expand-project]').click() -// await window.locator('.pl-5 > div > div').click() -// await window.getByRole('menuitem', {name: "Export"}).click() -// await window.locator('input[name="location"]').fill('/home/bobby/Downloads') -// await window.getByRole('button', {name: "Export"}).click() -// } - -// } - -// } -// }) - -// test('Click user and Navigate projects', async () => { -// await window.click('#bobby'); -// const title = await window.textContent('[aria-label=projects]'); -// expect(title).toBe('Projects'); -// // await electronApp.close(); -// }); - - -/* Translation Editor */ -// test('Click on project to open editor page', async () => { -// await window.click('id=translation testing'); -// const editorpane = await window.innerText('[aria-label=editor-pane]'); -// expect(editorpane).toBe('EDITOR'); -// }); - -// test('Check project name', async () => { -// const projectname = await window.innerText( -// '[aria-label=editor-project-name]', -// ); -// expect(projectname).toBe('TRANSLATION TESTING'); -// }); - -// test('Increase font size', async () => { -// await window.click('[aria-label=increase-font]'); -// }); - -// test('Decrease font size', async () => { -// await window.click('[aria-label=decrease-font]'); -// }); - -// test('Saving bookmark and Testing bookmarks window', async () => { -// await window.click('[aria-label=save-bookmark]'); -// await window.click('[aria-label=select-menu-file]'); -// await window.click('[aria-label=select-bookmarks]'); -// await window.click('[aria-label=close-button]'); -// await window.click('[aria-label=save-bookmark]'); -// }); - -// test('Testing Navigation', async () => { -// await window.click('[aria-label=open-book]'); -// const title = await window.innerText('text=NEW'); -// expect(title).toBe('NEW TESTAMENT'); -// await window.click('[aria-label=nt-Mark]'); -// // const label = await window.click('role=presentation[aria-label="nt-Mark"]'); -// // await window.click('text=1'); -// // await window.click('text=1'); - -// // expect(developedby).toBe('Developed by Bridge Connectivity Solutions'); -// }); - -// test('Testing About', async () => { -// await window.click('[aria-label=about-button]'); -// const developedby = await window.innerText('[aria-label=developed-by]'); -// expect(developedby).toBe('Developed by Bridge Connectivity Solutions'); -// await window.click('[aria-label=license-button]'); -// await window.click('[aria-label=close-about]'); -// }); - -// test('Testing Section Heading', async () => { -// await window.click('[aria-label=select-menu-edit]'); -// await window.click('[aria-label=section-header]'); -// }); - -// test('Testing Font Family', async () => { -// await window.click('[aria-label=select-menu-file]'); -// await window.click('[aria-label=selected-font]'); -// await window.click('[aria-label=AnjaliOldLipi]'); -// }); - -// test('Testing Notificaton', async () => { -// await window.click('[aria-label=notification-button]'); -// const title = await window.innerText('[aria-label=notification-title]'); -// expect(title).toBe('NOTIFICATIONS'); -// await window.click('[aria-label=close-notification]'); -// }); - -// test('Testing by adding the panels', async () => { -// await window.click('[aria-label=add-panels]'); -// let title = await window.innerText('[aria-label=number-of-panels]'); -// expect(title).toBe('2'); -// await window.click('[aria-label=add-panels]'); -// title = await window.innerText('[aria-label=number-of-panels]'); -// expect(title).toBe('3'); -// await window.click('[aria-label=add-panels]'); -// title = await window.innerText('[aria-label=number-of-panels]'); -// expect(title).toBe('1'); -// }); - -// test('Checking resources in added panel', async () => { -// await window.click('[aria-label=add-panels]'); -// let title = await window.innerText('[aria-label=number-of-panels]'); -// console.log(title); -// expect(title).toBe('1'); -// await window.hover('[aria-label=resources-panel]'); -// await window.click('[aria-label=resources-selector]'); -// title = await window.innerText('[aria-label=resources-title]'); -// expect(title).toBe('RESOURCES'); -// await window.click('[aria-label=close-resources]'); -// }); - -// test('Testing Resource Select', async () => { -// await window.click('[aria-label=resources-selector]'); -// const title = await window.textContent('[aria-label=resources-title]'); -// expect(title).toBe('Resources'); -// await window.click('#tn'); -// // await window.click('#English'); -// console.log(title); -// }); - -// test('Checking scroll lock/unlock', async () => { -// await window.click('[aria-label=close-lock]'); -// const editoreBookname = await window.innerText( -// '[aria-label=editor-bookname]', -// ); -// const resourceBookname = await window.innerText( -// '[aria-label=resource-bookname]', -// ); -// expect(resourceBookname).toBe(editoreBookname); -// await window.click('[aria-label=open-lock]'); -// }); - -// test.afterAll(async () => { -// await window.context().close(); -// await window.close(); -// }); - -// test('Restore the OBS project from the archive tab and return to the projects', async () => { -// await window.getByRole('button', {name: "Archived"}).click() -// await window.click('[aria-label=unstar-expand-project]') -// await window.click('[aria-label=unstar-menu-project]') -// await window.getByRole('menuitem', {name: "Restore"}).click() -// await window.getByRole('button', {name: 'Active'}).click() -// }); \ No newline at end of file diff --git a/package.json b/package.json index f70d4af80..4888e0921 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,6 @@ "jest": "^26.6.3", "jest-dom": "^4.0.0", "null-loader": "^4.0.1", - "playwright": "^1.22.2", "postcss": "^8.4.21", "prettier": "^2.8.3", "tailwindcss": "^3.2.4" diff --git a/playwright.config.ts b/playwright.config.ts index bcff6288d..a0f2c66ae 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -6,7 +6,7 @@ const config: PlaywrightTestConfig = { timeout: 5 * 60 * 1000, globalTimeout: 60 * 60 * 1000, // Run all tests in parallel. - fullyParallel: true, + fullyParallel: false, retries: 3, use: { // trace: 'on-first-retry', // record traces on first retry of each test diff --git a/renderer/src/components/Profile/UserProfile.js b/renderer/src/components/Profile/UserProfile.js index 278ac6978..02445ce09 100644 --- a/renderer/src/components/Profile/UserProfile.js +++ b/renderer/src/components/Profile/UserProfile.js @@ -62,7 +62,7 @@ const UserProfile = (_username) => { static className="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" > -
+
From 0718edd8a9ac133851e346a354b1eca537faa3bb Mon Sep 17 00:00:00 2001 From: bobby Date: Wed, 30 Aug 2023 11:02:14 +0530 Subject: [PATCH 02/15] app is being logged or not --- e2e-tests/base.test.ts | 66 +++++++------------ jsconfig.json | 2 + playwright.config.ts | 2 +- renderer/src/components/Login/LeftLogin.js | 3 +- .../src/components/Profile/UserProfile.js | 2 +- renderer/src/core/Login/removeUser.js | 18 ++--- 6 files changed, 35 insertions(+), 58 deletions(-) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 76c11ed24..791e1b577 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -10,60 +10,38 @@ let electronApp; let appPath; let window; -test('Check for Scribe Scripture app render', async () => { +test.beforeEach(async () => { electronApp = await electron.launch({ args: ['main/index.js'] }); - appPath = await electronApp.evaluate(async ({ app }) => app.getAppPath()); + appPath = await electronApp.evaluate(async ({ app }) => { + // This runs in the main Electron process, parameter here is always + // the result of the require('electron') in the main app script + return app.getAppPath(); + }); + console.log(appPath); window = await electronApp.firstWindow(); expect(await window.title()).toBe('Scribe Scripture'); - // await electronApp.close(); -}); + await window.waitForSelector('//*[@id="__next"]/div[1]', '//*[@id="__next"]/div') -test('Check whether the app is being logged IN', async ({userName}) => { - const textVisible = await window.locator('//h1["@aria-label=projects"]').isVisible() - if (textVisible) { - const title = await window.textContent('[aria-label=projects]'); - await expect(title).toBe('Projects') - await window.getByRole('button', {name: "Open user menu"}).click() - const currentUser = await window.textContent('[aria-label="userName"]') - await window.getByRole('menuitem', {name: "Sign out"}).click() - expect(await window.title()).toBe('Scribe Scripture'); - }else { - const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') - expect(welcome).toBe('Welcome!'); - } }); -test('Create a new user and login', async ({userName}) => { - await window.getByRole('button', {name: 'Create New Account'}).click() - await expect(window.locator('//input[@placeholder="Username"]')).toBeVisible() - await expect(window.locator('//button[@type="submit"]')).toBeVisible() - await window.getByPlaceholder('Username').fill(userName) - await window.click('[type=submit]'); - await window.waitForTimeout(2000) - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); -}) - -test("Delete playwright test user", async ({userName}) => { +test('Check whether the app is being logged IN', async ({userName}) => { const newpath = await window.evaluate(() => Object.assign({}, window.localStorage)) const path = require('path'); const folder = path.join(newpath.userPath, packageInfo.name, 'users', userName.toLowerCase()); const file = path.join(newpath.userPath, packageInfo.name, 'users', 'users.json'); const data = await fs.readFileSync(file); const json = JSON.parse(data); - const title = await window.textContent('[aria-label=projects]'); - await expect(title).toBe('Projects') - await window.getByRole('button', {name: "Open user menu"}).click() - const currentUser = await window.textContent('[aria-label="userName"]') - await window.getByRole('menuitem', {name: "Sign out"}).click() - expect(await window.title()).toBe('Scribe Scripture'); - if (currentUser && await fs.existsSync(folder)) { - fs.rmSync(folder, {recursive: true, force: true}) + const textVisble = await window.locator('//h1["@aria-label=projects"]').isVisible() + + if (textVisble) { + const title = await window.textContent('[aria-label=projects]') + console.log('user is Logged In') + await expect(title).toBe('Projects') + + }else { + const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') + console.log('user is not Logged In') + await expect(welcome).toBe("Welcome!") } - console.error('users.json', `${currentUser} data removed from json`); - const filtered = json.filter((item) => - item.username.toLowerCase() !== currentUser.toLowerCase() - ) - return await fs.writeFileSync(file, JSON.stringify(filtered)) -}) - \ No newline at end of file +}); + diff --git a/jsconfig.json b/jsconfig.json index 854bf172d..d716d235c 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,6 +1,8 @@ { "compilerOptions": { "baseUrl": ".", + "resolveJsonModule": true, + "esModuleInterop": true, "paths": { "@/icons/*": [ "public/icons/*" diff --git a/playwright.config.ts b/playwright.config.ts index a0f2c66ae..59d4653b1 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -12,7 +12,7 @@ const config: PlaywrightTestConfig = { // trace: 'on-first-retry', // record traces on first retry of each test // Run browser in headless mode. - headless: false, + // headless: false, }, expect: { timeout: 60 * 1000, diff --git a/renderer/src/components/Login/LeftLogin.js b/renderer/src/components/Login/LeftLogin.js index c237bc302..7bc0ece3c 100644 --- a/renderer/src/components/Login/LeftLogin.js +++ b/renderer/src/components/Login/LeftLogin.js @@ -186,10 +186,11 @@ const LeftLogin = () => { Welcome back! Login to access Scribe Scripture

-
+
{sortedUsers?.filter(filterUsers).slice(0, 5).map((user) => (
{ static className="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" > -
+
diff --git a/renderer/src/core/Login/removeUser.js b/renderer/src/core/Login/removeUser.js index 119c2a846..e0c9ce4c9 100644 --- a/renderer/src/core/Login/removeUser.js +++ b/renderer/src/core/Login/removeUser.js @@ -1,23 +1,19 @@ // import * as localforage from 'localforage'; -import * as logger from '../../logger'; import packageInfo from '../../../../package.json'; export const removeUser = async (userName) => { const newpath = await localStorage.getItem('userPath'); const fs = window.require('fs'); const path = require('path'); - const folder = path.join(newpath, packageInfo.name, 'users', `${userName}`); + const folder = path.join(newpath, packageInfo.name, 'users', userName.toLowerCase()); const file = path.join(newpath, packageInfo.name, 'users', 'users.json'); - if (fs.existsSync(folder)) { - await fs.rmdir(folder, (err) => { - if (err) { throw err; } - logger.error('users.json', 'Directory removed'); - }); - logger.error('users.json', 'removing data from json'); const data = await fs.readFileSync(file); const json = JSON.parse(data); - const filtered = json.filter((item) => item.username.toLowerCase() !== userName.toLowerCase()); - await fs.writeFileSync(file, JSON.stringify(json)); - return filtered; + const existData = await fs.existsSync(folder); + if (existData) { + fs.rmSync(folder, { recursive: true, force: true }); } + // console.error('users.json', `${userName} data removed from json`); + const filtered = json.filter((item) => item.username.toLowerCase() !== userName.toLowerCase()); + await fs.writeFileSync(file, JSON.stringify(filtered)); }; From 8973d4a80f43b3463c00018525f9202fa231fc4e Mon Sep 17 00:00:00 2001 From: bobby Date: Wed, 30 Aug 2023 11:17:33 +0530 Subject: [PATCH 03/15] If logged IN then logout and delete user --- e2e-tests/base.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 791e1b577..653184ec8 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -37,6 +37,25 @@ test('Check whether the app is being logged IN', async ({userName}) => { const title = await window.textContent('[aria-label=projects]') console.log('user is Logged In') await expect(title).toBe('Projects') + await window.getByRole('button', {name: "Open user menu"}).click() + const currentUser = await window.textContent('[aria-label="userName"]') + if(currentUser !== userName.toLowerCase()){ + await window.getByRole('menuitem', {name: "Sign out"}).click() + console.log('user is not playwright user') + }else{ + await window.getByRole('menuitem', {name: "Sign out"}).click() + if (currentUser === userName.toLowerCase() && await fs.existsSync(folder)) { + fs.rmSync(folder, {recursive: true, force: true}) + + } + console.error('users.json', `${userName} data removed from json`); + const filtered = json.filter((item) => + item.username.toLowerCase() !== userName.toLowerCase() + ) + console.log('user is playwright user') + expect(await window.title()).toBe('Scribe Scripture'); + await fs.writeFileSync(file, JSON.stringify(filtered)) + } }else { const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') From c2943dd2fb1f298b48efc8c351d6addb9d1d079a Mon Sep 17 00:00:00 2001 From: bobby Date: Thu, 31 Aug 2023 11:31:36 +0530 Subject: [PATCH 04/15] recode app is being logged in or not --- e2e-tests/base.test.ts | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 653184ec8..4352431c9 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -37,30 +37,10 @@ test('Check whether the app is being logged IN', async ({userName}) => { const title = await window.textContent('[aria-label=projects]') console.log('user is Logged In') await expect(title).toBe('Projects') - await window.getByRole('button', {name: "Open user menu"}).click() - const currentUser = await window.textContent('[aria-label="userName"]') - if(currentUser !== userName.toLowerCase()){ - await window.getByRole('menuitem', {name: "Sign out"}).click() - console.log('user is not playwright user') - }else{ - await window.getByRole('menuitem', {name: "Sign out"}).click() - if (currentUser === userName.toLowerCase() && await fs.existsSync(folder)) { - fs.rmSync(folder, {recursive: true, force: true}) - - } - console.error('users.json', `${userName} data removed from json`); - const filtered = json.filter((item) => - item.username.toLowerCase() !== userName.toLowerCase() - ) - console.log('user is playwright user') - expect(await window.title()).toBe('Scribe Scripture'); - await fs.writeFileSync(file, JSON.stringify(filtered)) - } }else { const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') console.log('user is not Logged In') await expect(welcome).toBe("Welcome!") } -}); - +}); \ No newline at end of file From 7230ee4d32e6af7e709e6100828ccaff6d073712 Mon Sep 17 00:00:00 2001 From: Bobbykumar706584 Date: Sun, 3 Sep 2023 15:54:15 +0530 Subject: [PATCH 05/15] if user logged in then delete --- e2e-tests/base.test.ts | 67 +++++++++++++++++++++++++++++++++++------- yarn.lock | 12 -------- 2 files changed, 57 insertions(+), 22 deletions(-) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 4352431c9..62806e7e9 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -10,7 +10,8 @@ let electronApp; let appPath; let window; -test.beforeEach(async () => { + +test("Render the scribe application", async () => { electronApp = await electron.launch({ args: ['main/index.js'] }); appPath = await electronApp.evaluate(async ({ app }) => { // This runs in the main Electron process, parameter here is always @@ -22,10 +23,24 @@ test.beforeEach(async () => { expect(await window.title()).toBe('Scribe Scripture'); await window.waitForSelector('//*[@id="__next"]/div[1]', '//*[@id="__next"]/div') +}) + +test('Check whether the app is being logged IN', async ({ userName }) => { + const textVisble = await window.locator('//h1["@aria-label=projects"]').isVisible() + if (textVisble) { + const title = await window.textContent('[aria-label=projects]') + console.log('user is Logged In') + await expect(title).toBe('Projects') + + } else { + const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') + console.log('user is not Logged In') + await expect(welcome).toBe("Welcome!") + } }); -test('Check whether the app is being logged IN', async ({userName}) => { - const newpath = await window.evaluate(() => Object.assign({}, window.localStorage)) +test('If logged IN then logout and delete that user from the backend', async ({ userName }) => { + const newpath = await window.evaluate(() => Object.assign({}, window.localStorage)) const path = require('path'); const folder = path.join(newpath.userPath, packageInfo.name, 'users', userName.toLowerCase()); const file = path.join(newpath.userPath, packageInfo.name, 'users', 'users.json'); @@ -35,12 +50,44 @@ test('Check whether the app is being logged IN', async ({userName}) => { if (textVisble) { const title = await window.textContent('[aria-label=projects]') - console.log('user is Logged In') + await expect(title).toBe('Projects') - - }else { - const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') - console.log('user is not Logged In') - await expect(welcome).toBe("Welcome!") + await window.getByRole('button', { name: "Open user menu" }).click() + const currentUser = await window.textContent('[aria-label="userName"]') + if (currentUser !== userName.toLowerCase()) { + await window.getByRole('menuitem', { name: "Sign out" }).click() + console.log(`current user is not a ${userName}`) + } else { + await window.getByRole('menuitem', { name: "Sign out" }).click() + if (currentUser === userName.toLowerCase() && await fs.existsSync(folder)) { + fs.rmSync(folder, { recursive: true, force: true }) + + } + console.error('users.json', `${userName} data removed from json`); + const filtered = json.filter((item) => + item.username.toLowerCase() !== userName.toLowerCase() + ) + console.log(`user is ${userName}`) + await fs.writeFileSync(file, JSON.stringify(filtered)) + expect(await window.title()).toBe('Scribe Scripture'); + } + + } else { + if (await window.locator('//*[@id="playwright user"]').isVisible()) { + if (userName.toLowerCase() && await fs.existsSync(folder)) { + fs.rmSync(folder, { recursive: true, force: true }) + + } + console.error('users.json', `${userName} data removed from json`); + const filtered = json.filter((item) => + item.username.toLowerCase() !== userName.toLowerCase() + ) + console.log(`user is ${userName}`) + await fs.writeFileSync(file, JSON.stringify(filtered)) + expect(await window.title()).toBe('Scribe Scripture'); + } else { + const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') + await expect(welcome).toBe("Welcome!") + } } -}); \ No newline at end of file +}); diff --git a/yarn.lock b/yarn.lock index 03cc4d26d..21f10b3ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16269,23 +16269,11 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" -playwright-core@1.27.1: - version "1.27.1" - resolved "https://registry.npmjs.org/playwright-core/-/playwright-core-1.27.1.tgz" - integrity sha512-9EmeXDncC2Pmp/z+teoVYlvmPWUC6ejSSYZUln7YaP89Z6lpAaiaAnqroUt/BoLo8tn7WYShcfaCh+xofZa44Q== - playwright-core@1.36.2: version "1.36.2" resolved "https://registry.npmjs.org/playwright-core/-/playwright-core-1.36.2.tgz" integrity sha512-sQYZt31dwkqxOrP7xy2ggDfEzUxM1lodjhsQ3NMMv5uGTRDsLxU0e4xf4wwMkF2gplIxf17QMBCodSFgm6bFVQ== -playwright@^1.22.2: - version "1.27.1" - resolved "https://registry.npmjs.org/playwright/-/playwright-1.27.1.tgz" - integrity sha512-xXYZ7m36yTtC+oFgqH0eTgullGztKSRMb4yuwLPl8IYSmgBM88QiB+3IWb1mRIC9/NNwcgbG0RwtFlg+EAFQHQ== - dependencies: - playwright-core "1.27.1" - plist@^3.0.1, plist@^3.0.4: version "3.0.6" resolved "https://registry.npmjs.org/plist/-/plist-3.0.6.tgz" From 7ea9dfaac49946ae6dde7c4fd45a2fa5b3e3bcee Mon Sep 17 00:00:00 2001 From: Bobbykumar706584 Date: Sun, 3 Sep 2023 15:55:53 +0530 Subject: [PATCH 06/15] create a new user --- e2e-tests/base.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 62806e7e9..4b4f8cc62 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -91,3 +91,13 @@ test('If logged IN then logout and delete that user from the backend', async ({ } } }); + +test('Create a new user and login', async ({ userName }) => { + await window.getByRole('button', { name: 'Create New Account' }).click() + await expect(window.locator('//input[@placeholder="Username"]')).toBeVisible() + await window.getByPlaceholder('Username').fill(userName) + await expect(window.locator('//button[@type="submit"]')).toBeVisible() + await window.click('[type=submit]'); + const title = await window.textContent('[aria-label=projects]'); + expect(title).toBe('Projects'); +}) \ No newline at end of file From 12a47ff5133d042092b8eca905b6ffc46150340d Mon Sep 17 00:00:00 2001 From: Bobbykumar706584 Date: Mon, 4 Sep 2023 10:26:55 +0530 Subject: [PATCH 07/15] logout and delete user test --- e2e-tests/base.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 4b4f8cc62..d886b67e3 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -100,4 +100,27 @@ test('Create a new user and login', async ({ userName }) => { await window.click('[type=submit]'); const title = await window.textContent('[aria-label=projects]'); expect(title).toBe('Projects'); +}) + +test("Logout and delete that user from the backend", async ({ userName }) => { + const newpath = await window?.evaluate(() => Object.assign({}, window.localStorage)) + const path = require('path'); + const folder = path.join(newpath.userPath, packageInfo.name, 'users', userName.toLowerCase()); + const file = path.join(newpath.userPath, packageInfo.name, 'users', 'users.json'); + const data = await fs.readFileSync(file); + const json = JSON.parse(data); + const title = await window.textContent('[aria-label=projects]'); + await expect(title).toBe('Projects') + await window.getByRole('button', { name: "Open user menu" }).click() + const currentUser = await window.textContent('[aria-label="userName"]') + await window.getByRole('menuitem', { name: "Sign out" }).click() + expect(await window.title()).toBe('Scribe Scripture'); + if (userName && await fs.existsSync(folder)) { + fs.rmSync(folder, { recursive: true, force: true }) + } + console.error('users.json', `${userName} data removed from json`); + const filtered = json.filter((item) => + item.username.toLowerCase() !== currentUser.toLowerCase() + ) + await fs.writeFileSync(file, JSON.stringify(filtered)) }) \ No newline at end of file From 95bf8b314f9cd257685a50e41160dec2b73c7bfa Mon Sep 17 00:00:00 2001 From: Bobbykumar706584 Date: Tue, 5 Sep 2023 16:10:12 +0530 Subject: [PATCH 08/15] delete playwright user on load --- e2e-tests/base.test.ts | 37 ++++++++++++---------- renderer/src/components/Login/LeftLogin.js | 2 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index d886b67e3..3f195c0ed 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -11,7 +11,7 @@ let appPath; let window; -test("Render the scribe application", async () => { +test("Start the scribe application", async () => { electronApp = await electron.launch({ args: ['main/index.js'] }); appPath = await electronApp.evaluate(async ({ app }) => { // This runs in the main Electron process, parameter here is always @@ -58,6 +58,7 @@ test('If logged IN then logout and delete that user from the backend', async ({ await window.getByRole('menuitem', { name: "Sign out" }).click() console.log(`current user is not a ${userName}`) } else { + /// projects page then logout and delete playwright user await window.getByRole('menuitem', { name: "Sign out" }).click() if (currentUser === userName.toLowerCase() && await fs.existsSync(folder)) { fs.rmSync(folder, { recursive: true, force: true }) @@ -70,28 +71,30 @@ test('If logged IN then logout and delete that user from the backend', async ({ console.log(`user is ${userName}`) await fs.writeFileSync(file, JSON.stringify(filtered)) expect(await window.title()).toBe('Scribe Scripture'); + await window.reload() } } else { - if (await window.locator('//*[@id="playwright user"]').isVisible()) { - if (userName.toLowerCase() && await fs.existsSync(folder)) { - fs.rmSync(folder, { recursive: true, force: true }) + ///loging page, if playwright user exist then onload app remove + const filtered = json.filter((item) => + item.username.toLowerCase() !== userName.toLowerCase() + ) + if (filtered && await fs.existsSync(folder)) { + fs.rmSync(folder, { recursive: true, force: true }) - } - console.error('users.json', `${userName} data removed from json`); - const filtered = json.filter((item) => - item.username.toLowerCase() !== userName.toLowerCase() - ) - console.log(`user is ${userName}`) - await fs.writeFileSync(file, JSON.stringify(filtered)) - expect(await window.title()).toBe('Scribe Scripture'); - } else { - const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') - await expect(welcome).toBe("Welcome!") } + console.error('users.json', `${userName} data removed from json`); + + console.log(`user is ${userName}`) + await fs.writeFileSync(file, JSON.stringify(filtered)) + await window.reload() + const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') + await expect(welcome).toBe("Welcome!") } + }); + test('Create a new user and login', async ({ userName }) => { await window.getByRole('button', { name: 'Create New Account' }).click() await expect(window.locator('//input[@placeholder="Username"]')).toBeVisible() @@ -102,6 +105,7 @@ test('Create a new user and login', async ({ userName }) => { expect(title).toBe('Projects'); }) + test("Logout and delete that user from the backend", async ({ userName }) => { const newpath = await window?.evaluate(() => Object.assign({}, window.localStorage)) const path = require('path'); @@ -115,7 +119,7 @@ test("Logout and delete that user from the backend", async ({ userName }) => { const currentUser = await window.textContent('[aria-label="userName"]') await window.getByRole('menuitem', { name: "Sign out" }).click() expect(await window.title()).toBe('Scribe Scripture'); - if (userName && await fs.existsSync(folder)) { + if (userName.toLowerCase() && await fs.existsSync(folder)) { fs.rmSync(folder, { recursive: true, force: true }) } console.error('users.json', `${userName} data removed from json`); @@ -123,4 +127,5 @@ test("Logout and delete that user from the backend", async ({ userName }) => { item.username.toLowerCase() !== currentUser.toLowerCase() ) await fs.writeFileSync(file, JSON.stringify(filtered)) + await window.reload() }) \ No newline at end of file diff --git a/renderer/src/components/Login/LeftLogin.js b/renderer/src/components/Login/LeftLogin.js index 7bc0ece3c..539e88751 100644 --- a/renderer/src/components/Login/LeftLogin.js +++ b/renderer/src/components/Login/LeftLogin.js @@ -381,7 +381,7 @@ const LeftLogin = () => { )}
{newOpen && ( - {text} + {text} )}