Skip to content

Commit

Permalink
trying to make functions in Ocis.ts static
Browse files Browse the repository at this point in the history
  • Loading branch information
koebel committed Apr 3, 2024
1 parent 38082fb commit 4624076
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
32 changes: 16 additions & 16 deletions tests/e2e/pageObjects/Ocis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import config from '../config'
import util from 'util'

export class Ocis {
page: Page = state.page
elements: Readonly<Record<string, string>> = {
static page: Page = state.page
static elements: Readonly<Record<string, string>> = {

userNameSelector: '#oc-login-username',
passwordSelector: '#oc-login-password',
loginButtonSelector: 'button[type="submit"]',
Expand All @@ -18,25 +19,24 @@ export class Ocis {
resourceNameSelector: '#files-space-table [data-test-resource-name="%s"]'
}

//static
async login({ username, password }): Promise<void> {
await this.page.locator(this.elements.userNameSelector).fill(username)
await this.page.locator(this.elements.passwordSelector).fill(password)
await this.page.locator(this.elements.loginButtonSelector).click()
await this.page.locator(this.elements.webContentSelector).waitFor()
static async login({ username, password }): Promise<void> {
await Ocis.page.locator(this.elements.userNameSelector).fill(username)
await Ocis.page.locator(this.elements.passwordSelector).fill(password)
await Ocis.page.locator(this.elements.loginButtonSelector).click()
await Ocis.page.locator(this.elements.webContentSelector).waitFor()
}

async logout(): Promise<void> {
await this.page.locator(this.elements.userMenuButtonSelector).click()
await this.page.locator(this.elements.logoutSelector).click()
static async logout(): Promise<void> {
await Ocis.page.locator(this.elements.userMenuButtonSelector).click()
await Ocis.page.locator(this.elements.logoutSelector).click()
}

async uploadFile(filename: string): Promise<void> {
await this.page.locator(this.elements.resourceUploadButton).click()
await this.page
static async uploadFile(filename: string): Promise<void> {
await Ocis.page.locator(this.elements.resourceUploadButton).click()
await Ocis.page
.locator(this.elements.fileUploadInput)
.setInputFiles(`${config.assets}/${filename}`)
await this.page.locator(this.elements.uploadInfoCloseButton).click()
await this.page.locator(util.format(this.elements.resourceNameSelector, filename)).waitFor()
await Ocis.page.locator(this.elements.uploadInfoCloseButton).click()
await Ocis.page.locator(util.format(this.elements.resourceNameSelector, filename)).waitFor()
}
}
6 changes: 2 additions & 4 deletions tests/e2e/steps/ViewerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ Given(
'the user has logged in with username {string} and password {string}',
async function (user: string, password: string): Promise<void> {
const page = state.page
const ocis = new Ocis()
await page.goto(config.baseUrlOcis)
await ocis.login({ username: user, password: password })
await Ocis.login({ username: user, password: password })
}
)

Given(
'the user has uploaded the following 3D models:',
async function (filesForUpload: DataTable): Promise<void> {
const ocis = new Ocis()
for (const file of filesForUpload.hashes()) {
await ocis.uploadFile(file.filename)
await Ocis.uploadFile(file.filename)
}
}
)
Expand Down

0 comments on commit 4624076

Please sign in to comment.