diff --git a/Services/client/tests/listview.spec.ts b/Services/client/tests/listview.spec.ts index 0e99731..9e8f112 100644 --- a/Services/client/tests/listview.spec.ts +++ b/Services/client/tests/listview.spec.ts @@ -1,5 +1,5 @@ import { test, expect, Page } from '@playwright/test' - +import { nanoid } from 'nanoid' test.describe.configure({ mode: 'serial' }) let page: Page @@ -21,23 +21,26 @@ test('Login', async ({}) => { }) test('listViewMode', async () => { - await page.click("(//i[@role='img'])[2]") + await page.click("//i[text()='view_list']") }) + test('Create Cabinet', async () => { await page.click("//span[text()='สร้างตู้เก็บเอกสาร']") - await page.fill("(//input[@placeholder='กรอกชื่อ'])[2]", 'oat-test') - await page.click("(//span[text()='บันทึก'])[3]") + await page.fill("//input[@placeholder='กรอกชื่อ']", 'oat-test') + await page.click("//button[@type='submit']") }) test('Go into Cabinet', async () => { await page.click('//td[contains(text(),"oat-test")]') }) +var drawername = nanoid(7) + test('Create Drawer', async () => { await page.click("//span[text()='สร้างลิ้นชัก']") - await page.fill("(//input[@placeholder='กรอกชื่อ'])[1]", 'oat-drawer2') - await page.click("(//button[@type='submit'])[3]") + await page.fill("(//input[@class='q-field__native q-placeholder'])[2]", drawername) + await page.click("(//button[@type='submit'])") }) test('Go into Drawer', async () => { @@ -46,18 +49,18 @@ test('Go into Drawer', async () => { test('Create Folder', async () => { await page.click("//span[text()='สร้างแฟ้ม']") - await page.fill("(//input[@placeholder='กรอกชื่อ'])[1]", 'oat-folder2') - await page.click("(//span[text()='บันทึก'])[2]") + await page.fill("(//input[@class='q-field__native q-placeholder'])[2]", 'oat-folder') + await page.click("(//button[@type='submit'])") }) test('Go into Folder', async () => { - await page.click("//table[@class='q-table']") + await page.click("//table[@class='q-table']/tbody[1]/tr[1]/td[1]") }) test('Create subFolder', async () => { await page.click("//span[text()='สร้างแฟ้มย่อย']") - await page.fill("(//input[@placeholder='กรอกชื่อ'])[1]","oat-subfolder2") - await page.click("(//span[text()='บันทึก'])[2]") + await page.fill("(//input[@class='q-field__native q-placeholder'])[2]","oat-subfolder") + await page.click("//span[text()='บันทึก']") }) test('Go into SubFolder', async () => { @@ -67,15 +70,15 @@ test('Go into SubFolder', async () => { test('Upload File', async () => { await page.click("//span[text()='สร้างเอกสาร']") await page.locator("//input[@type='file']").setInputFiles('tests/test.docx') - await page.fill("//input[@placeholder='กรอกชื่อเรื่อง']",'oattest2') - await page.click("(//button[@type='submit'])[2]") + await page.fill("//input[@placeholder='กรอกชื่อเรื่อง']",'oattestfile') + await page.click("(//button[@type='submit'])[1]") await page.waitForTimeout(3000) - await page.click("//i[text()='refresh']") + await page.click("button#getFolder") await page.waitForTimeout(1000) }) test('Go into File', async () => { - await page.click("//table[@class='q-table']/tbody[1]/tr[1]/td[1]") + await page.click('//td[contains(text(),"test.docx")]') }) test('Download File', async () => { diff --git a/Services/client/tests/listviewdelete.spec.ts b/Services/client/tests/listviewdelete.spec.ts new file mode 100644 index 0000000..d400756 --- /dev/null +++ b/Services/client/tests/listviewdelete.spec.ts @@ -0,0 +1,168 @@ +import { test, expect, Page } from '@playwright/test' +import { nanoid } from 'nanoid' +import { Directive } from 'vue' +test.describe.configure({ mode: 'serial' }) + +let page: Page + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage() +}) + +test.afterAll(async () => { + await page.close() +}) + +test('Login', async ({}) => { + await page.goto('http://localhost:3010/admin') + await expect(page).toHaveTitle('Sign in to EDM') + await page.fill("input[name='username']", 'admin') + await page.fill("input[name='password']", 'P@ssw0rd') + await page.click("input[name='login']") +}) + +test('listViewMode', async () => { + await page.click("//i[text()='view_list']") +}) + + +test('Create Cabinet', async () => { + await page.click("//span[text()='สร้างตู้เก็บเอกสาร']") + await page.fill("//input[@placeholder='กรอกชื่อ']", 'oat-test') + await page.click("//button[@type='submit']") +}) + +test('Go into Cabinet', async () => { + await page.click('//td[contains(text(),"oat-test")]') +}) + +test('Create Drawer', async () => { + await page.click("//span[text()='สร้างลิ้นชัก']") + await page.fill("(//input[@class='q-field__native q-placeholder'])[2]", 'oat-drawer') + await page.click("(//button[@type='submit'])") +}) + +test('Go into Drawer', async () => { + await page.click("//table[@class='q-table']/tbody[1]/tr[1]/td[1]") +}) + +test('Create Folder', async () => { + await page.click("//span[text()='สร้างแฟ้ม']") + await page.fill("(//input[@class='q-field__native q-placeholder'])[2]", 'oat-folder') + await page.click("(//button[@type='submit'])") +}) + +test('Go into Folder', async () => { + await page.click("//table[@class='q-table']/tbody[1]/tr[1]/td[1]") +}) + +test('Create subFolder', async () => { + await page.click("//span[text()='สร้างแฟ้มย่อย']") + await page.fill("(//input[@class='q-field__native q-placeholder'])[2]","oat-subfolder") + await page.click("//span[text()='บันทึก']") +}) + +test('Go into SubFolder', async () => { + await page.click("//table[@class='q-table']") +}) + +test('Upload File in SubFolder Level', async () => { + await page.click("//span[text()='สร้างเอกสาร']") + await page.locator("//input[@type='file']").setInputFiles('tests/test.docx') + await page.fill("//input[@placeholder='กรอกชื่อเรื่อง']",'oattestfile') + await page.click("(//button[@type='submit'])[1]") + await page.waitForTimeout(2500) + await page.click("button#getFolder") + await page.waitForTimeout(1000) +}) + +test('Go into File', async () => { + await page.click('//td[contains(text(),"test.docx")]') +}) + +test('Download File', async () => { + await page.click("//span[text()='ดาวน์โหลด']") + await page.waitForTimeout(2000) +}) + +test('Go Back to SubFolder', async () => { + await page.click("//i[text()='arrow_back']") +}) + +test('Delele file on SubFolder', async () => { + await page.click("//button[@data-testid='listViewFileDelete']") + await page.click("//span[text()='ลบ']") +}) + +test('Go back to Folder Level', async () => { + await page.click("//i[text()='arrow_back']") +}) + +test('Delete SubFolder', async () => { + await page.click("//button[@data-testid='oat-subfolder']") + await page.click("//span[text()='ลบ']") +}) + +test('Upload File in Folder Level', async () => { + await page.click("//span[text()='สร้างเอกสาร']") + await page.locator("//input[@type='file']").setInputFiles('tests/searchtest.txt') + await page.fill("//input[@placeholder='กรอกชื่อเรื่อง']",'testtext') + await page.click("(//button[@type='submit'])[1]") + await page.waitForTimeout(2500) + await page.click("button#getFolder") + await page.waitForTimeout(1000) +}) + +test('Go into Text File', async () => { + await page.click('//td[contains(text(),"searchtest.txt")]') +}) + +test('Download File Text', async () => { + await page.click("//span[text()='ดาวน์โหลด']") + await page.waitForTimeout(2000) +}) + +test('Go back to Folder Level Again', async () => { + await page.click("//i[text()='arrow_back']") +}) + +test('Delele file on Folder', async () => { + await page.click("//button[@data-testid='listViewFileDelete']") + await page.click("//span[text()='ลบ']") +}) + +test('Go back to Drawer Level', async () => { + await page.click("//i[text()='arrow_back']") +}) + +test('Delete Folder', async () => { + await page.click("//button[@data-testid='oat-folder']") + await page.click("//span[text()='ลบ']") +}) + +test('Go back to Cabinet Level', async () => { + await page.click("//i[text()='arrow_back']") +}) + +test('Delete Drawer', async () => { + await page.click("//button[@data-testid='oat-drawer']") + await page.click("//span[text()='ลบ']") +}) + +test('Go back to Main Level', async () => { + await page.click("//i[text()='arrow_back']") +}) + +test('Delete Cabinet', async () => { + await page.click("//button[@data-testid='oat-test']") + await page.click("//span[text()='ลบ']") + await page.waitForTimeout(1000) +}) + + +// test('Delete Cabinet', async () => { +// await page.click("//button[@data-testid='oat-test']") +// await page.click("//span[text()='ลบ']") +// await page.waitForTimeout(2000) +// }) + diff --git a/Services/client/tests/searchtest.txt b/Services/client/tests/searchtest.txt new file mode 100644 index 0000000..4dd29f5 --- /dev/null +++ b/Services/client/tests/searchtest.txt @@ -0,0 +1,2 @@ +หาเจอป่าว รายรับ รายจ่าย สวัสดี กินข้าว หิว อิ่ม ราชการ นอน ตื่น กระโดด วิ่ง โทรศัพท์ คอมพิวเตอร์ เอกสาร แฟ้ม โฟลเดอร์ ประตู ตู้เก็บของ ตู้เสื้อผ้า +ปลั้กไฟ ตู้เย็น ปากกา ดินสอ ยางลบ กบเหลา \ No newline at end of file