-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1341 from kubeshop/andreiv1992/feat/work-with-git…
…-folder Andreiv1992/feat/work with git folder
- Loading branch information
Showing
17 changed files
with
261 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import {expect, test} from '@playwright/test'; | ||
import {Page} from 'playwright'; | ||
import {ElectronApplication} from 'playwright-core'; | ||
import {execSync} from 'child_process'; | ||
import * as path from 'path'; | ||
import * as fs from 'fs'; | ||
import {ElectronAppInfo, startApp} from './electronHelpers'; | ||
import {pause} from './utils'; | ||
import {MainWindow} from './models/mainWindow'; | ||
import {FileExplorerPane} from './models/fileExplorerPane'; | ||
import {KustomizePane} from './models/kustomizePane'; | ||
import {HelmPane} from './models/helmPane'; | ||
import {StartProjectPane} from './models/startProjectPane'; | ||
import {NavigatorPane} from './models/navigatorPane'; | ||
|
||
let appWindow: Page; | ||
let appInfo: ElectronAppInfo; | ||
let electronApp: ElectronApplication; | ||
|
||
const clonePath = path.join(__dirname, '..', '..'); | ||
const projectPath = path.join(clonePath, 'manifest-test-data'); | ||
const repo = 'https://github.com/kubeshop/manifest-test-data'; | ||
|
||
let mainWindow: MainWindow; | ||
let fileExplorerPane: FileExplorerPane; | ||
let kustomizePane: KustomizePane; | ||
let helmPane: HelmPane; | ||
let startProjectPane: StartProjectPane; | ||
let navigatorPane: NavigatorPane; | ||
|
||
test.beforeAll(async () => { | ||
const startAppResponse = await startApp(); | ||
appWindow = startAppResponse.appWindow; | ||
appInfo = startAppResponse.appInfo; | ||
electronApp = startAppResponse.electronApp; | ||
|
||
mainWindow = new MainWindow(appWindow); | ||
fileExplorerPane = new FileExplorerPane(appWindow); | ||
kustomizePane = new KustomizePane(appWindow); | ||
helmPane = new HelmPane(appWindow); | ||
startProjectPane = new StartProjectPane(appWindow); | ||
navigatorPane = new NavigatorPane(appWindow); | ||
|
||
appWindow.on('console', console.log); | ||
|
||
execSync(`git clone ${repo}`, { | ||
cwd: `${clonePath}`, | ||
}); | ||
}); | ||
|
||
const startCommit = 'aeb1e59a03913b00020eca6ac2a416d085f34a6b'; | ||
const removeSomeFiles = 'f5518240cf7cac1f686c1bc9e4ca8099bfd7daa1'; | ||
const removeMoreFiles = '28879f29f62c8357b5ca988e475db30e13c8300b'; | ||
|
||
async function goToCommit(hash: string) { | ||
execSync(`git checkout ${hash}`, { | ||
cwd: `${projectPath}`, | ||
}); | ||
|
||
await pause(5000); | ||
} | ||
|
||
const testData = [ | ||
{ | ||
hash: startCommit, | ||
fileExplorerCount: 53, | ||
kustomizeCount: 22, | ||
helmCount: 4, | ||
navigatorCount: 55, | ||
}, | ||
{ | ||
hash: removeSomeFiles, | ||
fileExplorerCount: 32, | ||
kustomizeCount: 5, | ||
helmCount: 4, | ||
navigatorCount: 48, | ||
}, | ||
{ | ||
hash: removeMoreFiles, | ||
fileExplorerCount: 15, | ||
kustomizeCount: 2, | ||
helmCount: 4, | ||
navigatorCount: 35, | ||
}, | ||
{ | ||
hash: startCommit, | ||
fileExplorerCount: 53, | ||
kustomizeCount: 22, | ||
helmCount: 4, | ||
navigatorCount: 55, | ||
}, | ||
]; | ||
|
||
test('all files should be loaded', async () => { | ||
await startProjectPane.createProjectFromFolder(electronApp, projectPath); | ||
await pause(10000); | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
for (const data of testData) { | ||
console.log(`testing commit hash: ${data.hash}`); | ||
await goToCommit(data.hash); | ||
|
||
expect(parseInt(await navigatorPane.resourcesCount.textContent(), 10)).toEqual(data.navigatorCount); | ||
|
||
await mainWindow.clickFileExplorer(); | ||
expect((await fileExplorerPane.projectName.textContent())?.includes(projectPath)).toBe(true); | ||
expect(await fileExplorerPane.fileCount.textContent()).toEqual(`${data.fileExplorerCount} files`); | ||
|
||
await mainWindow.clickKustomizeButton(); | ||
const kustomizeInnerTexts = (await kustomizePane.kustomizeItemsContainer.allInnerTexts())[0].split('\n'); | ||
expect(kustomizeInnerTexts.length).toEqual(data.kustomizeCount); | ||
|
||
await mainWindow.clickHelmButton(); | ||
const helmInnerTexts = (await helmPane.helmItemsContainer.allInnerTexts())[0].split('\n'); | ||
expect(helmInnerTexts.length).toEqual(data.helmCount); | ||
} | ||
}); | ||
|
||
test.afterAll(async () => { | ||
fs.rmSync(projectPath, { recursive: true, force: true }); | ||
await appWindow.screenshot({path: `test-output/${appInfo.platform}/screenshots/final-screen.png`}); | ||
await appWindow.context().close(); | ||
await appWindow.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Locator, Page} from 'playwright'; | ||
|
||
export class HelmPane { | ||
|
||
private _page: Page; | ||
|
||
private readonly _helmItemsContainer: Locator; | ||
|
||
constructor(page: Page) { | ||
this._page = page; | ||
|
||
this._helmItemsContainer = page.locator('#helm-sections-container'); | ||
} | ||
|
||
get helmItemsContainer() { | ||
return this._helmItemsContainer; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Locator, Page} from 'playwright'; | ||
|
||
export class KustomizePane { | ||
|
||
private _page: Page; | ||
|
||
private readonly _kustomizeItemsContainer: Locator; | ||
|
||
constructor(page: Page) { | ||
this._page = page; | ||
|
||
this._kustomizeItemsContainer = page.locator('#kustomize-sections-container'); | ||
} | ||
|
||
get kustomizeItemsContainer() { | ||
return this._kustomizeItemsContainer; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.