|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import type { Page } from '@playwright/test'; |
| 3 | +const { checkTitle } = require('./utils/uniqueFunction'); |
| 4 | + |
| 5 | +const { navDataStructure, checkConstraint, createDataStructure, findDataStructure, deleteDataStructure, checkAndCloseToast, editDataStructure, findEditedDataStructure, checkDataStructure } = require('./utils/dataStructureFunctions'); |
| 6 | + |
| 7 | +import { login, host } from '../shared'; |
| 8 | + |
| 9 | +// Annotate entire file as serial. |
| 10 | +test.describe.configure({ mode: 'serial' }); |
| 11 | + |
| 12 | +test.describe('Data Structure', () => { |
| 13 | + // Declare page outside of the test hooks so it's accessible by all tests. |
| 14 | + let page: Page; |
| 15 | + |
| 16 | + test.beforeAll(async ({ browser }) => { |
| 17 | + page = await browser.newPage(); // Create new page |
| 18 | + await login(page); // Login |
| 19 | + await page.goto(`${host}/rpm/datastructure`); // Go to Data Structure page |
| 20 | + }); |
| 21 | + |
| 22 | + test.afterAll(async () => { |
| 23 | + await page.close(); // Close the page after all tests |
| 24 | + }); |
| 25 | + |
| 26 | + test.describe('Iterations for fields validation', () => { |
| 27 | + const dataStructure = `test_iterate-${+Date.now()}`; |
| 28 | + |
| 29 | + test('Check with title and title description field ', async () => { |
| 30 | + await checkDataStructure(page, dataStructure, "Test data structure", "", "", "", "", "", ""); |
| 31 | + }); |
| 32 | + |
| 33 | + test('Check with title, title description and hasPrimaryKey field', async () => { |
| 34 | + await navDataStructure(page); |
| 35 | + await checkDataStructure(page, dataStructure, "Test data structure", "hasPrimaryKey", "", "", "", "", ""); |
| 36 | + }); |
| 37 | + |
| 38 | + test('Check with title, title description and hasOptionalValue field', async () => { |
| 39 | + await navDataStructure(page); |
| 40 | + await checkDataStructure(page, dataStructure, "Test data structure", "", "hasOptionalValue", "", "", "", ""); |
| 41 | + }); |
| 42 | + |
| 43 | + test('Check with title, title description, name, description and hasPrimaryKey field', async () => { |
| 44 | + await navDataStructure(page); |
| 45 | + await checkDataStructure(page, dataStructure, "Test data structure", "hasPrimaryKey", "", dataStructure, "Test data structure", "", ""); |
| 46 | + }); |
| 47 | + test('Check with title, title description, name, description and hasOptionalValue field', async () => { |
| 48 | + await navDataStructure(page); |
| 49 | + await checkDataStructure(page, dataStructure, "Test data structure", "", "hasOptionalValue", dataStructure, "Test data structure", "", ""); |
| 50 | + }); |
| 51 | + |
| 52 | + test('Check with title, title description, name, description, hasPrimaryKey, hasOptionalValue and hasDataType field', async () => { |
| 53 | + await navDataStructure(page); |
| 54 | + await checkDataStructure(page, dataStructure, "Test data structure", "hasPrimaryKey", "hasOptionalValue", dataStructure, "Test data structure", "hasDataType", ""); |
| 55 | + }); |
| 56 | + |
| 57 | + test('Check with title, title description, name, description, hasPrimaryKey, hasOptionalValue and hasUnit field', async () => { |
| 58 | + await navDataStructure(page); |
| 59 | + await checkDataStructure(page, dataStructure, "Test data structure", "hasPrimaryKey", "hasOptionalValue", dataStructure, "Test data structure", "", "hasUnit"); |
| 60 | + }); |
| 61 | + |
| 62 | + |
| 63 | + }); |
| 64 | + |
| 65 | + test.describe('Create new data structure', () => { |
| 66 | + const dataStructure = `test_new-${+Date.now()}`; |
| 67 | + // // test('should match the expected title', async () => { |
| 68 | + // await checkTitle(page, 'Data structure', '.w-full >> .table.table-compact', 'h1.h1'); |
| 69 | + // }); |
| 70 | + test('Check Constraint', async () => { |
| 71 | + await navDataStructure(page); |
| 72 | + await checkConstraint(page); |
| 73 | + await navDataStructure(page); |
| 74 | + }); |
| 75 | + |
| 76 | + test('Create data structure', async () => { |
| 77 | + await createDataStructure(page, dataStructure); |
| 78 | + }); |
| 79 | + //test.slow() |
| 80 | + test('Find the new data structure in the table', async () => { |
| 81 | + await findDataStructure(page, dataStructure); |
| 82 | + }); |
| 83 | + |
| 84 | + test('Delete new data structure', async () => { |
| 85 | + await deleteDataStructure(page); |
| 86 | + }); |
| 87 | + |
| 88 | + test('Check toast', async () => { |
| 89 | + await checkAndCloseToast(page); |
| 90 | + }); |
| 91 | + |
| 92 | + }); |
| 93 | + |
| 94 | + test.describe('Edit new data structure', () => { |
| 95 | + const dataStructure = `test_edit-${+Date.now()}`; |
| 96 | + |
| 97 | + |
| 98 | + test('Check Constraint', async () => { |
| 99 | + await navDataStructure(page); |
| 100 | + await checkConstraint(page); |
| 101 | + await navDataStructure(page); |
| 102 | + }); |
| 103 | + |
| 104 | + |
| 105 | + test('Create data structure', async () => { |
| 106 | + await createDataStructure(page, dataStructure); |
| 107 | + }); |
| 108 | + //test.slow() |
| 109 | + test('Find the new data structure in the table', async () => { |
| 110 | + await findDataStructure(page, dataStructure); |
| 111 | + }); |
| 112 | + test('Edit description data structure', async () => { |
| 113 | + test.slow(); |
| 114 | + await editDataStructure(page); |
| 115 | + }); |
| 116 | + |
| 117 | + test('Find the edited data structure in the table', async () => { |
| 118 | + await findEditedDataStructure(page, dataStructure); |
| 119 | + }); |
| 120 | + |
| 121 | + test('Delete new data structure', async () => { |
| 122 | + await deleteDataStructure(page); |
| 123 | + }); |
| 124 | + |
| 125 | + test('Check toast', async () => { |
| 126 | + await checkAndCloseToast(page); |
| 127 | + }); |
| 128 | + |
| 129 | + }); |
| 130 | + |
| 131 | +}); |
0 commit comments