Skip to content

Commit

Permalink
move viewer and ocis constructor outside the steps
Browse files Browse the repository at this point in the history
  • Loading branch information
koebel committed Apr 11, 2024
1 parent ca2b944 commit ee3efef
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions tests/e2e/steps/ViewerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { Ocis } from '../pageObjects/Ocis'
import { Viewer } from '../pageObjects/Viewer'
import { uploadFile, delay } from '../utils/helpers'

const ocis = new Ocis()
const viewer = new Viewer()

Given(
'the following 3D models have been uploaded:',
async function (filesForUpload: DataTable): Promise<void> {
Expand All @@ -19,23 +22,20 @@ Given(
'the user has logged in with username {string} and password {string}',
async function (user: string, password: string): Promise<void> {
await global.page.goto(config.baseUrlOcis)
const ocis = new Ocis()
await ocis.login({ username: user, password: password })
}
)

When(
'the user previews the file {string} in the 3D model viewer',
async function (filename: string): Promise<void> {
const ocis = new Ocis()
await ocis.previewFile(filename)
}
)

Then(
'the 3D model {string} should be displayed in the viewport',
async function (filename: string): Promise<void> {
const viewer = new Viewer()
// add some delay to allow model to be loaded
await delay(1000)
// check if the filename is displayed in hidden h1 title element of the viewport
Expand All @@ -47,19 +47,16 @@ Then(
Then(
'the file name {string} should be shown in the topbar',
async function (filename: string): Promise<void> {
const viewer = new Viewer()
const topbarFilename = await viewer.getTopbarResourceName()
expect(topbarFilename).toContain(filename)
}
)

When('the user enters fullscreen mode', async function (): Promise<void> {
const viewer = new Viewer()
await viewer.toggleFullscreenMode()
})

Then('the 3D model should be displayed in fullscreen mode', async function (): Promise<void> {
const viewer = new Viewer()
const viewportWrapperSize = await viewer.getViewportWrapperSize()
const windowInnerSize = await viewer.getWindowInnerSize()
// in fullscreen mode, model viewport wrapper should have same size as browser window
Expand All @@ -68,12 +65,10 @@ Then('the 3D model should be displayed in fullscreen mode', async function (): P
})

When('the user exits fullscreen mode', async function (): Promise<void> {
const viewer = new Viewer()
await viewer.toggleFullscreenMode()
})

Then('the 3D model should be display in standard mode', async function (): Promise<void> {
const viewer = new Viewer()
await viewer.checkStandardDisplayMode()
await viewer.checkTopbarVisibility()
})
Expand All @@ -95,7 +90,6 @@ Then('the size and position of the 3D model will be changed accordingly', functi
})

When('the user resets the viewport', async function (): Promise<void> {
const viewer = new Viewer()
await viewer.resetViewport()
})

Expand All @@ -105,11 +99,9 @@ Then('the 3D model should be display in the default size and position', function
})

When('the user navigates to the next model', async function (): Promise<void> {
const viewer = new Viewer()
await viewer.displayNextModel()
})

When('the user navigates to the previous model', async function (): Promise<void> {
const viewer = new Viewer()
await viewer.displayPreviousModel()
})

0 comments on commit ee3efef

Please sign in to comment.