* BROKEN: start of scopes for each setting * Clean up later: mostly-functional scoped settings! Broken command bar, unimplemented generated settings components * Working persisted project settings in-folder * Start working toward automatic commands and settings UI * Relatively stable, settings-menu-editable * Settings persistence tweaks after merge * Custom settings UI working properly, cleaner types * Allow boolean command types, create Settings UI for them * Add support for option and string Settings input types * Proof of concept settings from command bar * Add all settings to command bar * Allow settings to be hidden on a level * Better command titles for settings * Hide the settings the settings from the commands bar * Derive command defaultValue from *current* settingsMachine context * Fix generated settings UI for 'options' type settings * Pretty settings modal 💅 * Allow for rollback to parent level setting * fmt * Fix tsc errors not related to loading from localStorage * Better setting descriptions, better buttons * Make displayName searchable in command bar * Consolidate constants, get working in browser * Start fixing tests, better types for saved settings payloads * Fix playwright tests * Add a test for the settings modal * Add AtLeast to codespell ignore list * Goofed merge of codespellrc * Try fixing linux E2E tests * Make codespellrc word lowercase * fmt * Fix data-testid in Tauri test * Don't set text settings if nothing changed * Turn off unimplemented settings * Allow for multiple "execution-done" messages to have appeared in snapshot tests * Try fixing up snapshot tests * Switch from .json to .toml settings file format * Use a different method for overriding the default units * Try to force using the new common storage state in snapshot tests * Update tests to use TOML * fmt and remove console logs * Restore units to export * tsc errors, make snapshot tests use TOML * Ensure that snapshot tests use the basicStorageState * Re-organize use of test.use() * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update snapshots one more time since lighting changed * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix broken "Show in folder" for project-level settings * Fire all relevant actions after settings reset * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Properly reset the default directory * Hide settings by platform * Actually honor showDebugPanel * Unify settings hiding logic * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix first extrusion snapshot * another attempt to fix extrustion snapshot * Rerun test suite * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * more extrusion stuff * Replace resetSettings console log with comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
106 lines
3.9 KiB
TypeScript
106 lines
3.9 KiB
TypeScript
import { browser, $, expect } from '@wdio/globals'
|
|
import fs from 'fs/promises'
|
|
|
|
const defaultDir = `${process.env.HOME}/Documents/zoo-modeling-app-projects`
|
|
const userCodeDir = '/tmp/kittycad_user_code'
|
|
|
|
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)
|
|
}
|
|
|
|
describe('ZMA (Tauri, Linux)', () => {
|
|
it('opens the auth page and signs in', async () => {
|
|
// Clean up filesystem from previous tests
|
|
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
await fs.rm(defaultDir, { force: true, recursive: true })
|
|
await fs.rm(userCodeDir, { force: true })
|
|
|
|
const signInButton = await $('[data-testid="sign-in-button"]')
|
|
expect(await signInButton.getText()).toEqual('Sign in')
|
|
|
|
await click(signInButton)
|
|
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
|
|
// Get from main.rs
|
|
const userCode = await (
|
|
await fs.readFile('/tmp/kittycad_user_code')
|
|
).toString()
|
|
console.log(`Found user code ${userCode}`)
|
|
|
|
// Device flow: verify
|
|
const token = process.env.KITTYCAD_API_TOKEN
|
|
const headers = {
|
|
Authorization: `Bearer ${token}`,
|
|
Accept: 'application/json',
|
|
'Content-Type': 'application/json',
|
|
}
|
|
const apiBaseUrl = process.env.VITE_KC_API_BASE_URL
|
|
const verifyUrl = `${apiBaseUrl}/oauth2/device/verify?user_code=${userCode}`
|
|
console.log(`GET ${verifyUrl}`)
|
|
const vr = await fetch(verifyUrl, { headers })
|
|
console.log(vr.status)
|
|
|
|
// Device flow: confirm
|
|
const confirmUrl = `${apiBaseUrl}/oauth2/device/confirm`
|
|
const data = JSON.stringify({ user_code: userCode })
|
|
console.log(`POST ${confirmUrl} ${data}`)
|
|
const cr = await fetch(confirmUrl, {
|
|
headers,
|
|
method: 'POST',
|
|
body: data,
|
|
})
|
|
console.log(cr.status)
|
|
|
|
// Now should be signed in
|
|
const newFileButton = await $('[data-testid="home-new-file"]')
|
|
expect(await newFileButton.getText()).toEqual('New file')
|
|
})
|
|
|
|
it('opens the settings page, checks filesystem settings, and closes the settings page', async () => {
|
|
const menuButton = await $('[data-testid="user-sidebar-toggle"]')
|
|
await click(menuButton)
|
|
|
|
const settingsButton = await $('[data-testid="settings-button"]')
|
|
await click(settingsButton)
|
|
|
|
const defaultDirInput = await $('[data-testid="default-directory-input"]')
|
|
expect(await defaultDirInput.getValue()).toEqual(defaultDir)
|
|
|
|
const nameInput = await $('[data-testid="projects-defaultProjectName"]')
|
|
expect(await nameInput.getValue()).toEqual('project-$nnn')
|
|
|
|
const closeButton = await $('[data-testid="settings-close-button"]')
|
|
await click(closeButton)
|
|
})
|
|
|
|
it('checks that no file exists, creates a new file', async () => {
|
|
const homeSection = await $('[data-testid="home-section"]')
|
|
expect(await homeSection.getText()).toContain('No Projects found')
|
|
|
|
const newFileButton = await $('[data-testid="home-new-file"]')
|
|
await click(newFileButton)
|
|
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
|
|
expect(await homeSection.getText()).toContain('project-000')
|
|
})
|
|
|
|
it('opens the new file and expects a loading stream', async () => {
|
|
const projectLink = await $('[data-testid="project-link"]')
|
|
await click(projectLink)
|
|
const loadingText = await $('[data-testid="loading-stream"]')
|
|
expect(await loadingText.getText()).toContain('Loading stream...')
|
|
await browser.execute('window.location.href = "tauri://localhost/home"')
|
|
})
|
|
|
|
it('signs out', async () => {
|
|
const menuButton = await $('[data-testid="user-sidebar-toggle"]')
|
|
await click(menuButton)
|
|
const signoutButton = await $('[data-testid="user-sidebar-sign-out"]')
|
|
await click(signoutButton)
|
|
const newSignInButton = await $('[data-testid="sign-in-button"]')
|
|
expect(await newSignInButton.getText()).toEqual('Sign in')
|
|
})
|
|
})
|