|
5 | 5 |
|
6 | 6 | import { test, expect } from '../support/fixtures' |
7 | 7 | import { createRandomUser } from '../support/api' |
8 | | -import { createTable, deleteTable, loadTable } from '../support/commands' |
| 8 | +import { createTable, createTextLineColumn, deleteTable, loadTable } from '../support/commands' |
9 | 9 | import { login } from '../support/login' |
10 | 10 |
|
11 | 11 | test.describe('Manage a table', () => { |
@@ -42,7 +42,7 @@ test.describe('Manage a table', () => { |
42 | 42 | await page.getByRole('menuitem', { name: 'Edit table' }).click() |
43 | 43 |
|
44 | 44 | await expect(page.locator('[data-cy="editTableModal"]')).toBeVisible() |
45 | | - await page.locator('.modal__content #description-editor .tiptap.ProseMirror').fill('Updated ToDo List description') |
| 45 | + await page.locator('#description-editor .tiptap.ProseMirror').fill('Updated ToDo List description') |
46 | 46 | await expect(page.locator('[data-cy="editTableSaveBtn"]')).toBeEnabled() |
47 | 47 | await page.locator('[data-cy="editTableSaveBtn"]').click() |
48 | 48 |
|
@@ -110,4 +110,81 @@ test.describe('Manage a table', () => { |
110 | 110 | await page.goto('/index.php/apps/tables') |
111 | 111 | await expect(page.locator('.app-navigation__list').filter({ hasText: 'test table' })).toBeVisible() |
112 | 112 | }) |
| 113 | + |
| 114 | + test('Set column order in Edit Table modal', async ({ userPage: { page } }) => { |
| 115 | + await page.goto('/index.php/apps/tables') |
| 116 | + await createTable(page, 'Column order test table') |
| 117 | + await createTextLineColumn(page, 'colFirst', '', '', true) |
| 118 | + await createTextLineColumn(page, 'colSecond', '', '', false) |
| 119 | + |
| 120 | + const tableItem = page.locator('[data-cy="navigationTableItem"]').filter({ hasText: 'Column order test table' }).first() |
| 121 | + await tableItem.getByRole('button', { name: /Actions|Open menu/i }).click({ force: true }) |
| 122 | + await page.getByRole('menuitem', { name: 'Edit table' }).click() |
| 123 | + |
| 124 | + await expect(page.locator('[data-cy="editTableModal"]')).toBeVisible() |
| 125 | + |
| 126 | + const columnOrderSection = page.locator('#settings-section_column-order') |
| 127 | + await columnOrderSection.scrollIntoViewIfNeeded() |
| 128 | + |
| 129 | + const columnEntries = columnOrderSection.locator('.column-entry') |
| 130 | + await expect(columnEntries.filter({ hasText: 'colFirst' })).toBeVisible() |
| 131 | + await expect(columnEntries.filter({ hasText: 'colSecond' })).toBeVisible() |
| 132 | + |
| 133 | + // Move colFirst down so colSecond becomes first |
| 134 | + const colFirstEntry = columnEntries.filter({ hasText: 'colFirst' }) |
| 135 | + await colFirstEntry.hover() |
| 136 | + await colFirstEntry.getByRole('button', { name: 'Move down' }).click() |
| 137 | + |
| 138 | + await expect(columnEntries.nth(0)).toContainText('colSecond') |
| 139 | + await expect(columnEntries.nth(1)).toContainText('colFirst') |
| 140 | + |
| 141 | + const updateReqPromise = page.waitForResponse( |
| 142 | + (response) => response.url().includes('/apps/tables/api/2/tables/') && response.request().method() === 'PUT', |
| 143 | + ) |
| 144 | + await page.locator('[data-cy="editTableSaveBtn"]').click() |
| 145 | + const updateResponse = await updateReqPromise |
| 146 | + expect(updateResponse.ok()).toBeTruthy() |
| 147 | + const body = await updateResponse.json() |
| 148 | + expect(body.ocs.data.columnOrder).toHaveLength(2) |
| 149 | + |
| 150 | + await expect(page.locator('.toastify.toast-success').first()).toBeVisible() |
| 151 | + }) |
| 152 | + |
| 153 | + test('Set default sort in Edit Table modal', async ({ userPage: { page } }) => { |
| 154 | + await page.goto('/index.php/apps/tables') |
| 155 | + await createTable(page, 'Default sort test table') |
| 156 | + await createTextLineColumn(page, 'name', '', '', true) |
| 157 | + |
| 158 | + const tableItem = page.locator('[data-cy="navigationTableItem"]').filter({ hasText: 'Default sort test table' }).first() |
| 159 | + await tableItem.getByRole('button', { name: /Actions|Open menu/i }).click({ force: true }) |
| 160 | + await page.getByRole('menuitem', { name: 'Edit table' }).click() |
| 161 | + |
| 162 | + await expect(page.locator('[data-cy="editTableModal"]')).toBeVisible() |
| 163 | + |
| 164 | + const defaultSortSection = page.locator('#settings-section_default-sort') |
| 165 | + await defaultSortSection.scrollIntoViewIfNeeded() |
| 166 | + |
| 167 | + await defaultSortSection.getByRole('button', { name: 'Add new sorting rule' }).click() |
| 168 | + |
| 169 | + const sortEntry = defaultSortSection.locator('.sort-entry').first() |
| 170 | + await sortEntry.locator('.select-field').click() |
| 171 | + await page.locator('ul.vs__dropdown-menu li span[title="name"]').click() |
| 172 | + |
| 173 | + await expect(sortEntry.locator('.checkbox-radio-switch__input[value="ASC"]')).toBeChecked() |
| 174 | + |
| 175 | + await sortEntry.locator('.checkbox-radio-switch__label').filter({ hasText: 'Descending' }).click() |
| 176 | + await expect(sortEntry.locator('.checkbox-radio-switch__input[value="DESC"]')).toBeChecked() |
| 177 | + |
| 178 | + const updateReqPromise = page.waitForResponse( |
| 179 | + (response) => response.url().includes('/apps/tables/api/2/tables/') && response.request().method() === 'PUT', |
| 180 | + ) |
| 181 | + await page.locator('[data-cy="editTableSaveBtn"]').click() |
| 182 | + const updateResponse = await updateReqPromise |
| 183 | + expect(updateResponse.ok()).toBeTruthy() |
| 184 | + const body = await updateResponse.json() |
| 185 | + expect(body.ocs.data.sort).toHaveLength(1) |
| 186 | + expect(body.ocs.data.sort[0].mode).toBe('DESC') |
| 187 | + |
| 188 | + await expect(page.locator('.toastify.toast-success').first()).toBeVisible() |
| 189 | + }) |
113 | 190 | }) |
0 commit comments