diff --git a/Makefile b/Makefile index de8e6fc95..42b1d2ae5 100644 --- a/Makefile +++ b/Makefile @@ -63,8 +63,8 @@ E2EDrecordRelatedTable=test/e2e/specs/all-features/record/related-table.config.t E2EDrecordLinks=test/e2e/specs/default-config/record/links.config.ts # Recordset tests E2EDrecordset=test/e2e/specs/all-features-confirmation/recordset/presentation.config.ts -E2EDrecordsetEdit=test/e2e/specs/default-config/recordset/edit.conf.js -E2ErecordsetAdd=test/e2e/specs/default-config/recordset/add.conf.js +E2EDrecordsetEdit=test/e2e/specs/default-config/recordset/edit.config.ts +E2ErecordsetAdd=test/e2e/specs/default-config/recordset/add.config.ts E2EDrecordsetIndFacet=test/e2e/specs/delete-prohibited/recordset/facet.config.ts E2EDrecordsetHistFacet=test/e2e/specs/delete-prohibited/recordset/histogram-facet.config.ts E2ErecordsetSavedQuery=test/e2e/specs/all-features/recordset/saved-query.config.ts @@ -89,7 +89,6 @@ DefaultConfigParallel=test/e2e/specs/default-config/playwright.config.ts Manualrecordset=test/manual/specs/recordset.conf.js # protractor tests -RECORDSET_TESTS_PROTRACTOR=$(E2ErecordsetAdd) $(E2EDrecordsetEdit) RECORDADD_TESTS_PROTRACTOR=$(E2EDIrecordMultiFormInput) $(E2EDIrecordImmutable) RECORDEDIT_TESTS_PROTRACTOR=$(E2EDrecordEditSubmissionDisabled) DEFAULT_CONFIG_PARALLEL_TESTS_PROTRACTOR=$(DefaultConfigParallel_PROTRACTOR) @@ -99,7 +98,7 @@ ALL_TESTS_PROTRACTOR=$(RECORDSET_TESTS_PROTRACTOR) $(RECORDADD_TESTS_PROTRACTOR) # playwright tests NAVBAR_TESTS=$(E2Enavbar) $(E2EnavbarHeadTitle) $(E2EnavbarCatalogConfig) RECORD_TESTS=$(E2EDrecord) $(E2ErecordNoDeleteBtn) $(E2EDrecordRelatedTable) $(E2EDrecordCopy) $(E2EDrecordLinks) -RECORDSET_TESTS=$(E2EDrecordset) $(E2ErecordsetSavedQuery) $(E2EDrecordsetIndFacet) $(E2EDrecordsetHistFacet) +RECORDSET_TESTS=$(E2EDrecordset) $(E2ErecordsetAdd) $(E2EDrecordsetEdit) $(E2ErecordsetSavedQuery) $(E2EDrecordsetIndFacet) $(E2EDrecordsetHistFacet) RECORDADD_TESTS=$(E2EDIrecordAdd) $(E2EDIrecordMultiFormInput) $(E2ErecordEditForeignKeyDropdown) $(E2EDrecordEditCompositeKey) RECORDEDIT_TESTS=$(E2EDIrecordEdit) $(E2EDrecordEditNullValues) $(E2ErecordEditInputIframe) $(E2EDrecordEditDomainFilter) PERMISSIONS_TESTS=$(E2EmultiPermissionsVisibility) @@ -170,9 +169,6 @@ testpermissions:test-PERMISSIONS_TESTS .PHONY: testrecordset testrecordset: test-RECORDSET_TESTS -.PHONY: testrecordset-protractor -testrecordset-protractor: test_protractor-RECORDSET_TESTS_PROTRACTOR - #Rule to run the default chaise configuration tests in parallel .PHONY: testfooter testfooter: test-FOOTER_TESTS diff --git a/test/e2e/locators/recordset.ts b/test/e2e/locators/recordset.ts index 82f94a4dc..55818761d 100644 --- a/test/e2e/locators/recordset.ts +++ b/test/e2e/locators/recordset.ts @@ -59,6 +59,10 @@ export default class RecordsetLocators { return this.getPageTitleElement(container).locator('.chaise-icon-for-tooltip'); } + static getPageTitleInlineComment(container: Page | Locator): Locator { + return this.getPageTitleElement(container).locator('.inline-tooltip'); + }; + static getPermalinkButton(container: Page | Locator): Locator { return container.locator('#permalink'); } @@ -269,6 +273,10 @@ export default class RecordsetLocators { return RecordsetLocators.getRows(container).nth(rowIndex).locator('td').nth(0).locator('.select-action-button'); } + static getReadMore(container: Page | Locator): Locator { + return container.locator('.readmore'); + } + // ---------------- facet panel selectors ------------------ // diff --git a/test/e2e/specs/default-config/recordset/add.conf.js b/test/e2e/specs/default-config/recordset/add.conf.js deleted file mode 100644 index fd30fd36e..000000000 --- a/test/e2e/specs/default-config/recordset/add.conf.js +++ /dev/null @@ -1,15 +0,0 @@ -var pConfig = require('./../../../utils/protractor.configuration.js'); - -var config = pConfig.getConfig({ - configFileName: 'recordset/add.dev.json', - chaiseConfigFilePath: 'test/e2e/specs/default-config/chaise-config.js', - specs: [ - "add.spec.js" - ], - setBaseUrl: function(browser, data) { - browser.params.url = process.env.CHAISE_BASE_URL; - return browser.params.url; - } -}); - -exports.config = config; diff --git a/test/e2e/specs/default-config/recordset/add.config.ts b/test/e2e/specs/default-config/recordset/add.config.ts new file mode 100644 index 000000000..32e372833 --- /dev/null +++ b/test/e2e/specs/default-config/recordset/add.config.ts @@ -0,0 +1,10 @@ +import getConfig from '@isrd-isi-edu/chaise/test/e2e/setup/playwright.configuration'; + +export default getConfig({ + testName: 'default-config/recordset/add', + configFileName: 'recordset/add.dev.json', + mainSpecName: 'default-config', + testMatch: [ + 'add.spec.ts' + ] +}); diff --git a/test/e2e/specs/default-config/recordset/add.spec.js b/test/e2e/specs/default-config/recordset/add.spec.js deleted file mode 100644 index 89326ca2e..000000000 --- a/test/e2e/specs/default-config/recordset/add.spec.js +++ /dev/null @@ -1,188 +0,0 @@ -// TODO can be combined with recordset/edit.spec.js -var chaisePage = require('../../../utils/chaise.page.js'); -var moment = require('moment'); -var testParams = { - schemaName: "product-recordset-add", - table_name: "accommodation", - num_rows: 6, - title: "Best Western Plus Amedia Art Salzburg", - rating: "3.50", - summary: "The BEST WESTERN PLUS Amedia Art Salzburg is located near the traditional old part of town, near the highway, near the train station and close to the exhibition center of Salzburg.\nBEST WESTERN PLUS Amedia Art Salzburg offers harmony of modern technique and convenient atmosphere to our national and international business guest and tourists." -}; - -describe('Recordset add record,', function() { - - var allWindows;; - - beforeAll(function () { - chaisePage.navigate(browser.params.url + "/recordset/#" + browser.params.catalogId + "/" + testParams.schemaName + ":" + testParams.table_name); - chaisePage.recordsetPageReady(); - - // the truncation test sometimes would fail because it was running before rows show up - browser.wait(function () { - return chaisePage.recordsetPage.getRows().count().then(function (ct) { - return (ct > 0) - }); - }); - }); - - - it("show an inline comment instead of tooltip", function () { - expect(chaisePage.recordsetPage.getPageTitleInlineComment().getText()).toBe("Recordset inline comment", "inline comment is not shown or is incorrect"); - }); - - it("verify the text is truncated properly based on the default config, then not truncated after clicking 'more'", function (done) { - // default config: maxRecordsetRowHeight = 160 - // 160 for max height, 10 for padding - var testCell, cellHeight = 170; - chaisePage.recordsetPage.getRows().then(function (rows) { - return chaisePage.recordsetPage.getRowCells(rows[0]); - }).then(function (cells) { - testCell = cells[4]; - expect(testCell.getText()).toContain("... more"); - - return testCell.getSize(); - }).then(function (dimensions) { - // the calculations might be one pixel off - expect(Math.abs(dimensions.height - cellHeight) <= 1).toBeTruthy(); - return testCell.element(by.css(".readmore")).click(); - }).then(function () { - expect(testCell.getText()).toContain("... less"); - - return testCell.getSize(); - }).then(function (tallerDimensions) { - expect(tallerDimensions.height).toBeGreaterThan(cellHeight); - done(); - }).catch(function (err) { - console.log(err); - done.fail(err); - }); - }); - - it("verify view details link, search for a term, then verify view details link has changed", function (done) { - var baseUrl = '/record/#' + browser.params.catalogId + "/" + testParams.schemaName + ":" + testParams.table_name + "/RID="; - - chaisePage.recordsetPage.getRows().then(function (rows) { - var dataRow = browser.params.entities[testParams.schemaName][testParams.table_name].find(function (entity) { - return entity.id == 2003; - }); - // get first row view details button - expect(rows[0].element(by.css('.view-action-button')).getAttribute("href")).toContain(baseUrl + dataRow.RID, "View button url is incorrect before searching set"); - - // search for a row that is not the first one after sorting - chaisePage.recordsetPage.getMainSearchInput().sendKeys('hilton'); - return chaisePage.recordsetPage.getSearchSubmitButton().click(); - }).then(function() { - chaisePage.recordsetPage.waitForInverseMainSpinner(); - browser.wait(function () { - return chaisePage.recordsetPage.getRows().count().then(function (ct) { - return (ct == 1) - }); - }); - return chaisePage.recordsetPage.getRows(); - }).then(function(rows) { - expect(rows.length).toBe(1); - - var dataRow = browser.params.entities[testParams.schemaName][testParams.table_name].find(function (entity) { - return entity.id == 4004; - }); - // get first row view details button - expect(rows[0].element(by.css('.view-action-button')).getAttribute("href")).toContain(baseUrl + dataRow.RID, "View button url is incorrect after searching set"); - - // clear search - return chaisePage.recordsetPage.getSearchClearButton().click(); - }).then(function () { - done(); - }).catch(chaisePage.catchTestError(done)); - }); - - var allWindows; - it("click on the add button should open a new tab to recordedit", function(done) { - var rows; - var EC = protractor.ExpectedConditions; - var addRecordLink = chaisePage.recordsetPage.getAddRecordLink(); - browser.wait(EC.presenceOf(addRecordLink), browser.params.defaultTimeout); - - addRecordLink.click().then(function() { - return browser.getAllWindowHandles(); - }).then(function (handles) { - allWindows = handles; - return browser.switchTo().window(allWindows[1]); - }).then(function () { - chaisePage.waitForElement(element(by.id('submit-record-button'))); - return browser.driver.getCurrentUrl(); - }).then(function (url) { - - var recordeditUrl = '/recordedit/#' + browser.params.catalogId + "/" + testParams.schemaName + ":" + testParams.table_name; - expect(url).toContain(recordeditUrl, "url missmatch"); - - // set the required fields - return chaisePage.recordsetPage.getInputForAColumn("title"); - }).then(function(input) { - input.sendKeys(testParams.title); - - return chaisePage.recordsetPage.getModalPopupBtn('Category', 1); - }).then(function(btn) { - return btn.click(); - }).then(function() { - return chaisePage.recordsetPageReady(); - }).then(function() { - rows = chaisePage.recordsetPage.getRows(); - - return browser.wait(function () { - return rows.count().then(function (ct) { - return (ct == 5) - }); - }); - }).then(function () { - return rows.get(0).all(by.css(".select-action-button")); - }).then(function(selectButtons) { - selectButtons[0].click(); - }).then(function() { - return chaisePage.recordsetPage.getInputForAColumn("rating"); - }).then(function(input) { - input.sendKeys(testParams.rating); - return chaisePage.recordEditPage.getTextAreaForAColumn("summary"); - }).then(function(input) { - input.sendKeys(testParams.summary); - return chaisePage.recordEditPage.getTimestampInputsForAColumn('opened_on', 1).nowBtn.click(); - }).then (function () { - return chaisePage.recordEditPage.submitForm(); - }).then(function() { - // wait until redirected to record page - chaisePage.waitForElement(element(by.css(".record-main-section-table"))); - done(); - }).catch(function (err) { - done.fail(err); - }) - }); - - it("go back to recordset should refresh the table with the new record", function(done) { - // ... before closing this new tab and switching back to the original Record app's tab so that the next it spec can run properly - /** - * we noticed this test case started failing on saucelabs, - * that's why we're switching tabs twice to ensure the onfocus is getting called. - */ - browser.switchTo().window(allWindows[0]).then(function() { - return browser.switchTo().window(allWindows[1]); - }).then(function () { - return browser.switchTo().window(allWindows[0]); - }).then(function () { - return chaisePage.waitForElementInverse(element(by.id("spinner"))); - }).then(function() { - return chaisePage.recordsetPage.getPageTitleElement().click(); - }).then(function () { - return browser.wait(function() { - return chaisePage.recordsetPage.getRows().count().then(function(ct) { - return (ct == testParams.num_rows+1); - }); - }, browser.params.defaultTimeout); - }).then(function () { - return chaisePage.recordsetPage.getRows(); - }).then(function(rows) { - expect(rows.length).toBe(testParams.num_rows+1); - done(); - }).catch(chaisePage.catchTestError(done)); - }) - -}); diff --git a/test/e2e/specs/default-config/recordset/add.spec.ts b/test/e2e/specs/default-config/recordset/add.spec.ts new file mode 100644 index 000000000..806a7245d --- /dev/null +++ b/test/e2e/specs/default-config/recordset/add.spec.ts @@ -0,0 +1,130 @@ +/* eslint-disable max-len */ +import { expect, test, Page } from '@playwright/test'; + +// locators +import RecordLocators from '@isrd-isi-edu/chaise/test/e2e/locators/record'; +import RecordeditLocators, { RecordeditInputType } from '@isrd-isi-edu/chaise/test/e2e/locators/recordedit'; +import RecordsetLocators from '@isrd-isi-edu/chaise/test/e2e/locators/recordset'; + +// utils +import { getCatalogID, getEntityRow } from '@isrd-isi-edu/chaise/test/e2e/utils/catalog-utils'; +import { clickNewTabLink, manuallyTriggerFocus } from '@isrd-isi-edu/chaise/test/e2e/utils/page-utils'; +import { setInputValue } from '@isrd-isi-edu/chaise/test/e2e/utils/recordedit-utils'; + +const testParams = { + schema_name: 'product-recordset-add', + table_name: 'accommodation', + num_rows: 6, + title: 'Best Western Plus Amedia Art Salzburg', + rating: '3.50', + summary: 'The BEST WESTERN PLUS Amedia Art Salzburg is located near the traditional old part of town, near the highway, near the train station and close to the exhibition center of Salzburg.\nBEST WESTERN PLUS Amedia Art Salzburg offers harmony of modern technique and convenient atmosphere to our national and international business guest and tourists.' +}; + +test('Recordset add record', async ({ page, baseURL }, testInfo) => { + const PAGE_URL = `/recordset/#${getCatalogID(testInfo.project.name)}/${testParams.schema_name}:${testParams.table_name}`; + + let firstRow, testCell: any, dimensions; + await test.step('should load recordset page', async () => { + await page.goto(`${baseURL}${PAGE_URL}`); + await RecordsetLocators.waitForRecordsetPageReady(page); + + await expect.soft(RecordsetLocators.getRows(page)).toHaveCount(6); + }); + + await test.step('show an inline comment instead of tooltip', async () => { + await expect.soft(RecordsetLocators.getPageTitleInlineComment(page)).toHaveText('Recordset inline comment'); + }); + + await test.step('verify the text is truncated and "... more" is showing', async () => { + firstRow = RecordsetLocators.getRows(page).nth(0); + testCell = RecordsetLocators.getRowCells(firstRow).nth(4); + await expect.soft(testCell).toHaveText(/... more/); + }); + + // default config: maxRecordsetRowHeight = 160 + // 160 for max height, 10 for padding + const cellHeight = 170; + await test.step('the cell with text has the expected height when truncated', async () => { + dimensions = await testCell.boundingBox(); + expect.soft(dimensions).toBeDefined(); + + if (dimensions) { + // the calculations might be one pixel off + expect.soft(Math.abs(dimensions.height - cellHeight)).toBeLessThanOrEqual(1); + } + }); + + await test.step('click "... more" and verify "... less" shows up', async () => { + await RecordsetLocators.getReadMore(testCell).click(); + await expect.soft(testCell).toHaveText(/... less/); + }); + + await test.step('the cell with text is expanded with a new height', async () => { + dimensions = await testCell.boundingBox(); + expect.soft(dimensions).toBeDefined(); + + if (dimensions) { + expect.soft(dimensions.height).toBeGreaterThan(cellHeight); + }; + }); + + await test.step('click on "... less" and verify the content is truncated again', async() => { + await RecordsetLocators.getReadMore(testCell).click(); + await expect.soft(testCell).toHaveText(/... more/); + }); + + await test.step('verify view details link, search for a term, then verify view details link has changed', async () => { + const baseViewUrl = `${PAGE_URL.replace('recordset', 'record')}/RID=`; + + let keyValues = [{ column: 'id', value: '2003' }]; + let rowRID = getEntityRow(testInfo, testParams.schema_name, testParams.table_name, keyValues).RID; + // get first row view details button + expect.soft(await RecordsetLocators.getRowViewButton(page, 0).getAttribute('href')).toContain(`${baseURL}${baseViewUrl}${rowRID}`); + + // search for a row that is not the first one after sorting + await RecordsetLocators.getMainSearchInput(page).fill('hilton'); + await RecordsetLocators.getSearchSubmitButton(page).click(); + + await RecordsetLocators.waitForRecordsetPageReady(page); + await expect.soft(RecordsetLocators.getRows(page)).toHaveCount(1); + + keyValues = [{ column: 'id', value: '4004' }]; + rowRID = getEntityRow(testInfo, testParams.schema_name, testParams.table_name, keyValues).RID; + // get first row view details button + expect.soft(await RecordsetLocators.getRowViewButton(page, 0).getAttribute('href')).toContain(`${baseURL}${baseViewUrl}${rowRID}`); + + // clear search + await RecordsetLocators.getSearchClearButton(page).click(); + }); + + let newPage: Page; + await test.step('click on the add button should open a new tab to recordedit', async () => { + newPage = await clickNewTabLink(RecordsetLocators.getAddRecordsLink(page)); + + await RecordeditLocators.waitForRecordeditPageReady(newPage); + + + const recordeditUrl = PAGE_URL.replace('recordset', 'recordedit'); + expect.soft(newPage.url()).toContain(recordeditUrl); + + // set the required fields + await setInputValue(newPage, 1, 'title', 'Title', RecordeditInputType.TEXT, testParams.title); + await setInputValue(newPage, 1, 'category', 'Category', RecordeditInputType.FK_POPUP, {modal_num_rows: 5, modal_option_index: 0}); + await setInputValue(newPage, 1, 'rating', 'Rating', RecordeditInputType.TEXT, testParams.rating); + await setInputValue(newPage, 1, 'summary', 'Summary', RecordeditInputType.LONGTEXT, testParams.summary); + await RecordeditLocators.getTimestampInputsForAColumn(newPage, 'opened_on', 1).nowBtn.click(); + + await RecordeditLocators.submitForm(newPage); + // wait until redirected to record page + await RecordLocators.waitForRecordPageReady(newPage); + }); + + await test.step('go back to recordset should refresh the table with the new record', async () => { + if (!newPage) return; + + await newPage.close(); + await manuallyTriggerFocus(page); + + await expect.soft(RecordsetLocators.getRows(page)).toHaveCount(testParams.num_rows+1); + }); +}); diff --git a/test/e2e/specs/default-config/recordset/edit.conf.js b/test/e2e/specs/default-config/recordset/edit.conf.js deleted file mode 100644 index 371a1d987..000000000 --- a/test/e2e/specs/default-config/recordset/edit.conf.js +++ /dev/null @@ -1,16 +0,0 @@ -var pConfig = require('./../../../utils/protractor.configuration.js'); - -var config = pConfig.getConfig({ - configFileName: 'recordset/edit.dev.json', - chaiseConfigFilePath: 'test/e2e/specs/default-config/chaise-config.js', - specs: [ - "edit.spec.js" - ], - setBaseUrl: function(browser, data) { - browser.params.url = process.env.CHAISE_BASE_URL; - return browser.params.url; - } - -}); - -exports.config = config; diff --git a/test/e2e/specs/default-config/recordset/edit.config.ts b/test/e2e/specs/default-config/recordset/edit.config.ts new file mode 100644 index 000000000..0ddccfabc --- /dev/null +++ b/test/e2e/specs/default-config/recordset/edit.config.ts @@ -0,0 +1,10 @@ +import getConfig from '@isrd-isi-edu/chaise/test/e2e/setup/playwright.configuration'; + +export default getConfig({ + testName: 'default-config/recordset/edit', + configFileName: 'recordset/edit.dev.json', + mainSpecName: 'default-config', + testMatch: [ + 'edit.spec.ts' + ] +}); diff --git a/test/e2e/specs/default-config/recordset/edit.spec.js b/test/e2e/specs/default-config/recordset/edit.spec.js deleted file mode 100644 index 9cf9e4591..000000000 --- a/test/e2e/specs/default-config/recordset/edit.spec.js +++ /dev/null @@ -1,135 +0,0 @@ -var chaisePage = require('../../../utils/chaise.page.js'); -var testParams = { - schemaName: "recordset-multi-edit", - table_name: "multi-edit-table", - default_page_limit: 25, - limit: 10, - int_23_count: 11 -}; - -describe('Recordset edit records,', function() { - - describe("recordset shows results with no limit defined,", function() { - beforeAll(function() { - chaisePage.navigate(browser.params.url + "/recordset/#" + browser.params.catalogId + "/" + testParams.schemaName + ":" + testParams.table_name); - - chaisePage.recordsetPageReady() - }); - - it("clicking edit will show forms based on the default page size of " + testParams.default_page_limit + ".", function() { - browser.wait(function() { - return chaisePage.recordsetPage.getRows().count().then(function(ct) { - return (ct == testParams.default_page_limit); - }); - }, browser.params.defaultTimeout); - - chaisePage.recordsetPage.getRows().count().then(function(ct) { - expect(ct).toBe(testParams.default_page_limit); - - return chaisePage.recordsetPage.getEditRecordLink().click(); - }).then(function() { - browser.wait(function() { - return chaisePage.recordEditPage.getRecordeditForms().count().then(function(ct) { - return (ct == testParams.default_page_limit); - }); - }, browser.params.defaultTimeout); - - return chaisePage.recordEditPage.getRecordeditForms().count(); - }).then(function(count) { - expect(count).toBe(testParams.default_page_limit); - }); - }); - }); - - describe("recordset url includes a limit,", function() { - beforeAll(function() { - chaisePage.navigate(browser.params.url + "/recordset/#" + browser.params.catalogId + "/" + testParams.schemaName + ":" + testParams.table_name + "?limit=" + testParams.limit); - - chaisePage.recordsetPageReady() - }); - - it("clicking edit will show forms based on the limit of " + testParams.limit + " in the uri.", function() { - browser.wait(function() { - return chaisePage.recordsetPage.getRows().count().then(function(ct) { - return (ct == testParams.limit); - }); - }, browser.params.defaultTimeout); - - chaisePage.recordsetPage.getRows().count().then(function(ct) { - expect(ct).toBe(testParams.limit); - - return chaisePage.recordsetPage.getEditRecordLink().click(); - }).then(function() { - browser.wait(function() { - return chaisePage.recordEditPage.getRecordeditForms().count().then(function(ct) { - return (ct == testParams.limit); - }); - }, browser.params.defaultTimeout); - - return chaisePage.recordEditPage.getRecordeditForms().count(); - }).then(function(count) { - expect(count).toBe(testParams.limit); - }); - }); - }); - - describe("recordset url includes a filter of int=23", function() { - beforeAll(function() { - chaisePage.navigate(browser.params.url + "/recordset/#" + browser.params.catalogId + "/" + testParams.schemaName + ":" + testParams.table_name + "/int=23"); - - chaisePage.recordsetPageReady() - }); - - it("without a limit, clicking edit will show all forms with int=23.", function() { - browser.wait(function() { - return chaisePage.recordsetPage.getRows().count().then(function(ct) { - return (ct == testParams.int_23_count); - }); - }, browser.params.defaultTimeout); - - chaisePage.recordsetPage.getRows().count().then(function(ct) { - expect(ct).toBe(testParams.int_23_count); - - return chaisePage.recordsetPage.getEditRecordLink().click(); - }).then(function() { - browser.wait(function() { - return chaisePage.recordEditPage.getRecordeditForms().count().then(function(ct) { - return (ct == testParams.int_23_count); - }); - }, browser.params.defaultTimeout); - - return chaisePage.recordEditPage.getRecordeditForms().count(); - }).then(function(count) { - expect(count).toBe(testParams.int_23_count); - }); - }); - - it("with a limit of " + testParams.limit + ", clicking edit will show all forms with int=23.", function() { - chaisePage.navigate(browser.params.url + "/recordset/#" + browser.params.catalogId + "/" + testParams.schemaName + ":" + testParams.table_name + "/int=23?limit=" + testParams.limit); - - chaisePage.recordsetPageReady() - - browser.wait(function() { - return chaisePage.recordsetPage.getRows().count().then(function(ct) { - return (ct == testParams.limit); - }); - }, browser.params.defaultTimeout); - - chaisePage.recordsetPage.getRows().count().then(function(ct) { - expect(ct).toBe(testParams.limit); - - return chaisePage.recordsetPage.getEditRecordLink().click(); - }).then(function() { - browser.wait(function() { - return chaisePage.recordEditPage.getRecordeditForms().count().then(function(ct) { - return (ct == testParams.limit); - }); - }, browser.params.defaultTimeout); - - return chaisePage.recordEditPage.getRecordeditForms().count(); - }).then(function(count) { - expect(count).toBe(testParams.limit); - }); - }); - }); -}); diff --git a/test/e2e/specs/default-config/recordset/edit.spec.ts b/test/e2e/specs/default-config/recordset/edit.spec.ts new file mode 100644 index 000000000..8132644d7 --- /dev/null +++ b/test/e2e/specs/default-config/recordset/edit.spec.ts @@ -0,0 +1,34 @@ +import { test } from '@playwright/test'; + +// utils +import { getCatalogID } from '@isrd-isi-edu/chaise/test/e2e/utils/catalog-utils'; +import { testBulkEditLink } from '@isrd-isi-edu/chaise/test/e2e/utils/recordset-utils'; + +const testParams = { + schema_name: 'recordset-multi-edit', + table_name: 'multi-edit-table', + default_page_limit: 25, + limit: 10, + int_23_count: 11 +}; + +test.describe('Recordset edit records', async () => { + test.describe.configure({ mode: 'parallel' }); + + const PAGE_URL = (projectName: string) => `/recordset/#${getCatalogID(projectName)}/${testParams.schema_name}:${testParams.table_name}` + test('recordset shows results with no limit defined', async ({ page, baseURL }, testInfo) => { + await testBulkEditLink(page, `${baseURL}${PAGE_URL(testInfo.project.name)}`, testParams.default_page_limit); + }); + + test('recordset url includes a limit', async ({ page, baseURL }, testInfo) => { + await testBulkEditLink(page, `${baseURL}${PAGE_URL(testInfo.project.name)}?limit=${testParams.limit}`, testParams.limit); + }); + + test('recordset url includes a filter of int=23 without a limit', async ({ page, baseURL }, testInfo) => { + await testBulkEditLink(page, `${baseURL}${PAGE_URL(testInfo.project.name)}/int=23`, testParams.int_23_count); + }); + + test(`recordset url includes a filter of int=23 with a limit of ${testParams.limit}`, async ({ page, baseURL }, testInfo) => { + await testBulkEditLink(page, `${baseURL}${PAGE_URL(testInfo.project.name)}/int=23?limit=${testParams.limit}`, testParams.limit); + }); +}); diff --git a/test/e2e/utils/recordset-utils.ts b/test/e2e/utils/recordset-utils.ts index 3652a053d..798e4a138 100644 --- a/test/e2e/utils/recordset-utils.ts +++ b/test/e2e/utils/recordset-utils.ts @@ -2,10 +2,13 @@ import { expect, Locator, Page, test } from '@playwright/test' // locators import ModalLocators from '@isrd-isi-edu/chaise/test/e2e/locators/modal'; +import RecordeditLocators from '@isrd-isi-edu/chaise/test/e2e/locators/recordedit'; import RecordsetLocators, { DefaultRangeInputLocators, TimestampRangeInputLocators } from '@isrd-isi-edu/chaise/test/e2e/locators/recordset'; + +// utils import { Either } from '@isrd-isi-edu/chaise/src/utils/type-utils'; type RecordsetColStringValue = { @@ -995,3 +998,24 @@ export async function testIndividualFacet(page: Page, pageSize: number, totalNum break; } } + +/** + * test navigating to recordset and clicking the bulk edit link to ensure the same number of rows are shown in both apps + * + * @param url recordset url to navigate to for this test + * @param count the count of recordset rows and recordedit forms + */ +export async function testBulkEditLink(page: Page, url: string, count: number) { + await test.step('should load recordset page', async () => { + await page.goto(`${url}`); + await RecordsetLocators.waitForRecordsetPageReady(page); + }); + + await test.step(`clicking edit will show ${count} forms.`, async () => { + await expect.soft(RecordsetLocators.getRows(page)).toHaveCount(count); + await RecordsetLocators.getBulkEditLink(page).click(); + + await RecordeditLocators.waitForRecordeditPageReady(page); + await expect.soft(RecordeditLocators.getRecordeditForms(page)).toHaveCount(count); + }); +}