alessandro trinca tornidor
commited on
Commit
·
be2d172
1
Parent(s):
f97c259
test: update test case for th4esaurus custom form entries
Browse files- static/tests/test-classic-4-lite.koboldai.net.spec.ts +119 -0
- static/tests/test-classic-4-lite.koboldai.net.spec.ts-snapshots/test-classic-4-0-wordsearch-results-0-chromium-editable.txt +5 -0
- static/tests/test-classic-4-lite.koboldai.net.spec.ts-snapshots/test-classic-4-0-wordsearch-results-1-chromium-editable.txt +24 -0
- static/tests/test-classic-4-lite.koboldai.net.spec.ts-snapshots/test-classic-4-0-wordsearch-results-2-chromium-editable.txt +34 -0
- static/tests/test-classic-4-lite.koboldai.net.spec.ts-snapshots/test-classic-4-0-wordsearch-results-3-chromium-editable.txt +20 -0
static/tests/test-classic-4-lite.koboldai.net.spec.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { test, expect, WorkerInfo, Page } from '@playwright/test';
|
| 2 |
+
import {
|
| 3 |
+
deleteCustomSynonym,
|
| 4 |
+
ensureThesaurusPanelClosed,
|
| 5 |
+
ensureThesaurusPanelOpen,
|
| 6 |
+
fillInputFieldWithString,
|
| 7 |
+
initTest
|
| 8 |
+
} from './test-helper';
|
| 9 |
+
|
| 10 |
+
const testStoryJsonTxt = `${import.meta.dirname}/../../tests/events/very_long_text.json`
|
| 11 |
+
|
| 12 |
+
let page: Page;
|
| 13 |
+
let projectNameGlobal = {
|
| 14 |
+
projectName: ""
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
test.beforeAll(async ({ browser }, workerInfo) => {
|
| 18 |
+
page = await browser.newPage();
|
| 19 |
+
projectNameGlobal.projectName = await initTest({page, workerInfo, filepath:testStoryJsonTxt})
|
| 20 |
+
});
|
| 21 |
+
|
| 22 |
+
test.afterAll(async () => {
|
| 23 |
+
await page.close();
|
| 24 |
+
});
|
| 25 |
+
test(`test My Ghost Writer: backend request - word with no synonyms, then add a custom entries`, async () => {
|
| 26 |
+
console.log("process.env.DOMAIN_PORT:", process.env.DOMAIN_PORT, "#")
|
| 27 |
+
const thesaurusDomain = `${process.env.DOMAIN_PORT}` ?? "http://localhost:7860"
|
| 28 |
+
console.log("thesaurusDomain:", thesaurusDomain, "#")
|
| 29 |
+
const projectName = projectNameGlobal.projectName;
|
| 30 |
+
console.log("projectNameGlobal.projectName:", projectName, projectNameGlobal.projectName, "#")
|
| 31 |
+
const word = "happy"
|
| 32 |
+
const state = "editable"
|
| 33 |
+
// search the word 'happy'
|
| 34 |
+
await fillInputFieldWithString(page, word);
|
| 35 |
+
await page.getByRole('checkbox', { name: 'Allow Editing' }).check();
|
| 36 |
+
await page.waitForTimeout(200)
|
| 37 |
+
|
| 38 |
+
await ensureThesaurusPanelClosed(page);
|
| 39 |
+
// open the thesaurus result right panel: the word 'happy', for start, doesn't find any synonyms
|
| 40 |
+
await page.getByRole('link', { name: 'id-a-candidate-0-nth' }).click();
|
| 41 |
+
await page.getByRole('link', { name: 'id-0-range-0-nth' }).click();
|
| 42 |
+
await page.waitForTimeout(200)
|
| 43 |
+
|
| 44 |
+
await ensureThesaurusPanelOpen(page);
|
| 45 |
+
// assert that the title of the thesaurus right panel is what we expect
|
| 46 |
+
await expect(page.getByLabel('id-content-inflated-synonyms-')).toContainText('Original phrase: happy');
|
| 47 |
+
await expect(page.getByRole("heading", {name: "id-content-inflated-synonyms-container-h1-original-phrase"})).toContainText('Original phrase: '+word);
|
| 48 |
+
// assert that the content of page is what we expect
|
| 49 |
+
await expect(page.locator('#id-rightpanel-thesaurus-content-parent')).toMatchAriaSnapshot({ name: `test-classic-4-0-wordsearch_results-0-${projectName}-${state}.txt` });
|
| 50 |
+
// open the thesaurus custom form using the internal button
|
| 51 |
+
await page.getByRole('button', { name: 'thesaurus-custom-button-internal0' }).click();
|
| 52 |
+
// try to submit immediately, we'll get an error because we didn't filled the forms
|
| 53 |
+
console.log("#")
|
| 54 |
+
await page.getByRole('button', { name: 'thesaurus-custom-submit' }).click();
|
| 55 |
+
page.once('dialog', dialog1 => {
|
| 56 |
+
const msg1 = dialog1.message()
|
| 57 |
+
// expect(msg1).toContain("Please enter a word.")
|
| 58 |
+
console.error(`Dialog message: '${msg1}'`); // Dialog message: Please enter a word.
|
| 59 |
+
dialog1.dismiss().catch(() => {});
|
| 60 |
+
});
|
| 61 |
+
await page.waitForTimeout(200)
|
| 62 |
+
|
| 63 |
+
await page.getByRole('button', { name: 'thesaurus-custom-cancel' }).click(); // close the thesaurus custom form
|
| 64 |
+
await page.getByRole('button', { name: 'id-rightpanel-thesaurus-close' }).click(); // close the thesaurus result right panel
|
| 65 |
+
await page.waitForTimeout(200)
|
| 66 |
+
// re-open the thesaurus custom form, from the external button this time
|
| 67 |
+
await page.getByRole('button', { name: 'thesaurus-custom-button-' }).click();
|
| 68 |
+
await page.waitForTimeout(200)
|
| 69 |
+
// compile the forms for the submission of the 'happy' synonyms
|
| 70 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-word' }).click();
|
| 71 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-word' }).fill('happy');
|
| 72 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-related-words-0nth' }).click();
|
| 73 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-related-words-0nth' }).fill('cheerful,joy');
|
| 74 |
+
await page.getByRole('button', { name: 'thesaurus-custom-related-btn-' }).click();
|
| 75 |
+
await page.getByLabel('thesaurus-custom-related-type-1nth').selectOption('antonym');
|
| 76 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-related-words-1nth' }).click();
|
| 77 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-related-words-1nth' }).fill('sad,sadness');
|
| 78 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-related-definition-1nth' }).click();
|
| 79 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-related-definition-1nth' }).fill('I\'m a sad person');
|
| 80 |
+
await page.getByRole('button', { name: 'thesaurus-custom-related-btn-add-0nth' }).click();
|
| 81 |
+
await page.getByRole('button', { name: 'thesaurus-custom-related-btn-del-2nth' }).click(); // delete an entry
|
| 82 |
+
await expect(page.getByLabel('thesaurus-custom-form-content')).toMatchAriaSnapshot({ name: `test-classic-4-0-wordsearch_results-1-${projectName}-${state}.txt` });
|
| 83 |
+
await page.getByRole('button', { name: 'thesaurus-custom-related-btn-add-0nth' }).click();
|
| 84 |
+
await expect(page.getByLabel('thesaurus-custom-form-content')).toMatchAriaSnapshot({ name: `test-classic-4-0-wordsearch_results-2-${projectName}-${state}.txt` });
|
| 85 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-related-words-2nth' }).click();
|
| 86 |
+
await page.getByRole('textbox', { name: 'thesaurus-custom-related-words-2nth' }).fill('joyful,happyness,content');
|
| 87 |
+
// handle second dialog message
|
| 88 |
+
page.once('dialog', dialog2 => {
|
| 89 |
+
const msg2 = dialog2.message()
|
| 90 |
+
// expect(msg2).toContain("Thesaurus entry added successfully!")
|
| 91 |
+
console.error(`Dialog message: '${msg2}'`); // Dialog message: Thesaurus entry added successfully!
|
| 92 |
+
dialog2.dismiss().catch(() => {});
|
| 93 |
+
});
|
| 94 |
+
await page.waitForTimeout(200)
|
| 95 |
+
|
| 96 |
+
// submit the form content
|
| 97 |
+
await page.getByRole('button', { name: 'thesaurus-custom-submit' }).click();
|
| 98 |
+
await page.waitForTimeout(200)
|
| 99 |
+
|
| 100 |
+
await ensureThesaurusPanelClosed(page);
|
| 101 |
+
// re-open the right panel with the thesaurus results for 'happy': this time we'll find the synonynms we submitted before (WIP: only the first group right now)
|
| 102 |
+
await page.getByRole('link', { name: 'id-a-candidate-0-nth' }).click();
|
| 103 |
+
await page.getByRole('link', { name: 'id-0-range-0-nth' }).click();
|
| 104 |
+
await page.waitForTimeout(200)
|
| 105 |
+
await ensureThesaurusPanelOpen(page);
|
| 106 |
+
|
| 107 |
+
await expect(page.getByLabel('definition-div-0-')).toBeVisible();
|
| 108 |
+
await expect(page.getByLabel('content-inflated-synonyms-0nth')).toMatchAriaSnapshot({ name: `test-classic-4-0-wordsearch_results-3-${projectName}-${state}.txt` });
|
| 109 |
+
await page.getByRole('button', { name: 'id-rightpanel-thesaurus-close' }).click();
|
| 110 |
+
await page.waitForTimeout(200)
|
| 111 |
+
await ensureThesaurusPanelClosed(page);
|
| 112 |
+
|
| 113 |
+
// delete the synonyms group(s) for 'happy' to ensure we can repeat this test
|
| 114 |
+
const responseData = await deleteCustomSynonym(word)
|
| 115 |
+
const {message} = responseData;
|
| 116 |
+
expect(message).toContain(`Synonyms for '${word}' deleted successfully`)
|
| 117 |
+
|
| 118 |
+
await page.close()
|
| 119 |
+
})
|
static/tests/test-classic-4-lite.koboldai.net.spec.ts-snapshots/test-classic-4-0-wordsearch-results-0-chromium-editable.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- button "id-rightpanel-thesaurus-close"
|
| 2 |
+
- searchbox "synonym mod Input"
|
| 3 |
+
- button "thesaurus-synonym-mod-confirm-button"
|
| 4 |
+
- button "thesaurus-custom-button-internal0"
|
| 5 |
+
- heading "id-content-inflated-synonyms-container-h1-original-phrase" [level=1]
|
static/tests/test-classic-4-lite.koboldai.net.spec.ts-snapshots/test-classic-4-0-wordsearch-results-1-chromium-editable.txt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- heading "Add Custom Thesaurus Entry" [level=3]
|
| 2 |
+
- textbox "thesaurus-custom-word"
|
| 3 |
+
- button "thesaurus-custom-related-btn-add-0nth"
|
| 4 |
+
- text: "Relationship:"
|
| 5 |
+
- combobox "thesaurus-custom-related-type-0nth":
|
| 6 |
+
- option "Synonym" [selected]
|
| 7 |
+
- option "Antonym"
|
| 8 |
+
- option "Homonym"
|
| 9 |
+
- option "Homophone"
|
| 10 |
+
- option "Homograph"
|
| 11 |
+
- textbox "thesaurus-custom-related-words-0nth"
|
| 12 |
+
- textbox "thesaurus-custom-related-definition-0nth"
|
| 13 |
+
- button "thesaurus-custom-related-btn-del-1nth"
|
| 14 |
+
- text: "Relationship:"
|
| 15 |
+
- combobox "thesaurus-custom-related-type-1nth":
|
| 16 |
+
- option "Synonym"
|
| 17 |
+
- option "Antonym" [selected]
|
| 18 |
+
- option "Homonym"
|
| 19 |
+
- option "Homophone"
|
| 20 |
+
- option "Homograph"
|
| 21 |
+
- textbox "thesaurus-custom-related-words-1nth"
|
| 22 |
+
- textbox "thesaurus-custom-related-definition-1nth"
|
| 23 |
+
- button "thesaurus-custom-submit"
|
| 24 |
+
- button "thesaurus-custom-cancel"
|
static/tests/test-classic-4-lite.koboldai.net.spec.ts-snapshots/test-classic-4-0-wordsearch-results-2-chromium-editable.txt
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- heading "Add Custom Thesaurus Entry" [level=3]
|
| 2 |
+
- textbox "thesaurus-custom-word"
|
| 3 |
+
- button "thesaurus-custom-related-btn-add-0nth"
|
| 4 |
+
- text: "Relationship:"
|
| 5 |
+
- combobox "thesaurus-custom-related-type-0nth":
|
| 6 |
+
- option "Synonym" [selected]
|
| 7 |
+
- option "Antonym"
|
| 8 |
+
- option "Homonym"
|
| 9 |
+
- option "Homophone"
|
| 10 |
+
- option "Homograph"
|
| 11 |
+
- textbox "thesaurus-custom-related-words-0nth"
|
| 12 |
+
- textbox "thesaurus-custom-related-definition-0nth"
|
| 13 |
+
- button "thesaurus-custom-related-btn-del-1nth"
|
| 14 |
+
- text: "Relationship:"
|
| 15 |
+
- combobox "thesaurus-custom-related-type-1nth":
|
| 16 |
+
- option "Synonym"
|
| 17 |
+
- option "Antonym" [selected]
|
| 18 |
+
- option "Homonym"
|
| 19 |
+
- option "Homophone"
|
| 20 |
+
- option "Homograph"
|
| 21 |
+
- textbox "thesaurus-custom-related-words-1nth"
|
| 22 |
+
- textbox "thesaurus-custom-related-definition-1nth"
|
| 23 |
+
- button "thesaurus-custom-related-btn-del-2nth"
|
| 24 |
+
- text: "Relationship:"
|
| 25 |
+
- combobox "thesaurus-custom-related-type-2nth":
|
| 26 |
+
- option "Synonym" [selected]
|
| 27 |
+
- option "Antonym"
|
| 28 |
+
- option "Homonym"
|
| 29 |
+
- option "Homophone"
|
| 30 |
+
- option "Homograph"
|
| 31 |
+
- textbox "thesaurus-custom-related-words-2nth"
|
| 32 |
+
- textbox "thesaurus-custom-related-definition-2nth"
|
| 33 |
+
- button "thesaurus-custom-submit"
|
| 34 |
+
- button "thesaurus-custom-cancel"
|
static/tests/test-classic-4-lite.koboldai.net.spec.ts-snapshots/test-classic-4-0-wordsearch-results-3-chromium-editable.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- heading "Smart Synonyms for thesaurus-original-word-span-0nth" [level=2]
|
| 2 |
+
- paragraph:
|
| 3 |
+
- strong: "Part of Speech:"
|
| 4 |
+
- text: ADJ (JJ)
|
| 5 |
+
- paragraph:
|
| 6 |
+
- strong: "Context:"
|
| 7 |
+
- text: Even Muggles like yourself should be celebrating, this happy, happy day!"
|
| 8 |
+
- paragraph:
|
| 9 |
+
- strong: "Dependency:"
|
| 10 |
+
- text: amod
|
| 11 |
+
- separator
|
| 12 |
+
- strong: "Definition:"
|
| 13 |
+
- text: User-defined synonym.
|
| 14 |
+
- strong: "WordNet POS:"
|
| 15 |
+
- text: ADJ
|
| 16 |
+
- heading "synonyms-title-0-0" [level=4]: "Available Synonyms:"
|
| 17 |
+
- button "synonym-button-0-0-0"
|
| 18 |
+
- button "synonym-button-0-0-1"
|
| 19 |
+
- button "synonym-button-0-0-2"
|
| 20 |
+
- group "details-0": Debug Information
|