-
-
Notifications
You must be signed in to change notification settings - Fork 0
OBPIH-7934 Improve data cleanups in afterEaches #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kkrawczyk123
wants to merge
4
commits into
main
Choose a base branch
from
OBPIH-7934
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a46007b
improve loading of tabs
kkrawczyk123 d2123ac
improve removing transactions after putaway tests
kkrawczyk123 f594712
improve deleting and deactivating receiving bins in putaway and recei…
kkrawczyk123 ddd0fba
add imprevements after review
kkrawczyk123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,61 @@ | ||
| import BaseServiceModel from '@/api/BaseServiceModel'; | ||
| import { INVENTORY_URL } from '@/constants/applicationUrls'; | ||
|
|
||
| /** | ||
| OpenBoxes has no REST endpoints for inventory transactions, so this service | ||
| goes through the same session-authenticated Grails controller actions as | ||
| the transaction list UI (plain GET requests). | ||
| */ | ||
| class TransactionService extends BaseServiceModel { | ||
| /** | ||
| Returns ids of the most recent transactions in the current location | ||
| (newest first, the same order as the transaction list page), scraped | ||
| from the delete links on the list page. | ||
| */ | ||
| async getRecentTransactionIds(count: number): Promise<string[]> { | ||
| const response = await this.request.get( | ||
| INVENTORY_URL.listTransactions({ max: count }) | ||
| ); | ||
| if (!response.ok()) { | ||
| throw new Error( | ||
| `Problem fetching transaction list: ${response.status()}` | ||
| ); | ||
| } | ||
| const html = await response.text(); | ||
| return [...html.matchAll(/deleteTransaction\/(\w+)/g)].map( | ||
| (match) => match[1] | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| Deletes a single transaction. A successful delete redirects back to the | ||
| transaction list, a failed one to the edit transaction page. | ||
| */ | ||
| async deleteTransaction(id: string): Promise<void> { | ||
| const response = await this.request.get( | ||
| INVENTORY_URL.deleteTransaction(id) | ||
| ); | ||
| if (!response.ok() || !response.url().includes('listTransactions')) { | ||
| throw new Error(`Problem deleting transaction with id: ${id}`); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| Deletes the given number of most recent transactions in the current | ||
| location — the API counterpart of deleting the top rows on the | ||
| transaction list page one by one. | ||
| */ | ||
| async deleteRecentTransactions(count: number): Promise<void> { | ||
| const transactionIds = await this.getRecentTransactionIds(count); | ||
| if (transactionIds.length < count) { | ||
| throw new Error( | ||
| `Expected at least ${count} transactions to delete, found ${transactionIds.length}` | ||
| ); | ||
| } | ||
| for (const transactionId of transactionIds) { | ||
| await this.deleteTransaction(transactionId); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default TransactionService; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,11 +1,28 @@ | ||
| import { Page } from '@playwright/test'; | ||
| import { expect, Locator, Page } from '@playwright/test'; | ||
|
|
||
| abstract class BasePageModel { | ||
| protected page: Page; | ||
|
|
||
| constructor(page: Page) { | ||
| this.page = page; | ||
| } | ||
|
|
||
| // tab content is fetched once per page load, so when it fails to render, | ||
| // re-clicking the tab never refetches it — only a reload does | ||
| protected async openTab( | ||
| tab: Locator, | ||
| tabContent: { isLoaded: () => Promise<void> } | ||
| ) { | ||
| let reloadOnRetry = false; | ||
| await expect(async () => { | ||
| if (reloadOnRetry) { | ||
| await this.page.reload(); | ||
| } | ||
| reloadOnRetry = true; | ||
| await tab.click(); | ||
| await tabContent.isLoaded(); | ||
| }).toPass({ timeout: 45000, intervals: [500, 1000, 2000] }); | ||
| } | ||
| } | ||
|
|
||
| export default BasePageModel; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, I prefer to make those endpoints, rather than fetch the HTML
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can create a ticket for that for the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, let's do that