Skip to content

Commit

Permalink
chore: update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-greffe committed Mar 26, 2024
1 parent 89a3e3c commit 87ef269
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 33 deletions.
25 changes: 14 additions & 11 deletions test/app.test.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/* eslint-disable no-unused-expressions */

import faker from 'faker'
import { expect } from 'chai'

import chai, { util, expect } from 'chai'
import chailint from 'chai-lint'
import { core } from '@kalisio/kdk/test.client.js'
import { createDocument, deleteDocumentItem, deleteDocumentCard } from './document.mjs'

const suite = 'app'

describe(suite, () => {
describe(`suite:${suite}`, () => {
let runner
let page
let user

before(async () => {
chailint(chai, util)

runner = new core.Runner(suite, {
appName: 'kapp',
browser: {
Expand All @@ -35,26 +37,27 @@ describe(suite, () => {
await core.register(page, user)
})

it('check-profile', async () => {
await core.manageAccount(page, 'profile')
await core.manageAccount(page, 'security')
await core.manageAccount(page, 'danger-zone')
it('update profile', async () => {
await core.updateAccountProfile(page, 'My new name', runner.getDataPath('avatar.png'))
user.name = 'My new name'
await core.clickOpener(page, 'left')
expect(await runner.captureAndMatch('profile')).beTrue()
})

it('check-collections', async () => {
await core.clickLeftPaneAction(page, 'collection', 1000)
await core.clickPaneAction(page, 'left', 'collection', 1000)
const nbDocuments = await core.countItems(page, 'collection/KItem')
const doc1 = { name: faker.name.findName() }
await createDocument(page, doc1)
expect((nbDocuments + 1) === await core.countItems(page, 'collection/KItem')).to.true
await core.clickTopPaneAction(page, 'grid', 1000)
await core.clickAction(page, 'grid', 1000)
const doc2 = { name: faker.name.findName() }
await createDocument(page, doc2)
expect((nbDocuments + 2) === await core.countItems(page, 'collection/KCard')).to.true
await core.clickTopPaneAction(page, 'list', 1000)
await core.clickAction(page, 'list', 1000)
await deleteDocumentItem(page, doc1)
expect((nbDocuments + 1) === await core.countItems(page, 'collection/KItem')).to.true
await core.clickTopPaneAction(page, 'grid', 1000)
await core.clickAction(page, 'grid', 1000)
await deleteDocumentCard(page, doc2)
expect(nbDocuments === await core.countItems(page, 'collection/KCard')).to.true
})
Expand Down
Binary file added test/data/app/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/data/app/screenrefs/profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/data/misc/screenrefs/misc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 23 additions & 20 deletions test/layout.test.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
/* eslint-disable no-unused-expressions */

import { expect } from 'chai'
import chai, { util, expect } from 'chai'
import chailint from 'chai-lint'
import { core } from '@kalisio/kdk/test.client.js'

const suite = 'layout'

describe(suite, () => {
describe(`suite:${suite}`, () => {
let runner
let page
let user
const placements = ['left', 'top', 'right', 'bottom']

before(async () => {
chailint(chai, util)

runner = new core.Runner(suite, {
appName: 'kapp',
browser: {
Expand All @@ -32,47 +35,47 @@ describe(suite, () => {
})

it('check-header-footer', async () => {
expect(await core.isHeaderVisible(page)).be.true
expect(await core.isFooterVisible(page)).be.false
expect(await core.isHeaderVisible(page)).beTrue()
expect(await core.isFooterVisible(page)).beFalse()
await core.clickAction(page, 'toggle-header')
expect(await core.isHeaderVisible(page)).be.false
expect(await core.isHeaderVisible(page)).beFalse()
await core.clickAction(page, 'toggle-footer')
expect(await core.isFooterVisible(page)).be.true
expect(await core.isFooterVisible(page)).beTrue()
})

it('check-panes', async () => {
await core.clickPaneAction(page, 'top', 'panes')
expect(await core.isPaneVisible(page, 'top')).be.true
expect(await core.isPaneVisible(page, 'right')).be.false
expect(await core.isPaneVisible(page, 'bottom')).be.false
expect(await core.isPaneVisible(page, 'left')).be.false
expect(await core.isPaneVisible(page, 'top')).beTrue()
expect(await core.isPaneVisible(page, 'right')).beFalse()
expect(await core.isPaneVisible(page, 'bottom')).beFalse()
expect(await core.isPaneVisible(page, 'left')).beFalse()
await core.clickAction(page, 'toggle-top-pane')
expect(await core.isPaneVisible(page, 'top')).be.false
expect(await core.isPaneVisible(page, 'top')).beFalse()
await core.clickAction(page, 'toggle-right-pane')
expect(await core.isPaneVisible(page, 'right')).be.true
expect(await core.isPaneVisible(page, 'right')).beTrue()
await core.clickAction(page, 'toggle-bottom-pane')
expect(await core.isPaneVisible(page, 'bottom')).be.true
expect(await core.isPaneVisible(page, 'bottom')).beTrue()
await core.clickAction(page, 'toggle-left-pane')
expect(await core.isPaneVisible(page, 'left')).be.true
expect(await core.isPaneVisible(page, 'left')).beTrue()
})

it('check-windows', async () => {
await core.clickPaneAction(page, 'top', 'windows')
for (const placement of placements) {
expect(await core.isWindowVisible(page, placement)).be.false
expect(await core.isWindowVisible(page, placement)).beFalse()
}
for (const placement of placements) {
await core.clickAction(page, `toggle-${placement}-window`)
expect(await core.isWindowVisible(page, placement)).be.true
expect(await core.isWindowVisible(page, placement)).beTrue()
const isFloating = await core.isWindowFloating(page, placement)
if (isFloating) await core.pinWindow(page, placement)
expect(await core.isWindowPinned(page, placement)).be.true
expect(await core.isWindowPinned(page, placement)).beTrue()
await core.maximizeWindow(page, placement)
expect(await core.isWindowMaximized(page, placement)).be.true
expect(await core.isWindowMaximized(page, placement)).beTrue()
await core.restoreWindow(page, placement)
expect(await core.isWindowPinned(page, placement)).be.true
expect(await core.isWindowPinned(page, placement)).beTrue()
await core.closeWindow(page, placement)
expect(await core.isWindowVisible(page, placement)).be.false
expect(await core.isWindowVisible(page, placement)).beFalse()
}
})

Expand Down
6 changes: 5 additions & 1 deletion test/misc.test.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import chai, { util, expect } from 'chai'
import chailint from 'chai-lint'
import { core } from '@kalisio/kdk/test.client.js'

const suite = 'misc'

describe(suite, () => {
describe(`suite:${suite}`, () => {
let runner
let page
let user

before(async () => {
chailint(chai, util)

runner = new core.Runner(suite, {
appName: 'kapp',
browser: {
Expand Down
2 changes: 1 addition & 1 deletion test/webpush.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type, clickAction } from '@kalisio/kdk/test/client/core/utils.js';

const suite = 'webpush'

describe(suite, () => {
describe(`suite:${suite}`, () => {
let runner
let page
let user
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5111,6 +5111,11 @@ eslint@^8.10.0, eslint@^8.41.0:
strip-ansi "^6.0.1"
text-table "^0.2.0"

esm@^3.2.25:
version "3.2.25"
resolved "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10"
integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==

espree@^9.3.1, espree@^9.6.0, espree@^9.6.1:
version "9.6.1"
resolved "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f"
Expand Down

0 comments on commit 87ef269

Please sign in to comment.