|
| 1 | +import { join } from 'path'; |
| 2 | +import * as os from 'os'; |
| 3 | +import * as fs from 'fs'; |
| 4 | +import * as editJsonFile from 'edit-json-file'; |
| 5 | +import { acceptLicenseTermsAndAddDatabaseApi} from '../../../helpers/database'; |
| 6 | +import { MyRedisDatabasePage, WorkbenchPage } from '../../../pageObjects'; |
| 7 | +import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf'; |
| 8 | +import { rte, env } from '../../../helpers/constants'; |
| 9 | +import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database'; |
| 10 | + |
| 11 | +const myRedisDatabasePage = new MyRedisDatabasePage(); |
| 12 | +const workbenchPage = new WorkbenchPage(); |
| 13 | + |
| 14 | +const workingDirectory = process.env.APP_FOLDER_ABSOLUTE_PATH |
| 15 | + || (join(os.homedir(), process.env.APP_FOLDER_NAME || '.redisinsight-v2')); |
| 16 | +if (fs.existsSync(workingDirectory)) { |
| 17 | + // Guides content |
| 18 | + const guidesTimestampPath = `${workingDirectory}/guides/build.json`; |
| 19 | + const guidesGraphIntroductionFilePath = `${workingDirectory}/guides/quick-guides/graph/introduction.md`; |
| 20 | + |
| 21 | + // Tutorials content |
| 22 | + const tutorialsTimestampPath = `${workingDirectory}/tutorials/build.json`; |
| 23 | + const tutorialsTimeSeriesFilePath = `${workingDirectory}/tutorials/redis_stack/redis_for_time_series.md`; |
| 24 | + |
| 25 | + // Remove md files from local folder. When desktop tests are started, files will be updated from remote repository |
| 26 | + // Need to uncomment when desktop tests are started |
| 27 | + // fs.unlinkSync(guidesGraphIntroductionFilePath); |
| 28 | + // fs.unlinkSync(tutorialsTimeSeriesFilePath); |
| 29 | + |
| 30 | + // Update timestamp for build files |
| 31 | + const guidesTimestampFile = editJsonFile(guidesTimestampPath); |
| 32 | + const tutorialsTimestampFile = editJsonFile(tutorialsTimestampPath); |
| 33 | + |
| 34 | + const guidesNewTimestamp = guidesTimestampFile.get('timestamp') - 10; |
| 35 | + const tutorialNewTimestamp = tutorialsTimestampFile.get('timestamp') - 10; |
| 36 | + |
| 37 | + guidesTimestampFile.set('timestamp', guidesNewTimestamp); |
| 38 | + guidesTimestampFile.save(); |
| 39 | + tutorialsTimestampFile.set('timestamp', tutorialNewTimestamp); |
| 40 | + tutorialsTimestampFile.save(); |
| 41 | + |
| 42 | + fixture `Automatically update information` |
| 43 | + .meta({ type: 'critical_path' }) |
| 44 | + .page(commonUrl) |
| 45 | + .beforeEach(async() => { |
| 46 | + await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName); |
| 47 | + }) |
| 48 | + .afterEach(async() => { |
| 49 | + await deleteStandaloneDatabaseApi(ossStandaloneConfig); |
| 50 | + }); |
| 51 | + test |
| 52 | + .meta({ rte: rte.standalone, env: env.desktop })('Verify that user can see updated info in Enablement Area', async t => { |
| 53 | + // Create new file due to cache-ability |
| 54 | + const guidesTimestampFileNew = editJsonFile(guidesTimestampPath); |
| 55 | + const tutorialsTimestampFileNew = editJsonFile(tutorialsTimestampPath); |
| 56 | + |
| 57 | + // Open Workbench page |
| 58 | + await t.click(myRedisDatabasePage.workbenchButton); |
| 59 | + |
| 60 | + // Check Enablement area and validate that removed file is existed in Guides |
| 61 | + await t.click(workbenchPage.guidesGraphAccordion); |
| 62 | + await t.click(workbenchPage.guidesIntroductionGraphLink.nth(1)); |
| 63 | + await t.expect(workbenchPage.enablementAreaEmptyContent.visible).notOk('Guides folder is not updated'); |
| 64 | + await t.click(workbenchPage.closeEnablementPage); |
| 65 | + |
| 66 | + // Check Enablement area and validate that removed file is existed in Tutorials |
| 67 | + await t.click(workbenchPage.redisStackTutorialsButton); |
| 68 | + await t.click(workbenchPage.timeSeriesLink); |
| 69 | + await t.expect(workbenchPage.enablementAreaEmptyContent.visible).notOk('Tutorials folder is not updated'); |
| 70 | + |
| 71 | + // Check that timestamp is new |
| 72 | + const actualGuidesTimestamp = await guidesTimestampFileNew.get('timestamp'); |
| 73 | + const actualTutorialTimestamp = await tutorialsTimestampFileNew.get('timestamp'); |
| 74 | + await t.expect(actualGuidesTimestamp).notEql(guidesNewTimestamp, 'Guides timestamp is not updated'); |
| 75 | + await t.expect(actualTutorialTimestamp).notEql(tutorialNewTimestamp, 'Tutorials timestamp is not updated'); |
| 76 | + }); |
| 77 | +} |
0 commit comments