-
Notifications
You must be signed in to change notification settings - Fork 209
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
chore(test): add integration test cases of CPK for API lazy loading #2769
Open
5d
wants to merge
4
commits into
main
Choose a base branch
from
5d/ll12-subscription-integration-test-more
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
0e31001
chore(test): add API subscription integration test case for LazyLoading
5d b6a48dc
chore(test): add more integration test cases for API lazy loading
5d 4259bff
chore(test): refactor subscription integration tests
5d dd09f50
chore(test): refactor subscription test cases with template function
5d 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 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 |
---|---|---|
|
@@ -107,4 +107,85 @@ extension GraphQLLazyLoadCompositePKTests { | |
} | ||
assertList(queriedChild, state: .isLoaded(count: 1)) | ||
} | ||
|
||
/* | ||
- Given: Api category setup with CompositePKModels | ||
- When: | ||
- Subscribe onCreate events of ImplicitChild | ||
- Create new CompositePKParent instance with API | ||
- Create new ImplicitChild instance with API | ||
- Then: | ||
- the newly created instance is successfully created through API. onCreate event is received. | ||
*/ | ||
func testSubscribeImplicitChildOnCreate() async throws { | ||
await setup(withModels: CompositePKModels()) | ||
|
||
let parent = CompositePKParent(customId: UUID().uuidString, content: UUID().uuidString) | ||
let child = ImplicitChild(childId: UUID().uuidString, content: UUID().uuidString, parent: parent) | ||
let (onCreate, subscription) = try await subscribe(of: ImplicitChild.self, type: .onCreate) { createdChild in | ||
createdChild.identifier == child.identifier | ||
} | ||
|
||
try await mutate(.create(parent)) | ||
try await mutate(.create(child)) | ||
await waitForExpectations([onCreate], timeout: 10) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be great if we can we use a constant for timeout value |
||
subscription.cancel() | ||
} | ||
|
||
/* | ||
- Given: Api category setup with CompositePKModels | ||
- When: | ||
- Subscribe onCreate events of ImplicitChild | ||
- Create new CompositePKParent instance with API | ||
- Create new ImplicitChild instance with API | ||
- Update newly created ImplicitChild instance with API | ||
- Then: | ||
- the newly created instance is successfully updated through API. onUpdate event is received. | ||
*/ | ||
func testSubscribeImplicitChildOnUpdate() async throws { | ||
await setup(withModels: CompositePKModels()) | ||
|
||
let parent = CompositePKParent(customId: UUID().uuidString, content: UUID().uuidString) | ||
let child = ImplicitChild(childId: UUID().uuidString, content: UUID().uuidString, parent: parent) | ||
let (onUpdate, subscription) = try await subscribe(of: ImplicitChild.self, type: .onUpdate, verifyChange: { updatedChild in | ||
let associatedParent = try await updatedChild.parent | ||
return associatedParent.identifier == parent.identifier | ||
&& updatedChild.identifier == child.identifier | ||
}) | ||
|
||
try await mutate(.create(parent)) | ||
try await mutate(.create(child)) | ||
|
||
var updatingChild = child | ||
updatingChild.setParent(parent) | ||
try await mutate(.update(updatingChild)) | ||
await waitForExpectations([onUpdate], timeout: 10) | ||
subscription.cancel() | ||
} | ||
|
||
/* | ||
- Given: Api category setup with CompositePKModels | ||
- When: | ||
- Subscribe onCreate events of CompositePKChild | ||
- Create new CompositePKParent instance with API | ||
- Create new CompositePKChild instance with API | ||
- Delete newly created CompositePKChild with API | ||
- Then: | ||
- the newly created instance is successfully deleted through API. onDelete event is received. | ||
*/ | ||
func testSubscribeImplicitChildOnDelete() async throws { | ||
await setup(withModels: CompositePKModels()) | ||
|
||
let parent = CompositePKParent(customId: UUID().uuidString, content: UUID().uuidString) | ||
let child = ImplicitChild(childId: UUID().uuidString, content: UUID().uuidString, parent: parent) | ||
let (onDelete, subscription) = try await subscribe(of: ImplicitChild.self, type: .onDelete) { deletedChild in | ||
deletedChild.identifier == child.identifier | ||
} | ||
|
||
try await mutate(.create(parent)) | ||
try await mutate(.create(child)) | ||
try await mutate(.delete(child)) | ||
await waitForExpectations([onDelete], timeout: 10) | ||
subscription.cancel() | ||
} | ||
} |
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.
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.
will this call the update mutation event even if there are no changes to child model?