-
Notifications
You must be signed in to change notification settings - Fork 648
Migrate from ember-cli-mirage
to msw
and @mswjs/data
#10393
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
Merged
Merged
Changes from all commits
Commits
Show all changes
189 commits
Select commit
Hold shift + click to select a range
80d3823
git: Ignore *all* `node_modules` folders
Turbo87 e884806
Add basic `@crates-io/msw` package
Turbo87 5f94902
msw: Add `@mswjs/data` mock database
Turbo87 62238a9
msw: Extract custom `factory()` fn
Turbo87 7b4ca78
msw: Add support for `preCreate()` fns
Turbo87 47f2840
msw: Add support for `counter` values to the models
Turbo87 42e2007
msw: Extract `db.reset()` fn
Turbo87 15dbb4b
msw: Import `dasherize()` fn from `@ember/string`
Turbo87 bc236e9
msw: Implement `category` model
Turbo87 ccb4cef
msw: Implement `keyword` model
Turbo87 8894455
msw: Implement `crate` model
Turbo87 61a9a03
msw: Implement `user` model
Turbo87 31ddd22
msw: Implement `mswSession` model
Turbo87 e1237f7
msw: Implement `apiToken` model
Turbo87 a5f3281
msw: Implement `team` model
Turbo87 36b0bb0
msw: Implement `version` model
Turbo87 1a468d5
msw: Implement `versionDownload` model
Turbo87 c7d595f
msw: Implement `crateOwnerInvitation` model
Turbo87 3678f88
msw: Implement `crateOwnership` model
Turbo87 2a4f94f
msw: Implement `dependency` model
Turbo87 0abb0dd
msw: Import `underscore()` fn from `@ember/string`
Turbo87 2d325e4
msw: Implement basic `serializeModel()` fn
Turbo87 74245ce
msw: Implement `category` serializer
Turbo87 a931e55
msw: Implement `keyword` serializer
Turbo87 8403d00
msw: Implement `team` serializer
Turbo87 a455550
msw: Implement `user` serializer
Turbo87 aa45a7c
msw: Implement `invite` serializer
Turbo87 990f853
msw: Implement `api-token` serializer
Turbo87 70eabf2
msw: Implement `crate` serializer
Turbo87 c85158f
msw: Implement `version` serializer
Turbo87 404e209
msw: Implement `dependency` serializer
Turbo87 7dd2952
msw: Implement `getSession()` helper fn
Turbo87 2ebe678
msw: Implement docs.rs request handler
Turbo87 4c0ef9b
msw: Implement `GET /api/v1/categories` request handler
Turbo87 36170ae
msw: Implement `GET /api/v1/category_slugs` request handler
Turbo87 571ff2e
msw: Implement `GET /api/v1/categories/:category_id` request handler
Turbo87 ef202e4
msw: Implement `GET /api/v1/keywords` request handler
Turbo87 4c6eb08
msw: Implement `GET /api/v1/keywords/:keyword_id` request handler
Turbo87 ab1b1d5
msw: Implement `DELETE /api/private/session` request handler
Turbo87 14839ec
msw: Implement `GET /api/v1/site_metadata` request handler
Turbo87 3462a1a
msw: Implement `GET /api/v1/teams/:team_id` request handler
Turbo87 bc1e4a5
msw: Implement `GET /api/v1/users/:user_id` request handler
Turbo87 c537922
msw: Implement `PUT /api/v1/users/:user_id` request handler
Turbo87 11edd81
msw: Implement `PUT /api/v1/users/:user_id/resend` request handler
Turbo87 0329a77
msw: Implement `GET /api/v1/me` request handler
Turbo87 125687b
msw: Implement `GET /api/private/crate_owner_invitations` request han…
Turbo87 f207e28
msw: Implement `GET /api/v1/me/crate_owner_invitations` request handler
Turbo87 48db714
msw: Implement `PUT /api/v1/me/crate_owner_invitations/:crate_id` req…
Turbo87 8d57606
msw: Implement `PUT /api/v1/me/crate_owner_invitations/accept/:token`…
Turbo87 8df29aa
msw: Implement `PUT /api/v1/confirm/:token` request handler
Turbo87 a91fff1
msw: Implement `PUT /api/v1/me/tokens` request handler
Turbo87 3abeb17
msw: Implement `GET /api/v1/me/tokens` request handler
Turbo87 20d7f46
msw: Implement `DELETE /api/v1/me/tokens/:tokenId` request handler
Turbo87 59105c0
msw: Implement `GET /api/v1/me/tokens/:tokenId` request handler
Turbo87 f0da1a2
msw: Implement `GET /api/v1/crates` request handler
Turbo87 c26e091
msw: Implement `GET /api/v1/crates/:name` request handler
Turbo87 cb91248
msw: Implement `GET /api/v1/crates/:name/versions` request handler
Turbo87 68a3f8d
msw: Implement `GET /api/v1/crates/:name/:version` request handler
Turbo87 87e1a9f
msw: Implement `DELETE /api/v1/crates/:name` request handler
Turbo87 cbe86e2
msw: Implement `GET /api/v1/crates/:name/following` request handler
Turbo87 4206f5a
msw: Implement `PUT /api/v1/crates/:name/follow` request handler
Turbo87 e2fbce4
msw: Implement `DELETE /api/v1/crates/:name/follow` request handler
Turbo87 def0e95
msw: Implement `GET /api/v1/crates/:name/:version/dependencies` reque…
Turbo87 f2cd3d9
msw: Implement `GET /api/v1/crates/:name/:version/downloads` request …
Turbo87 56334bb
msw: Implement `GET /api/v1/crates/:name/owner_user` request handler
Turbo87 8024266
msw: Implement `GET /api/v1/crates/:name/owner_team` request handler
Turbo87 9bbc9b7
msw: Implement `GET /api/v1/crates/:name/downloads` request handler
Turbo87 29a5005
msw: Implement `GET /api/v1/crates/:name/reverse_dependencies` reques…
Turbo87 69ca1ae
msw: Implement `PUT /api/v1/crates/:name/owners` request handler
Turbo87 b2aab7f
msw: Implement `DELETE /api/v1/crates/:name/owners` request handler
Turbo87 1b168a8
msw: Implement `DELETE /api/v1/crates/:name/:version/yank` request ha…
Turbo87 b15d71c
msw: Implement `PUT /api/v1/crates/:name/:version/unyank` request han…
Turbo87 4ff2177
msw: Implement `GET /api/v1/crates/:name/:version/readme` request han…
Turbo87 81573a1
msw: Implement `PATCH /api/v1/crates/:name/:version` request handler
Turbo87 26434dd
msw: Implement `GET /api/v1/me/updates` request handler
Turbo87 14d7481
msw: Implement `GET /api/v1/summary` request handler
Turbo87 f7ea672
msw: Implement play.rust-lang.org request handler
Turbo87 583fe8e
msw: Import existing fixtures
Turbo87 4aac5e9
msw: Serve `mockServiceWorker.js` in dev/test mode
Turbo87 62c540c
msw: Add `msw: true` option to `setupApplicationTest()` fn
Turbo87 2e3f7c3
msw: Prevent `@mswjs/data` from bundling the `msw` package
Turbo87 d2474d9
tests/acceptance/api-token: Migrate from `mirage` to `@crates-io/msw`
Turbo87 8ff81d9
tests/acceptance/readme-rendering: Migrate from `mirage` to `@crates-…
Turbo87 6bcd319
tests/acceptance/front-page: Migrate from `mirage` to `@crates-io/msw`
Turbo87 0987e36
tests/acceptance/settings/add-owner: Migrate from `mirage` to `@crate…
Turbo87 24e48ef
tests/acceptance/settings/remove-owner: Migrate from `mirage` to `@cr…
Turbo87 2baf29d
tests/acceptance/404: Migrate from `mirage` to `@crates-io/msw`
Turbo87 3371f29
tests/acceptance/categories: Migrate from `mirage` to `@crates-io/msw`
Turbo87 a8ba731
tests/acceptance/crate-deletion: Migrate from `mirage` to `@crates-io…
Turbo87 a377ba1
tests/acceptance/crate-dependencies: Migrate from `mirage` to `@crate…
Turbo87 e558342
tests/acceptance/crate-following: Migrate from `mirage` to `@crates-i…
Turbo87 4515e1a
tests/acceptance/crate-navtabs: Migrate from `mirage` to `@crates-io/…
Turbo87 d6c7a06
tests/acceptance/crate: Migrate from `mirage` to `@crates-io/msw`
Turbo87 52afee6
tests/acceptance/crates: Migrate from `mirage` to `@crates-io/msw`
Turbo87 bdd6b7a
tests/acceptance/dashboard: Migrate from `mirage` to `@crates-io/msw`
Turbo87 b7e8b4e
tests/acceptance/dev-mode: Migrate from `mirage` to `@crates-io/msw`
Turbo87 7ad14f9
tests/acceptance/email-change: Migrate from `mirage` to `@crates-io/msw`
Turbo87 5d55d78
tests/acceptance/email-confirmation: Migrate from `mirage` to `@crate…
Turbo87 489577d
tests/acceptance/invites: Migrate from `mirage` to `@crates-io/msw`
Turbo87 5ac2ac7
tests/acceptance/keyword: Migrate from `mirage` to `@crates-io/msw`
Turbo87 2e5d704
tests/acceptance/login: Migrate from `mirage` to `@crates-io/msw`
Turbo87 f4e1fec
tests/acceptance/logout: Migrate from `mirage` to `@crates-io/msw`
Turbo87 d613e24
tests/acceptance/publish-notifications: Migrate from `mirage` to `@cr…
Turbo87 ad2f7b3
tests/acceptance/read-only-mode: Migrate from `mirage` to `@crates-io…
Turbo87 cbbf385
tests/acceptance/reverse-dependencies: Migrate from `mirage` to `@cra…
Turbo87 df2da96
tests/acceptance/search: Migrate from `mirage` to `@crates-io/msw`
Turbo87 6d86ab9
tests/acceptance/sudo: Migrate from `mirage` to `@crates-io/msw`
Turbo87 b29f320
tests/acceptance/support: Migrate from `mirage` to `@crates-io/msw`
Turbo87 5786e2d
tests/acceptance/team-page: Migrate from `mirage` to `@crates-io/msw`
Turbo87 3642278
tests/acceptance/token-invites: Migrate from `mirage` to `@crates-io/…
Turbo87 bbcbcdf
tests/acceptance/user-page: Migrate from `mirage` to `@crates-io/msw`
Turbo87 68a5ef8
tests/acceptance/versions: Migrate from `mirage` to `@crates-io/msw`
Turbo87 c8a64a0
tests/acceptance/settings: Migrate from `mirage` to `@crates-io/msw`
Turbo87 72481d9
tests/bugs/2329: Migrate from `mirage` to `@crates-io/msw`
Turbo87 679cc45
tests/bugs/4506: Migrate from `mirage` to `@crates-io/msw`
Turbo87 b4b458c
tests/routes/crate/version/crate-links: Migrate from `mirage` to `@cr…
Turbo87 a10fda0
tests/routes/crate/version/docs-link: Migrate from `mirage` to `@crat…
Turbo87 581a82f
tests/routes/crate/version/model: Migrate from `mirage` to `@crates-i…
Turbo87 e879541
tests/routes/crate/delete: Migrate from `mirage` to `@crates-io/msw`
Turbo87 090faf8
tests/routes/crate/range: Migrate from `mirage` to `@crates-io/msw`
Turbo87 e13525d
tests/routes/settings/tokens: Migrate from `mirage` to `@crates-io/msw`
Turbo87 7fbfb75
tests/routes/category: Migrate from `mirage` to `@crates-io/msw`
Turbo87 733eb4f
tests/routes/keyword: Migrate from `mirage` to `@crates-io/msw`
Turbo87 cb20fb8
tests/routes/support: Migrate from `mirage` to `@crates-io/msw`
Turbo87 38c1e48
tests/routes/team: Migrate from `mirage` to `@crates-io/msw`
Turbo87 bec3ce7
tests/routes/user: Migrate from `mirage` to `@crates-io/msw`
Turbo87 e270add
tests/adapters/crate: Migrate from `mirage` to `@crates-io/msw`
Turbo87 c2474e9
tests/components/crate-sidebar/playground-button: Migrate from `mirag…
Turbo87 03dd0fe
tests/components/crate-sidebar/toml-snippet: Migrate from `mirage` to…
Turbo87 088f841
tests/components/crate-row: Migrate from `mirage` to `@crates-io/msw`
Turbo87 2372611
tests/components/owners-list: Migrate from `mirage` to `@crates-io/msw`
Turbo87 4b420e4
tests/components/privileged-action: Migrate from `mirage` to `@crates…
Turbo87 7bafdc5
tests/components/version-list-row: Migrate from `mirage` to `@crates-…
Turbo87 d3b2897
tests/models/crate: Migrate from `mirage` to `@crates-io/msw`
Turbo87 9fb9eb2
tests/models/user: Migrate from `mirage` to `@crates-io/msw`
Turbo87 a87766b
tests/models/version: Migrate from `mirage` to `@crates-io/msw`
Turbo87 9d1e84e
tests/services/playground: Migrate from `mirage` to `@crates-io/msw`
Turbo87 7e62fae
tests/utils/ajax: Migrate from `mirage` to `@crates-io/msw`
Turbo87 3685a95
CI: Run `@crates-io/msw` tests in dedicated job
Turbo87 a6e4c9a
mirage: Start `ember-cli-mirage` server only if `window.startMirage` …
Turbo87 d366c39
playwright: Disable `mirage` fixture from being applied automatically
Turbo87 febc17b
playwright: Set default `locale` to `en-US`
Turbo87 55e0873
playwright: Implement basic `defer()` fn
Turbo87 d3dd235
playwright: Implement `msw` fixture
Turbo87 fe40d9c
playwright: Use `@sinonjs/fake-timers` on the test runner side too
Turbo87 ab27271
e2e/acceptance/front-page: Migrate from `mirage` to `@crates-io/msw`
Turbo87 7fe47e4
e2e/acceptance/settings/add-owner: Migrate from `mirage` to `@crates-…
Turbo87 3748f6f
e2e/acceptance/settings/remove-owner: Migrate from `mirage` to `@crat…
Turbo87 24369f8
e2e/acceptance/settings/settings: Migrate from `mirage` to `@crates-i…
Turbo87 aa884d7
e2e/acceptance/api-token: Migrate from `mirage` to `@crates-io/msw`
Turbo87 1eeb54e
e2e/acceptance/categories: Migrate from `mirage` to `@crates-io/msw`
Turbo87 917557a
e2e/acceptance/crate: Migrate from `mirage` to `@crates-io/msw`
Turbo87 cf8cec9
e2e/acceptance/crate-deletion: Migrate from `mirage` to `@crates-io/msw`
Turbo87 4c1a947
e2e/acceptance/crate-dependencies: Migrate from `mirage` to `@crates-…
Turbo87 60e4b5e
e2e/acceptance/crate-following: Migrate from `mirage` to `@crates-io/…
Turbo87 d7baf9f
e2e/acceptance/crate-navtabs: Migrate from `mirage` to `@crates-io/msw`
Turbo87 de1e94a
e2e/acceptance/crates: Migrate from `mirage` to `@crates-io/msw`
Turbo87 f8498a9
e2e/acceptance/dashboard: Migrate from `mirage` to `@crates-io/msw`
Turbo87 0d0a068
e2e/acceptance/email-change: Migrate from `mirage` to `@crates-io/msw`
Turbo87 8a43670
e2e/acceptance/email-confirmation: Migrate from `mirage` to `@crates-…
Turbo87 55648e1
e2e/acceptance/invites: Migrate from `mirage` to `@crates-io/msw`
Turbo87 7f9a388
e2e/acceptance/keyword: Migrate from `mirage` to `@crates-io/msw`
Turbo87 340e3be
e2e/acceptance/login: Migrate from `mirage` to `@crates-io/msw`
Turbo87 4020722
e2e/acceptance/logout: Migrate from `mirage` to `@crates-io/msw`
Turbo87 d26562c
e2e/acceptance/publish-notifications: Migrate from `mirage` to `@crat…
Turbo87 331eb63
e2e/acceptance/read-only: Migrate from `mirage` to `@crates-io/msw`
Turbo87 fa7bc92
e2e/acceptance/readme-rendering: Migrate from `mirage` to `@crates-io…
Turbo87 234756e
e2e/acceptance/reverse-dependencies: Migrate from `mirage` to `@crate…
Turbo87 eb1e267
e2e/acceptance/search: Migrate from `mirage` to `@crates-io/msw`
Turbo87 1f7c914
e2e/acceptance/sudo: Migrate from `mirage` to `@crates-io/msw`
Turbo87 63236b3
e2e/acceptance/support: Migrate from `mirage` to `@crates-io/msw`
Turbo87 525c2ce
e2e/acceptance/team-page: Migrate from `mirage` to `@crates-io/msw`
Turbo87 e65e192
e2e/acceptance/token-invites: Migrate from `mirage` to `@crates-io/msw`
Turbo87 9702df6
e2e/acceptance/user-page: Migrate from `mirage` to `@crates-io/msw`
Turbo87 58818a9
e2e/acceptance/versions: Migrate from `mirage` to `@crates-io/msw`
Turbo87 8ef87d3
e2e/bugs/2329: Migrate from `mirage` to `@crates-io/msw`
Turbo87 858182a
e2e/bugs/4506: Migrate from `mirage` to `@crates-io/msw`
Turbo87 68be0b4
e2e/routes/category: Migrate from `mirage` to `@crates-io/msw`
Turbo87 2423995
e2e/routes/crate/delete: Migrate from `mirage` to `@crates-io/msw`
Turbo87 c459b0e
e2e/routes/crate/range: Migrate from `mirage` to `@crates-io/msw`
Turbo87 9bc8b57
e2e/routes/crate/version/crate-links: Migrate from `mirage` to `@crat…
Turbo87 06542cc
e2e/routes/crate/version/docs-link: Migrate from `mirage` to `@crates…
Turbo87 ac446e5
e2e/routes/crate/version/model: Migrate from `mirage` to `@crates-io/…
Turbo87 4eaf3db
e2e/routes/keyword: Migrate from `mirage` to `@crates-io/msw`
Turbo87 b710303
e2e/routes/settings/tokens/index: Migrate from `mirage` to `@crates-i…
Turbo87 1ea2da8
e2e/routes/settings/tokens/new: Migrate from `mirage` to `@crates-io/…
Turbo87 a309609
e2e/routes/team: Migrate from `mirage` to `@crates-io/msw`
Turbo87 c34c9df
e2e/routes/user: Migrate from `mirage` to `@crates-io/msw`
Turbo87 a328a12
Remove obsolete `ember-cli-mirage` setup
Turbo87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/tmp | ||
|
||
# dependencies | ||
/node_modules | ||
node_modules/ | ||
/bower_components | ||
package-lock.json | ||
yarn.lock | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
import { test, expect } from '@/e2e/helper'; | ||
import { expect, test } from '@/e2e/helper'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
test.describe('Acceptance | api-tokens', { tag: '@acceptance' }, () => { | ||
test.beforeEach(async ({ mirage }) => { | ||
await mirage.addHook(server => { | ||
let user = server.create('user', { | ||
login: 'johnnydee', | ||
name: 'John Doe', | ||
email: '[email protected]', | ||
avatar: 'https://avatars2.githubusercontent.com/u/1234567?v=4', | ||
}); | ||
server.create('api-token', { | ||
user, | ||
name: 'BAR', | ||
createdAt: '2017-11-19T17:59:22', | ||
lastUsedAt: null, | ||
expiredAt: '2017-12-19T17:59:22', | ||
}); | ||
|
||
server.create('api-token', { | ||
user, | ||
name: 'recently expired', | ||
createdAt: '2017-08-01T12:34:56', | ||
lastUsedAt: '2017-11-02T01:45:14', | ||
expiredAt: '2017-11-19T17:59:22', | ||
}); | ||
server.create('api-token', { | ||
user, | ||
name: 'foo', | ||
createdAt: '2017-08-01T12:34:56', | ||
lastUsedAt: '2017-11-02T01:45:14', | ||
}); | ||
|
||
globalThis.authenticateAs(user); | ||
test.beforeEach(async ({ msw }) => { | ||
let user = msw.db.user.create({ | ||
login: 'johnnydee', | ||
name: 'John Doe', | ||
email: '[email protected]', | ||
avatar: 'https://avatars2.githubusercontent.com/u/1234567?v=4', | ||
}); | ||
msw.db.apiToken.create({ | ||
user, | ||
name: 'BAR', | ||
createdAt: '2017-11-19T17:59:22', | ||
lastUsedAt: null, | ||
expiredAt: '2017-12-19T17:59:22', | ||
}); | ||
|
||
msw.db.apiToken.create({ | ||
user, | ||
name: 'recently expired', | ||
createdAt: '2017-08-01T12:34:56', | ||
lastUsedAt: '2017-11-02T01:45:14', | ||
expiredAt: '2017-11-19T17:59:22', | ||
}); | ||
msw.db.apiToken.create({ | ||
user, | ||
name: 'foo', | ||
createdAt: '2017-08-01T12:34:56', | ||
lastUsedAt: '2017-11-02T01:45:14', | ||
}); | ||
|
||
await msw.authenticateAs(user); | ||
}); | ||
|
||
test('/me is showing the list of active API tokens', async ({ page }) => { | ||
|
@@ -72,16 +71,13 @@ test.describe('Acceptance | api-tokens', { tag: '@acceptance' }, () => { | |
await expect(row3.locator('[data-test-token]')).toHaveCount(0); | ||
}); | ||
|
||
test('API tokens can be revoked', async ({ page }) => { | ||
test('API tokens can be revoked', async ({ page, msw }) => { | ||
await page.goto('/settings/tokens'); | ||
await expect(page).toHaveURL('/settings/tokens'); | ||
await expect(page.locator('[data-test-api-token]')).toHaveCount(3); | ||
|
||
await page.click('[data-test-api-token="1"] [data-test-revoke-token-button]'); | ||
expect( | ||
await page.evaluate(() => server.schema['apiTokens'].all().length), | ||
'API token has been deleted from the backend database', | ||
).toBe(2); | ||
expect(msw.db.apiToken.findMany({}).length, 'API token has been deleted from the backend database').toBe(2); | ||
|
||
await expect(page.locator('[data-test-api-token]')).toHaveCount(2); | ||
await expect(page.locator('[data-test-api-token="2"]')).toBeVisible(); | ||
|
@@ -97,12 +93,10 @@ test.describe('Acceptance | api-tokens', { tag: '@acceptance' }, () => { | |
await expect(page).toHaveURL('/settings/tokens/new?from=1'); | ||
}); | ||
|
||
test('failed API tokens revocation shows an error', async ({ page, mirage }) => { | ||
await mirage.addHook(server => { | ||
server.delete('/api/v1/me/tokens/:id', {}, 500); | ||
}); | ||
test('failed API tokens revocation shows an error', async ({ page, msw }) => { | ||
await msw.worker.use(http.delete('/api/v1/me/tokens/:id', () => HttpResponse.json({}, { status: 500 }))); | ||
|
||
await mirage.page.goto('/settings/tokens'); | ||
await page.goto('/settings/tokens'); | ||
await expect(page).toHaveURL('/settings/tokens'); | ||
await expect(page.locator('[data-test-api-token]')).toHaveCount(3); | ||
|
||
|
@@ -115,7 +109,7 @@ test.describe('Acceptance | api-tokens', { tag: '@acceptance' }, () => { | |
); | ||
}); | ||
|
||
test('new API tokens can be created', async ({ page, percy }) => { | ||
test('new API tokens can be created', async ({ page, percy, msw }) => { | ||
await page.goto('/settings/tokens'); | ||
await expect(page).toHaveURL('/settings/tokens'); | ||
await expect(page.locator('[data-test-api-token]')).toHaveCount(3); | ||
|
@@ -129,7 +123,7 @@ test.describe('Acceptance | api-tokens', { tag: '@acceptance' }, () => { | |
|
||
await page.click('[data-test-generate]'); | ||
|
||
let token = await page.evaluate(() => server.schema['apiTokens'].findBy({ name: 'the new token' })?.token); | ||
let token = msw.db.apiToken.findFirst({ where: { name: { equals: 'the new token' } } })?.token; | ||
expect(token, 'API token has been created in the backend database').toBeTruthy(); | ||
|
||
await expect(page.locator('[data-test-api-token="4"] [data-test-name]')).toHaveText('the new token'); | ||
|
@@ -140,14 +134,14 @@ test.describe('Acceptance | api-tokens', { tag: '@acceptance' }, () => { | |
await expect(page.locator('[data-test-token]')).toHaveText(token); | ||
}); | ||
|
||
test('API tokens are only visible in plaintext until the page is left', async ({ page }) => { | ||
test('API tokens are only visible in plaintext until the page is left', async ({ page, msw }) => { | ||
await page.goto('/settings/tokens'); | ||
await page.click('[data-test-new-token-button]'); | ||
await page.fill('[data-test-name]', 'the new token'); | ||
await page.click('[data-test-scope="publish-update"]'); | ||
await page.click('[data-test-generate]'); | ||
|
||
let token = await page.evaluate(() => server.schema['apiTokens'].findBy({ name: 'the new token' })?.token); | ||
let token = msw.db.apiToken.findFirst({ where: { name: { equals: 'the new token' } } })?.token; | ||
await expect(page.locator('[data-test-token]')).toHaveText(token); | ||
|
||
// leave the API tokens page | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.