forked from rmarscher/houdini
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e test of HoudiniGraphql#691 bug with union queries
- Loading branch information
1 parent
eb740fa
commit da4774b
Showing
5 changed files
with
115 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<script> | ||
import { graphql } from '$houdini'; | ||
const result = graphql` | ||
query PreprocessorTestQueryUnion { | ||
modelsConnection(snapshot: "preprocess-query-union") { | ||
edges { | ||
node { | ||
__typename | ||
... on ModelA { | ||
data { | ||
x | ||
y | ||
} | ||
} | ||
... on ModelB { | ||
data { | ||
msg | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
</script> | ||
|
||
{#if $result.data?.modelsConnection?.edges} | ||
{#each $result.data?.modelsConnection.edges as edge} | ||
{#if edge.node.__typename === "ModelA"} | ||
<div id="result-union-model-a"> | ||
x: {edge.node.data?.x} | ||
</div> | ||
{:else if edge.node.__typename === "ModelB"} | ||
<div id="result-union-model-b"> | ||
msg: {edge.node.data?.msg} | ||
</div> | ||
{/if} | ||
{/each} | ||
{/if} |
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,26 @@ | ||
import { routes } from '../../../../lib/utils/routes.js'; | ||
import { | ||
expectToBe, | ||
goto, | ||
navSelector, | ||
clientSideNavigation, | ||
expect_0_gql | ||
} from '../../../../lib/utils/testsHelper.js'; | ||
import { test } from '@playwright/test'; | ||
|
||
test.describe('query preprocessor unions', () => { | ||
test('query arrays with unions get unmarshaled into different types', async function ({ page }) { | ||
await goto(page, routes.Plugin_query_union); | ||
await clientSideNavigation(page, routes.Home); | ||
|
||
// We want the query in the frontend, so we navigate to the page | ||
// to zoom on union test & data | ||
await expect_0_gql(page, navSelector(routes.Plugin_query_union)); | ||
|
||
// Expect first type data to be set | ||
await expectToBe(page, 'x: 1', 'div[id=result-union-model-a]'); | ||
|
||
// Expect second type data to be set | ||
await expectToBe(page, 'msg: ok', 'div[id=result-union-model-b]'); | ||
}); | ||
}); |