alessandro trinca tornidor commited on
Commit ·
f419f31
1
Parent(s): 000cfc3
first working test example with playwright setup
Browse files- static/index.js +3 -0
- static/playwright.config.ts +2 -1
- static/tests/setup-classic-lite.koboldai.net.json +18 -0
- static/tests/setup-classic-lite.koboldai.net.ts +41 -0
- static/tests/test-classic-lite.koboldai.net.spec.ts +110 -0
- static/tests/test-lite.koboldai.net-classic.spec.ts-snapshots/test-1-chromium-linux.png +3 -0
static/index.js
CHANGED
|
@@ -722,6 +722,9 @@ function insertListOfWords(i, iReduced, wordListElement, currentTableOfWords) {
|
|
| 722 |
}
|
| 723 |
});
|
| 724 |
a.className = underlinedPrimary
|
|
|
|
|
|
|
|
|
|
| 725 |
li.appendChild(a);
|
| 726 |
wordListElement.appendChild(li);
|
| 727 |
}
|
|
|
|
| 722 |
}
|
| 723 |
});
|
| 724 |
a.className = underlinedPrimary
|
| 725 |
+
a.setAttribute("id", `id-list-of-words-${i}-nth`)
|
| 726 |
+
a.setAttribute("aria-label", `id-list-of-words-${i}-nth`)
|
| 727 |
+
console.log(`insertListOfWords::a:`, a.id, a.ariaLabel, "=>", a, "#")
|
| 728 |
li.appendChild(a);
|
| 729 |
wordListElement.appendChild(li);
|
| 730 |
}
|
static/playwright.config.ts
CHANGED
|
@@ -46,13 +46,14 @@ export default defineConfig({
|
|
| 46 |
|
| 47 |
/* Configure projects for major browsers */
|
| 48 |
projects: [
|
|
|
|
| 49 |
{
|
| 50 |
name: 'chromium',
|
| 51 |
// grepInvert: /mobile/,
|
| 52 |
use: {
|
| 53 |
...devices['Desktop Chrome'],
|
| 54 |
viewport: { width: 1600, height: 1200 },
|
| 55 |
-
},
|
| 56 |
},
|
| 57 |
|
| 58 |
{
|
|
|
|
| 46 |
|
| 47 |
/* Configure projects for major browsers */
|
| 48 |
projects: [
|
| 49 |
+
// { name: 'setup_classic_lite.koboldai.net', testMatch: 'setup-classic-lite.koboldai.net.ts' },
|
| 50 |
{
|
| 51 |
name: 'chromium',
|
| 52 |
// grepInvert: /mobile/,
|
| 53 |
use: {
|
| 54 |
...devices['Desktop Chrome'],
|
| 55 |
viewport: { width: 1600, height: 1200 },
|
| 56 |
+
} //, dependencies: ["setup_classic_lite.koboldai.net"]
|
| 57 |
},
|
| 58 |
|
| 59 |
{
|
static/tests/setup-classic-lite.koboldai.net.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cookies": [],
|
| 3 |
+
"origins": [
|
| 4 |
+
{
|
| 5 |
+
"origin": "http://localhost:8000",
|
| 6 |
+
"localStorage": [
|
| 7 |
+
{
|
| 8 |
+
"name": "kaihordewebui_story",
|
| 9 |
+
"value": "offload_to_indexeddb"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"name": "kaihordewebui_settings",
|
| 13 |
+
"value": "offload_to_indexeddb"
|
| 14 |
+
}
|
| 15 |
+
]
|
| 16 |
+
}
|
| 17 |
+
]
|
| 18 |
+
}
|
static/tests/setup-classic-lite.koboldai.net.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { test as setup, expect } from '@playwright/test';
|
| 2 |
+
|
| 3 |
+
const setupClassicContextFile = `${import.meta.dirname}/setup-classic-lite.koboldai.net.json`
|
| 4 |
+
const testStoryJsonTxt = `${import.meta.dirname}/../../tests/events/very_long_text.json`
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Author Testers Talk
|
| 8 |
+
*/
|
| 9 |
+
setup('classic UI setup for lite.koboldai.net', async ({ page }) => {
|
| 10 |
+
console.log('classic UI setup for lite.koboldai.net: starting...');
|
| 11 |
+
console.log("filename:", testStoryJsonTxt, "#")
|
| 12 |
+
|
| 13 |
+
await page.goto('http://localhost:8000/');
|
| 14 |
+
await page.getByRole('button', { name: 'Set UI' }).click();
|
| 15 |
+
|
| 16 |
+
console.log(`preparing uploading of file '${testStoryJsonTxt}'!`)
|
| 17 |
+
await page.getByRole('link', { name: 'Save / Load' }).click();
|
| 18 |
+
await page.waitForTimeout(100)
|
| 19 |
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
| 20 |
+
// filepickerawait page.getByRole('button', { name: '📁 Open File' }).click();
|
| 21 |
+
await page.getByRole('button', { name: '📁 Open File' }).click();
|
| 22 |
+
const fileChooser = await fileChooserPromise;
|
| 23 |
+
await fileChooser.setFiles(testStoryJsonTxt);
|
| 24 |
+
await page.waitForTimeout(300)
|
| 25 |
+
// await expect(page.locator('#gametext')).toHaveScreenshot()
|
| 26 |
+
console.log(`file '${testStoryJsonTxt}' uploaded!`)
|
| 27 |
+
|
| 28 |
+
await page.getByRole('link', { name: 'Settings' }).click();
|
| 29 |
+
await page.getByRole('link', { name: 'Tokens' }).click();
|
| 30 |
+
await page.waitForTimeout(100)
|
| 31 |
+
await page.getByRole('button', { name: 'id-expand-wordsfreqstats' }).click();
|
| 32 |
+
await page.getByRole('checkbox', { name: 'id-col2-words-frequency-enable' }).check();
|
| 33 |
+
// assert checkbox checked
|
| 34 |
+
await expect(page.getByRole('checkbox', { name: 'id-col2-words-frequency-enable' })).toBeChecked();
|
| 35 |
+
|
| 36 |
+
await page.getByRole('button', { name: 'OK' }).click();
|
| 37 |
+
await page.waitForTimeout(100)
|
| 38 |
+
|
| 39 |
+
await page.context().storageState({ path: setupClassicContextFile });
|
| 40 |
+
console.log('classic UI setup for lite.koboldai.net: done!');
|
| 41 |
+
});
|
static/tests/test-classic-lite.koboldai.net.spec.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { test, expect } from '@playwright/test';
|
| 2 |
+
|
| 3 |
+
const setupClassicContextFile = `${import.meta.dirname}/setup-classic-lite.koboldai.net.json`
|
| 4 |
+
const testStoryJsonTxt = `${import.meta.dirname}/../../tests/events/very_long_text.json`
|
| 5 |
+
|
| 6 |
+
test('test', async ({ page }) => {
|
| 7 |
+
await page.goto('http://localhost:8000/');
|
| 8 |
+
await page.getByRole('button', { name: 'Set UI' }).click();
|
| 9 |
+
|
| 10 |
+
console.log(`preparing uploading of file '${testStoryJsonTxt}'!`)
|
| 11 |
+
await page.getByRole('link', { name: 'Save / Load' }).click();
|
| 12 |
+
await page.waitForTimeout(100)
|
| 13 |
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
| 14 |
+
// filepickerawait page.getByRole('button', { name: '📁 Open File' }).click();
|
| 15 |
+
await page.getByRole('button', { name: '📁 Open File' }).click();
|
| 16 |
+
const fileChooser = await fileChooserPromise;
|
| 17 |
+
await fileChooser.setFiles(testStoryJsonTxt);
|
| 18 |
+
await page.waitForTimeout(300)
|
| 19 |
+
// await expect(page.locator('#gametext')).toHaveScreenshot()
|
| 20 |
+
console.log(`file '${testStoryJsonTxt}' uploaded!`)
|
| 21 |
+
|
| 22 |
+
await page.getByRole('link', { name: 'Settings' }).click();
|
| 23 |
+
await page.getByRole('link', { name: 'Tokens' }).click();
|
| 24 |
+
await page.waitForTimeout(100)
|
| 25 |
+
await page.getByRole('button', { name: 'id-expand-wordsfreqstats' }).click();
|
| 26 |
+
await page.getByRole('checkbox', { name: 'id-col2-words-frequency-enable' }).check();
|
| 27 |
+
// assert checkbox checked
|
| 28 |
+
await expect(page.getByRole('checkbox', { name: 'id-col2-words-frequency-enable' })).toBeChecked();
|
| 29 |
+
|
| 30 |
+
await page.getByRole('button', { name: 'OK' }).click();
|
| 31 |
+
await page.waitForTimeout(100)
|
| 32 |
+
console.log("#")
|
| 33 |
+
|
| 34 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).click();
|
| 35 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).fill('th');
|
| 36 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).press('Enter');
|
| 37 |
+
await page.waitForTimeout(100)
|
| 38 |
+
|
| 39 |
+
await expect(page.getByLabel('id-filtered-value')).toContainText('\'th\', 1701');
|
| 40 |
+
|
| 41 |
+
await expect(page.getByLabel('id-current-table-of-words-title')).not.toContainText('the: 734');
|
| 42 |
+
console.log("#")
|
| 43 |
+
|
| 44 |
+
let listOfWordsList = page.getByLabel('id-list-of-words-container').locator('list')
|
| 45 |
+
await expect(listOfWordsList.getByLabel(`id-list-of-words-${0}-nth`)).toMatchAriaSnapshot("- text: \"the: 734 repetitions\"");
|
| 46 |
+
console.log("nth0:#")
|
| 47 |
+
|
| 48 |
+
await page.getByText('the: 734').click();
|
| 49 |
+
await page.waitForTimeout(100)
|
| 50 |
+
|
| 51 |
+
await expect(page.getByLabel('id-current-table-of-words-title')).toContainText('the: 734');
|
| 52 |
+
await expect(page.getByLabel('id-table-0-row-0-nth').getByRole('cell')).toMatchAriaSnapshot(`- cell "THE BOY WHO"`);
|
| 53 |
+
await page.getByText('THE BOY WHO', { exact: true }).click();
|
| 54 |
+
await page.waitForTimeout(100)
|
| 55 |
+
await expect(page.locator('#gametext')).toHaveScreenshot()
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
await expect(page.getByLabel('id-table-0-row-733-nth').getByRole('cell')).toMatchAriaSnapshot(`- cell "early the next"`);
|
| 59 |
+
await page.getByText('early the next', { exact: true }).click();
|
| 60 |
+
await page.waitForTimeout(100)
|
| 61 |
+
await expect(page.locator('#gametext')).toHaveScreenshot()
|
| 62 |
+
/*
|
| 63 |
+
|
| 64 |
+
await page.getByLabel('order: ascend order: descend').selectOption('asc');
|
| 65 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).click();
|
| 66 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).press('Enter');
|
| 67 |
+
await page.waitForTimeout(100)
|
| 68 |
+
|
| 69 |
+
expect(listOfWordsList).toHaveCount(1701)
|
| 70 |
+
await expect(listOfWordsList.nth(0)).toContainText('anything strange: 1');
|
| 71 |
+
await expect(listOfWordsList.nth(1)).toContainText('because they: 1');
|
| 72 |
+
await expect(listOfWordsList.nth(1701)).toContainText('the: 734');
|
| 73 |
+
|
| 74 |
+
await page.getByText('the Dursleys:').click();
|
| 75 |
+
await page.waitForTimeout(100)
|
| 76 |
+
|
| 77 |
+
await expect(page.getByLabel('id-current-table-of-words-title')).toContainText('the Dursleys: 32');
|
| 78 |
+
await expect(page.locator('#gametext')).toHaveScreenshot()
|
| 79 |
+
|
| 80 |
+
let col2wordsFreq = page.getByLabel('id-col2-words-frequency', { exact: true })
|
| 81 |
+
await expect(col2wordsFreq).toHaveScreenshot()
|
| 82 |
+
await page.getByText('The Dursley s had a', { exact: true }).click();
|
| 83 |
+
await page.waitForTimeout(100)
|
| 84 |
+
await expect(page.locator('#gametext')).toHaveScreenshot()
|
| 85 |
+
|
| 86 |
+
await page.getByText('that the Dursleys were', { exact: true }).click();
|
| 87 |
+
await page.waitForTimeout(100)
|
| 88 |
+
await expect(page.locator('#gametext')).toHaveScreenshot()
|
| 89 |
+
|
| 90 |
+
listOfWordsList = page.getByLabel('id-list-of-words-container').locator('list')
|
| 91 |
+
expect(listOfWordsList).toHaveCount(1701)
|
| 92 |
+
|
| 93 |
+
await page.getByLabel('id-select-sort-by').selectOption('word_prefix');
|
| 94 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).click();
|
| 95 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).press('Enter');
|
| 96 |
+
await expect(listOfWordsList.nth(0)).toMatchAriaSnapshot(`- listitem: "— with: 1 reps."`);
|
| 97 |
+
await expect(listOfWordsList.nth(1701)).toMatchAriaSnapshot(`- listitem: "! The: 1 reps."`);
|
| 98 |
+
|
| 99 |
+
await page.getByLabel('id-select-sort-by').selectOption('n_words_ngram');
|
| 100 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).click();
|
| 101 |
+
await page.getByRole('searchbox', { name: 'filter-words-frequency' }).press('Enter');
|
| 102 |
+
|
| 103 |
+
await expect(listOfWordsList.nth(0)).toMatchAriaSnapshot(`- listitem: "the boy: 7 reps."`);
|
| 104 |
+
await expect(listOfWordsList.nth(1701)).toMatchAriaSnapshot(`- listitem: "third: 1 reps."`);
|
| 105 |
+
|
| 106 |
+
fileWriter(filepath, data)
|
| 107 |
+
fileReader(filepath)
|
| 108 |
+
*/
|
| 109 |
+
console.log("end!")
|
| 110 |
+
});
|
static/tests/test-lite.koboldai.net-classic.spec.ts-snapshots/test-1-chromium-linux.png
ADDED
|
Git LFS Details
|