-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from bible-technology/login_test
playwright login test
- Loading branch information
Showing
12 changed files
with
154 additions
and
1,282 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
export const checkLogInOrNot = async (window, expect) => { | ||
await window.waitForSelector('//*[@id="__next"]/div', '//*[@id="__next"]/div[1]') | ||
const textVisble = await window.locator('//h1["@aria-label=projects"]', { timeout: 3000 }).isVisible() | ||
if (textVisble) { | ||
const title = await window.textContent('[aria-label=projects]') | ||
await expect(title).toBe('Projects') | ||
|
||
} else { | ||
const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') | ||
await expect(welcome).toBe("Welcome!") | ||
await window.reload() | ||
} | ||
return textVisble; | ||
} | ||
|
||
export const filterUser = (json, name) => { | ||
const filtered = json.filter((user) => | ||
user.username.toLowerCase() !== name.toLowerCase() | ||
) | ||
return filtered | ||
} | ||
|
||
export const userJson = async (window, packageInfo, fs, path) => { | ||
const newpath = await window.evaluate(() => Object.assign({}, window.localStorage)) | ||
const file = path.join(newpath.userPath, packageInfo.name, 'users', 'users.json'); | ||
const data = await fs.readFileSync(file); | ||
return JSON.parse(data); | ||
} | ||
|
||
export const userFolder = async (window, userName, packageInfo, path) => { | ||
const newpath = await window.evaluate(() => Object.assign({}, window.localStorage)) | ||
return path.join(newpath.userPath, packageInfo.name, 'users', userName.toLowerCase()) | ||
} | ||
|
||
export const userFile = async (window, packageInfo, path) => { | ||
const newpath = await window.evaluate(() => Object.assign({}, window.localStorage)) | ||
return path.join(newpath.userPath, packageInfo.name, 'users', 'users.json'); | ||
} | ||
|
||
export const removeFolderAndFile = async (fs, folder, userName, json, file) => { | ||
fs.rmSync(folder, { recursive: true, force: true }) | ||
const filtered = json.filter((item) => | ||
item.username.toLowerCase() !== userName.toLowerCase() | ||
) | ||
return await fs.writeFileSync(file, JSON.stringify(filtered)) | ||
} | ||
|
||
export const showLoginPage = async (fs, folder, userName, json, file, window, expect) => { | ||
await removeFolderAndFile(fs, folder, userName, json, file) | ||
const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') | ||
await expect(welcome).toBe("Welcome!") | ||
await window.reload() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<myFixture>({ | ||
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'; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.