|
| 1 | +import { DatabaseHelper } from '../../../../helpers/database'; |
| 2 | +import { BrowserPage, MyRedisDatabasePage, WorkbenchPage } from '../../../../pageObjects'; |
| 3 | +import { commonUrl, ossStandaloneConfig, ossStandaloneV5Config } from '../../../../helpers/conf'; |
| 4 | +import { rte } from '../../../../helpers/constants'; |
| 5 | +import { DatabaseAPIRequests } from '../../../../helpers/api/api-database'; |
| 6 | +import { DatabaseScripts, DbTableParameters } from '../../../../helpers'; |
| 7 | +import { format, subDays } from 'date-fns'; |
| 8 | + |
| 9 | +const browserPage = new BrowserPage(); |
| 10 | +const databaseHelper = new DatabaseHelper(); |
| 11 | +const databaseAPIRequests = new DatabaseAPIRequests(); |
| 12 | +const myRedisDatabasePage = new MyRedisDatabasePage(); |
| 13 | +const workbenchPage = new WorkbenchPage(); |
| 14 | + |
| 15 | +const currentDate = new Date(); |
| 16 | +const fiveDaysAgo = subDays(currentDate, 5); |
| 17 | +const rowValue5 = format(fiveDaysAgo, 'yyyy-MM-dd HH:mm:ss'); |
| 18 | + |
| 19 | +const seventeenDaysAgo = subDays(currentDate, 17); |
| 20 | +const rowValue16 = format(seventeenDaysAgo, 'yyyy-MM-dd HH:mm:ss'); |
| 21 | + |
| 22 | +const dbTableParams5days: DbTableParameters = { |
| 23 | + tableName: 'database_instance', |
| 24 | + columnName: 'lastConnection', |
| 25 | + rowValue: rowValue5, |
| 26 | + conditionWhereColumnName: 'name', |
| 27 | + conditionWhereColumnValue: ossStandaloneConfig.databaseName |
| 28 | +}; |
| 29 | + |
| 30 | +const dbTableParams16days: DbTableParameters = { |
| 31 | + tableName: 'database_instance', |
| 32 | + columnName: 'lastConnection', |
| 33 | + rowValue: rowValue16, |
| 34 | + conditionWhereColumnName: 'name', |
| 35 | + conditionWhereColumnValue: ossStandaloneConfig.databaseName |
| 36 | +}; |
| 37 | + |
| 38 | +fixture `DB expire notifications` |
| 39 | + .meta({ type: 'critical_path', rte: rte.standalone }) |
| 40 | + .page(commonUrl); |
| 41 | + |
| 42 | +test.before(async() => { |
| 43 | + await databaseHelper.acceptLicenseTerms(); |
| 44 | + await databaseAPIRequests.deleteAllDatabasesApi(); |
| 45 | + await databaseAPIRequests.addNewStandaloneDatabaseApi(ossStandaloneV5Config); |
| 46 | + await databaseAPIRequests.addNewStandaloneDatabaseApi(ossStandaloneConfig, true); |
| 47 | + await browserPage.reloadPage(); |
| 48 | + await myRedisDatabasePage.clickOnDBByName(ossStandaloneV5Config.databaseName); |
| 49 | + }) |
| 50 | + .after(async() => { |
| 51 | + // await databaseAPIRequests.deleteAllDatabasesApi(); |
| 52 | + })('Verify that notifications are displayed if the db will be expired soon', async t => { |
| 53 | + await t.click(browserPage.NavigationPanel.workbenchButton); |
| 54 | + await workbenchPage.sendCommandInWorkbench('CMS.INITBYDIM'); |
| 55 | + |
| 56 | + await DatabaseScripts.updateColumnValueInDBTable(dbTableParams5days); |
| 57 | + await t.click(browserPage.NavigationPanel.myRedisDBButton); |
| 58 | + await t.hover(myRedisDatabasePage.iconNotUsedDatabase); |
| 59 | + await t.expect(myRedisDatabasePage.notificationUnusedDbMessage.textContent).contains('Probabilistic data structures', 'there is no info about module'); |
| 60 | + await t.expect(myRedisDatabasePage.notificationUnusedDbMessage.textContent).contains('free Cloud databases will be deleted after 15 days of inactivity.', 'there is no expected info'); |
| 61 | + |
| 62 | + await myRedisDatabasePage.clickOnDBByName(ossStandaloneConfig.databaseName); |
| 63 | + await t.click(browserPage.NavigationPanel.myRedisDBButton); |
| 64 | + await DatabaseScripts.updateColumnValueInDBTable(dbTableParams16days); |
| 65 | + await myRedisDatabasePage.reloadPage(); |
| 66 | + |
| 67 | + await t.hover(myRedisDatabasePage.iconDeletedDatabase); |
| 68 | + await t.expect(myRedisDatabasePage.notificationUnusedDbMessage.textContent).contains('Build your app with Redis Cloud', 'there is no common'); |
| 69 | + await t.expect(myRedisDatabasePage.notificationUnusedDbMessage.textContent).contains('Free Cloud DBs auto-delete after 15 days', 'there is no expected info'); |
| 70 | + }); |
0 commit comments