-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cypress) Fix flakiness of cypress test for glossary navigation (#…
…9410) Co-authored-by: david-leifker <[email protected]>
- Loading branch information
1 parent
3e79a13
commit 159a013
Showing
3 changed files
with
44 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ApolloClient } from '@apollo/client'; | ||
import { GetGlossaryNodeDocument, GetGlossaryNodeQuery } from '../../graphql/glossaryNode.generated'; | ||
|
||
export function removeTermFromGlossaryNode( | ||
client: ApolloClient<object>, | ||
glossaryNodeUrn: string, | ||
glossaryTermUrn: string, | ||
) { | ||
// Read the data from our cache for this query. | ||
const currData: GetGlossaryNodeQuery | null = client.readQuery({ | ||
query: GetGlossaryNodeDocument, | ||
variables: { urn: glossaryNodeUrn }, | ||
}); | ||
|
||
// Remove the term from the existing children set. | ||
const newTermChildren = { | ||
relationships: [ | ||
...(currData?.glossaryNode?.children?.relationships || []).filter( | ||
(relationship) => relationship.entity?.urn !== glossaryTermUrn, | ||
), | ||
], | ||
total: (currData?.glossaryNode?.children?.total || 1) - 1, | ||
}; | ||
|
||
// Write our data back to the cache. | ||
client.writeQuery({ | ||
query: GetGlossaryNodeDocument, | ||
variables: { urn: glossaryNodeUrn }, | ||
data: { | ||
glossaryNode: { | ||
...currData?.glossaryNode, | ||
children: newTermChildren, | ||
}, | ||
}, | ||
}); | ||
} |
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