|
| 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 | + const guidesTimestampPath = 'E:\\Redis\\RedisInsight\\tests\\e2e\\.redisinsight-v2\\guides\\build.json'; |
| 21 | + const guidesGraphIntroductionFilePath = 'E:\\Redis\\RedisInsight\\tests\\e2e\\.redisinsight-v2\\guides\\quick-guides\\graph\\introduction.md'; |
| 22 | + |
| 23 | + // Tutorials content |
| 24 | + // const tutorialsTimestampPath = `${workingDirectory}/tutorials/build.json`; |
| 25 | + // const tutorialsTimeSeriesFilePath = `${workingDirectory}/guides/quick-guides/graph/introduction.md`; |
| 26 | + const tutorialsTimestampPath = 'E:\\Redis\\RedisInsight\\tests\\e2e\\.redisinsight-v2\\tutorials\\build.json'; |
| 27 | + const tutorialsTimeSeriesFilePath = 'E:\\Redis\\RedisInsight\\tests\\e2e\\.redisinsight-v2\\tutorials\\redis_stack\\redis_for_time_series.md'; |
| 28 | + |
| 29 | + // Remove md files |
| 30 | + // fs.unlinkSync(guidesGraphIntroductionFilePath); |
| 31 | + // fs.unlinkSync(tutorialsTimeSeriesFilePath); |
| 32 | + |
| 33 | + // Update timestamp for build files |
| 34 | + const guidesTimestampFile = editJsonFile(guidesTimestampPath); |
| 35 | + const tutorialsTimestampFile = editJsonFile(tutorialsTimestampPath); |
| 36 | + |
| 37 | + console.log(`guide timestampBeforeUpdate: ${guidesTimestampFile.get('timestamp')}`); |
| 38 | + console.log(`tutorial timestampBeforeUpdate: ${tutorialsTimestampFile.get('timestamp')}`); |
| 39 | + const guidesNewTimestamp = guidesTimestampFile.get('timestamp') - 10; |
| 40 | + const tutorialNewTimestamp = tutorialsTimestampFile.get('timestamp') - 10; |
| 41 | + |
| 42 | + guidesTimestampFile.set('timestamp', guidesNewTimestamp); |
| 43 | + guidesTimestampFile.save(); |
| 44 | + tutorialsTimestampFile.set('timestamp', tutorialNewTimestamp); |
| 45 | + tutorialsTimestampFile.save(); |
| 46 | + |
| 47 | + console.log(`guide timestamp after file update: ${guidesTimestampFile.get('timestamp')}`); |
| 48 | + console.log(`tutorial timestamp after file update: ${tutorialsTimestampFile.get('timestamp')}`); |
| 49 | + |
| 50 | + fixture `Automatically update information` |
| 51 | + .meta({ type: 'critical_path' }) |
| 52 | + .page(commonUrl) |
| 53 | + .beforeEach(async() => { |
| 54 | + await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName); |
| 55 | + }) |
| 56 | + .afterEach(async() => { |
| 57 | + await deleteStandaloneDatabaseApi(ossStandaloneConfig); |
| 58 | + }); |
| 59 | + test.only |
| 60 | + .meta({ rte: rte.standalone, env: env.desktop })('Verify that user can see updated info in Enablement Area', async t => { |
| 61 | + // Create new file due to cache-ability |
| 62 | + const guidesTimestampFileNew = editJsonFile(guidesTimestampPath); |
| 63 | + const tutorialsTimestampFileNew = editJsonFile(tutorialsTimestampPath); |
| 64 | + |
| 65 | + // Open Workbench page |
| 66 | + await t.click(myRedisDatabasePage.workbenchButton); |
| 67 | + |
| 68 | + // Check Enablement area and validate that removed file is existed in Guides |
| 69 | + await t.click(workbenchPage.guidesGraphAccordion); |
| 70 | + await t.click(workbenchPage.guidesIntroductionGraphLink); |
| 71 | + await t.expect(workbenchPage.enablementAreaEmptyContent.visible).notOk('Guides folder is not updated'); |
| 72 | + |
| 73 | + // Check Enablement area and validate that removed file is existed in Tutorials |
| 74 | + await t.click(workbenchPage.redisStackTutorialsButton); |
| 75 | + await t.click(workbenchPage.timeSeriesLink); |
| 76 | + await t.expect(workbenchPage.enablementAreaEmptyContent.visible).notOk('Tutorials folder is not updated'); |
| 77 | + |
| 78 | + // Check that timestamp is new |
| 79 | + const actualGuidesTimestamp = await guidesTimestampFileNew.get('timestamp'); |
| 80 | + const actualTutorialTimestamp = await tutorialsTimestampFileNew.get('timestamp'); |
| 81 | + await t.expect(actualGuidesTimestamp).notEql(guidesNewTimestamp, 'Guides timestamp is not updated'); |
| 82 | + await t.expect(actualTutorialTimestamp).notEql(tutorialNewTimestamp, 'Tutorials timestamp is not updated'); |
| 83 | + }); |
| 84 | +} |
0 commit comments