Slight tauri e2e cleanup (#2659)

* WIP: Break the tauri e2e tests apart
Will fix #2658

* Clean up

* Longer before timeout

* Also exclude tauri tests from vitest

* Utils fn back in app.spec.ts

* Remove utils

* Change before back to it

* Remove explicit mocha dep

* Revert other attemps at fixing the browser issues. mocha dep was the issue

* Clean up

* Signin/out sep with auth flows

* Lint

---------

Co-authored-by: Frank Noirot <frank@zoo.dev>
This commit is contained in:
Pierre Jacquier
2024-06-18 14:01:39 -04:00
committed by GitHub
parent 2386ba24e5
commit a79e365c0f
4 changed files with 31 additions and 21 deletions

View File

@ -319,7 +319,7 @@ PS: for the debug panel, the following JSON is useful for snapping the camera
``` ```
yarn install yarn install
yarn build:wasm yarn build:wasm-dev
cp src/wasm-lib/pkg/wasm_lib_bg.wasm public cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
yarn vite build --mode development yarn vite build --mode development
yarn tauri build --debug -b yarn tauri build --debug -b

View File

@ -2,6 +2,7 @@ import { browser, $, expect } from '@wdio/globals'
import fs from 'fs/promises' import fs from 'fs/promises'
import path from 'path' import path from 'path'
import os from 'os' import os from 'os'
import { click, setDatasetValue } from '../utils'
const isWin32 = os.platform() === 'win32' const isWin32 = os.platform() === 'win32'
const documentsDir = path.join(os.homedir(), 'Documents') const documentsDir = path.join(os.homedir(), 'Documents')
@ -15,25 +16,8 @@ const newProjectDir = path.join(documentsDir, 'a-different-directory')
const tmp = process.env.TEMP || '/tmp' const tmp = process.env.TEMP || '/tmp'
const userCodeDir = path.join(tmp, 'kittycad_user_code') const userCodeDir = path.join(tmp, 'kittycad_user_code')
async function click(element: WebdriverIO.Element): Promise<void> { describe('ZMA sign in flow', () => {
// Workaround for .click(), see https://github.com/tauri-apps/tauri/issues/6541 before(async () => {
await element.waitForClickable()
await browser.execute('arguments[0].click();', element)
}
/* Shoutout to @Sheap on Github for a great workaround utility:
* https://github.com/tauri-apps/tauri/issues/6541#issue-1638944060
*/
async function setDatasetValue(
field: WebdriverIO.Element,
property: string,
value: string
) {
await browser.execute(`arguments[0].dataset.${property} = "${value}"`, field)
}
describe('ZMA (Tauri)', () => {
it('opens the auth page and signs in', async () => {
// Clean up filesystem from previous tests // Clean up filesystem from previous tests
await new Promise((resolve) => setTimeout(resolve, 100)) await new Promise((resolve) => setTimeout(resolve, 100))
await fs.rm(defaultProjectDir, { force: true, recursive: true }) await fs.rm(defaultProjectDir, { force: true, recursive: true })
@ -42,7 +26,9 @@ describe('ZMA (Tauri)', () => {
await fs.rm(userSettingsDir, { force: true, recursive: true }) await fs.rm(userSettingsDir, { force: true, recursive: true })
await fs.mkdir(defaultProjectDir, { recursive: true }) await fs.mkdir(defaultProjectDir, { recursive: true })
await fs.mkdir(newProjectDir, { recursive: true }) await fs.mkdir(newProjectDir, { recursive: true })
})
it('opens the auth page and signs in', async () => {
const signInButton = await $('[data-testid="sign-in-button"]') const signInButton = await $('[data-testid="sign-in-button"]')
expect(await signInButton.getText()).toEqual('Sign in') expect(await signInButton.getText()).toEqual('Sign in')
@ -82,6 +68,10 @@ describe('ZMA (Tauri)', () => {
const newFileButton = await $('[data-testid="home-new-file"]') const newFileButton = await $('[data-testid="home-new-file"]')
expect(await newFileButton.getText()).toEqual('New project') expect(await newFileButton.getText()).toEqual('New project')
}) })
})
describe('ZMA authorized user flows', () => {
// Note: each flow below is intended to start *and* end from the home page
it('opens the settings page, checks filesystem settings, and closes the settings page', async () => { it('opens the settings page, checks filesystem settings, and closes the settings page', async () => {
const menuButton = await $('[data-testid="user-sidebar-toggle"]') const menuButton = await $('[data-testid="user-sidebar-toggle"]')
@ -150,7 +140,9 @@ describe('ZMA (Tauri)', () => {
const base = isWin32 ? 'http://tauri.localhost' : 'tauri://localhost' const base = isWin32 ? 'http://tauri.localhost' : 'tauri://localhost'
await browser.execute(`window.location.href = "${base}/home"`) await browser.execute(`window.location.href = "${base}/home"`)
}) })
})
describe('ZMA sign out flow', () => {
it('signs out', async () => { it('signs out', async () => {
await new Promise((resolve) => setTimeout(resolve, 1000)) await new Promise((resolve) => setTimeout(resolve, 1000))
const menuButton = await $('[data-testid="user-sidebar-toggle"]') const menuButton = await $('[data-testid="user-sidebar-toggle"]')

18
e2e/tauri/utils.ts Normal file
View File

@ -0,0 +1,18 @@
import { browser } from '@wdio/globals'
export async function click(element: WebdriverIO.Element): Promise<void> {
// Workaround for .click(), see https://github.com/tauri-apps/tauri/issues/6541
await element.waitForClickable()
await browser.execute('arguments[0].click();', element)
}
/* Shoutout to @Sheap on Github for a great workaround utility:
* https://github.com/tauri-apps/tauri/issues/6541#issue-1638944060
*/
export async function setDatasetValue(
field: WebdriverIO.Element,
property: string,
value: string
) {
await browser.execute(`arguments[0].dataset.${property} = "${value}"`, field)
}

View File

@ -26,7 +26,7 @@ const config = defineConfig({
coverage: { coverage: {
provider: 'istanbul', // or 'v8' provider: 'istanbul', // or 'v8'
}, },
exclude: [...configDefaults.exclude, '**/e2e/playwright/**/*'], exclude: [...configDefaults.exclude, '**/e2e/**/*'],
deps: { deps: {
optimizer: { optimizer: {
web: { web: {