diff --git a/qa-core/src/config/internal-api/TestConfiguration/applications.ts b/qa-core/src/config/internal-api/TestConfiguration/applications.ts index 1cfd025974..1cb9033984 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/applications.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/applications.ts @@ -153,4 +153,27 @@ export default class AppApi { expect(response).toHaveStatusCode(204) return [response] } + + async unlock(appId: string): Promise<[Response, responseMessage]> { + const response = await this.api.del(`/dev/${appId}/lock`) + const json = await response.json() + expect(response).toHaveStatusCode(200) + expect(json.message).toEqual("Lock released successfully.") + return [response, json] + } + + async updateIcon(appId: string): Promise<[Response, Application]> { + const body = { + icon: { + name: "ConversionFunnel", + color: "var(--spectrum-global-color-red-400)" + } + } + const response = await this.api.put(`/applications/${appId}`, { body }) + const json = await response.json() + expect(response).toHaveStatusCode(200) + expect(json.icon.name).toEqual(body.icon.name) + expect(json.icon.color).toEqual(body.icon.color) + return [response, json] + } } diff --git a/qa-core/src/config/internal-api/TestConfiguration/rows.ts b/qa-core/src/config/internal-api/TestConfiguration/rows.ts index 39ba01f467..435be85d56 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/rows.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/rows.ts @@ -15,7 +15,7 @@ export default class RowsApi { const json = await response.json() if (this.rowAdded) { expect(response).toHaveStatusCode(200) - expect(json.length).toEqual(1) + expect(json.length).toBeGreaterThanOrEqual(1) } return [response, json] } @@ -36,4 +36,22 @@ export default class RowsApi { expect(response).toHaveStatusCode(200) return [response, json] } + + async searchSinglePage(tableId: string, body: any): Promise<[Response, Row[]]> { + const response = await this.api.post(`/${tableId}/search`, { body }) + const json = await response.json() + expect(response).toHaveStatusCode(200) + expect(json.rows.length).toBeLessThanOrEqual(9) + expect(json.hasNextPage).toEqual(false) + return [response, json.rows] + } + + async searchMultiPage(tableId: string, body: any): Promise<[Response, Row[]]> { + const response = await this.api.post(`/${tableId}/search`, { body }) + const json = await response.json() + expect(response).toHaveStatusCode(200) + expect(json.hasNextPage).toEqual(true) + expect(json.rows.length).toEqual(10) + return [response, json.rows] + } } diff --git a/qa-core/src/config/internal-api/fixtures/rows.ts b/qa-core/src/config/internal-api/fixtures/rows.ts index 90f6350dcf..fbb965c215 100644 --- a/qa-core/src/config/internal-api/fixtures/rows.ts +++ b/qa-core/src/config/internal-api/fixtures/rows.ts @@ -6,3 +6,27 @@ export const generateNewRowForTable = (tableId: string): Row => { tableId: tableId, } } + +export const searchBody = (primaryDisplay: string): any => { + return { + bookmark: null, + limit: 10, + paginate: true, + query: { + contains: {}, + containsAny: {}, + empty: {}, + equal: {}, + fuzzy: {}, + notContains: {}, + notEmpty: {}, + notEqual: {}, + oneOf: {}, + range: {}, + string: {}, + }, + sort: primaryDisplay, + sortOrder: "ascending", + sortType: "string" + } +} \ No newline at end of file diff --git a/qa-core/src/tests/internal-api/applications/applications.spec.ts b/qa-core/src/tests/internal-api/applications/applications.spec.ts index 7d889b7e87..4edcd34ca4 100644 --- a/qa-core/src/tests/internal-api/applications/applications.spec.ts +++ b/qa-core/src/tests/internal-api/applications/applications.spec.ts @@ -104,6 +104,14 @@ describe("Internal API - Application creation, update, publish and delete", () = }) }) + it("Update the icon and color of an application", async () => { + const app = await config.applications.create(generateApp()) + + config.applications.api.appId = app.appId + + await config.applications.updateIcon(app.appId) + }) + it("POST - Revert Changes without changes", async () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId @@ -124,6 +132,7 @@ describe("Internal API - Application creation, update, publish and delete", () = // // Revert the app to published state await config.applications.revertPublished(app.appId) + await config.applications.unlock(app.appId) // Check screen is removed await config.applications.getRoutes() }) diff --git a/qa-core/src/tests/internal-api/tables/tables.spec.ts b/qa-core/src/tests/internal-api/tables/tables.spec.ts index 6b2d2240e5..41acf42f92 100644 --- a/qa-core/src/tests/internal-api/tables/tables.spec.ts +++ b/qa-core/src/tests/internal-api/tables/tables.spec.ts @@ -6,9 +6,9 @@ import { generateTable, generateNewColumnForTable, } from "../../../config/internal-api/fixtures/table" -import { generateNewRowForTable } from "../../../config/internal-api/fixtures/rows" +import { generateNewRowForTable, searchBody } from "../../../config/internal-api/fixtures/rows" -describe("Internal API - Application creation, update, publish and delete", () => { +describe("Internal API - Table Operations", () => { const api = new InternalAPIClient() const config = new TestConfiguration(api) @@ -86,4 +86,61 @@ describe("Internal API - Application creation, update, publish and delete", () = //Table was deleted await config.tables.getAll(2) }) + + it("Search and pagination", async () => { + // create the app + const appName = generator.word() + const app = await createAppFromTemplate() + config.applications.api.appId = app.appId + + // Get current tables: expect 2 in this template + await config.tables.getAll(2) + + // Add new table + const [createdTableResponse, createdTableData] = await config.tables.save( + generateTable() + ) + + //Table was added + await config.tables.getAll(3) + + //Get information about the table + await config.tables.getTableById(createdTableData._id) + + //Add Column to table + const newColumn = generateNewColumnForTable(createdTableData) + const [addColumnResponse, addColumnData] = await config.tables.save( + newColumn, + true + ) + + //Add Row to table + let newRow = generateNewRowForTable(addColumnData._id) + await config.rows.add(addColumnData._id, newRow) + + //Search single row + await config.rows.searchSinglePage(createdTableData._id, searchBody(createdTableData.primaryDisplay)) + + //Add 10 more rows + for (let i = 0; i < 10; i++) { + let newRow = generateNewRowForTable(addColumnData._id) + await config.rows.add(addColumnData._id, newRow) + } + + //Search multiple rows + const [allRowsResponse, allRowsJson] = await config.rows.searchMultiPage(createdTableData._id, searchBody(createdTableData.primaryDisplay)) + + //Delete Rows from table + const rowToDelete = { + rows: [allRowsJson], + } + const [deleteRowResponse, deleteRowData] = await config.rows.delete( + addColumnData._id, + rowToDelete + ) + + //Search single row + await config.rows.searchSinglePage(createdTableData._id, searchBody(createdTableData.primaryDisplay)) + + }) })