-
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.
- Loading branch information
Showing
9 changed files
with
446 additions
and
24 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,43 @@ | ||
import { | ||
Mountebank, | ||
Imposter, | ||
HttpMethod, | ||
Stub, | ||
EqualPredicate, | ||
Response, | ||
} from '@anev/ts-mountebank'; | ||
|
||
const PORT = 2126; | ||
|
||
const HTML = ` | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
Hello world! | ||
</body> | ||
</html> | ||
`; | ||
|
||
export class FakeAuthProvider { | ||
private readonly _mountebank = new Mountebank().withURL('http://localhost:2125'); | ||
private readonly _imposter = new Imposter().withPort(PORT); | ||
|
||
public async setup(): Promise<void> { | ||
const authorizeStub = new Stub() | ||
.withPredicate(new EqualPredicate().withMethod(HttpMethod.GET).withPath('/authorize')) | ||
.withResponse( | ||
new Response().withStatusCode(200).withHeader('Content-Type', 'text/html').withBody(HTML), | ||
); | ||
|
||
await this._mountebank.createImposter(this._imposter.withStub(authorizeStub)); | ||
} | ||
|
||
public async teardown(): Promise<void> { | ||
await this._mountebank.deleteImposter(PORT); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,21 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { FakeAuthProvider } from '../fakeAuth'; | ||
|
||
let fakeAuth: FakeAuthProvider | null = null; | ||
|
||
test.beforeEach(async () => { | ||
fakeAuth = new FakeAuthProvider(); | ||
await fakeAuth.setup(); | ||
}); | ||
|
||
test.afterEach(async () => { | ||
await fakeAuth?.teardown(); | ||
}); | ||
|
||
test('should display sign in page', async ({ page }) => { | ||
await page.goto('https://localhost:10000'); | ||
await page.goto('https://localhost:8080'); | ||
|
||
await page.getByRole('button', { name: /sign in with google/i }).click(); | ||
|
||
await expect(page.getByRole('button', { name: /sign in with google/i })).toBeVisible(); | ||
await expect(page.getByText(/hello world/i)).toBeVisible(); | ||
}); |
Oops, something went wrong.