-
Notifications
You must be signed in to change notification settings - Fork 135
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 #1302 from kubeshop/andreiv1992/test/more-tests-ar…
…ound-projects Tests for create project & save resource
- Loading branch information
Showing
33 changed files
with
553 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Testing | ||
|
||
Monokle tests are written with Playwright: https://playwright.dev/docs/api/class-electron | ||
|
||
## Run tests | ||
|
||
First create a build to run the tests | ||
|
||
`npm run electron:build` | ||
|
||
To run specific tests | ||
|
||
`npm run ui-test -- tests/<filename>.test.ts` | ||
|
||
To run all the tests | ||
|
||
`npm run ui-test` | ||
|
||
## Write & extend tests | ||
|
||
To start writing tests first create a build(tests are run against the build which will be published), any changes made to the source code, adding identifiers, changing logic will need a new build for those changes to be in the tests | ||
|
||
`npm run electron:build` | ||
|
||
The `startApp()` function should be called and that will start a new monokle instance with the `automation` flag set. More examples of tests can be found in the `./tests` folder | ||
The `automation` flag is used to change some handlers which cannot be automated by playwright since they are open by the specific OS's | ||
|
||
Models should contain most of the logic, we can think of models a mirror for some components in the app with some logic and identifiers for certain elements. Having most of the logic in the models can help with reusing most of the logic we have around tests and more lightweight tests. | ||
|
||
## Overriding OS actions | ||
|
||
To change handlers such as `dialog.showOpenDialogSync` the function `getChannelName('channel-name')` should be called when creating a new handler on `ipcRenderer`, this will create different handler just for automation. | ||
To add a new handler in automation something like this is required: | ||
``` | ||
const name = 'some-value'; | ||
const chanel = getChannelName('channel-name', true); | ||
await electronApp.evaluate(({ ipcMain }, params) => { | ||
ipcMain.handle(params.chanel, () => { | ||
return [params.name]; | ||
}); | ||
}, { chanel, name }); | ||
``` | ||
|
||
Examples: | ||
- [override in electron](src/components/atoms/FileExplorer/FileExplorer.tsx) | ||
- [override in tests](tests/models/projectsDropdown.ts) |
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
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,12 @@ | ||
import {StartupFlag, StartupFlags} from './startupFlag'; | ||
|
||
export function getChannelName( | ||
name: string, | ||
hasAutomationFlag = StartupFlag.getInstance().hasAutomationFlag, | ||
) { | ||
if (hasAutomationFlag) { | ||
return `${name}-${StartupFlags.AUTOMATION}`; | ||
} | ||
|
||
return name; | ||
} |
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,29 @@ | ||
export enum StartupFlags { | ||
AUTOMATION = 'automation', | ||
} | ||
|
||
export class StartupFlag { | ||
|
||
private static _instance: StartupFlag; | ||
|
||
private _automationFlag = false; | ||
|
||
// eslint-disable-next-line no-useless-constructor,no-empty-function | ||
private constructor() {} | ||
|
||
public static getInstance(): StartupFlag { | ||
if (!StartupFlag._instance) { | ||
StartupFlag._instance = new StartupFlag(); | ||
} | ||
|
||
return StartupFlag._instance; | ||
} | ||
|
||
get hasAutomationFlag(): boolean { | ||
return this._automationFlag; | ||
} | ||
|
||
set automationFlag(value: boolean) { | ||
this._automationFlag = value; | ||
} | ||
} |
Oops, something went wrong.