-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
2e32829
commit 9772678
Showing
39 changed files
with
310 additions
and
364 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"baseUrl": "http:https://localhost:1336", | ||
"fileServerFolder": ".", | ||
"fixturesFolder": "../../shared/types/src/fixtures", | ||
"integrationFolder": "./cypress/integration", | ||
"modifyObstructiveCode": false, | ||
"supportFile": "./cypress/support/index.ts", | ||
"screenshotOnRunFailure": true, | ||
"trashAssetsBeforeRuns": true, | ||
"video": true, | ||
"videosFolder": "./cypress/dist/videos", | ||
"screenshotsFolder": "./cypress/dist/screenshots", | ||
"chromeWebSecurity": false, | ||
"projectId": "3mcgfk" | ||
} |
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,71 @@ | ||
import { contactsFixture, authFixture, ContactType, IContact } from '@fake-company/types'; | ||
|
||
describe('mutations', () => { | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
cy.intercept('GET', '/api/auth', authFixture); | ||
cy.intercept('GET', '/api/contacts/*', (req) => | ||
req.reply(contactsFixture.find(({ id }) => id === req.url.split('/').pop()) as IContact) | ||
); | ||
}); | ||
|
||
it('should add a contact', () => { | ||
cy.intercept('GET', '/api/contacts', contactsFixture); | ||
cy.intercept('POST', '/api/contacts', { | ||
id: '9478e897-5731-4fa2-a2dc-7c1adccc53a2', | ||
name: 'Foo Bar Baz', | ||
rating: 5, | ||
type: ContactType.Client | ||
}); | ||
|
||
cy.findAllByRole('button', { name: 'Add Contacts' }).first().click(); | ||
|
||
cy.url().should('equal', 'http:https://localhost:1336/admin/add'); | ||
|
||
cy.findByRole('button', { name: 'Submit' }).should('be.disabled'); | ||
cy.findByRole('textbox').type('Foo Bar'); | ||
cy.findByRole('textbox').clear(); | ||
cy.findByText('Name is a required field.').should('exist'); | ||
cy.findByRole('textbox').type('Foo Bar Baz'); | ||
cy.findByTestId('type').click(); | ||
cy.findAllByRole('option').first().click(); | ||
cy.findByRole('button', { name: 'Submit' }).click(); | ||
|
||
cy.url().should('equal', 'http:https://localhost:1336/admin/'); | ||
}); | ||
|
||
it('should edit a contact', () => { | ||
cy.intercept('GET', '/api/contacts', contactsFixture); | ||
cy.intercept('PUT', '/api/contacts', { ...contactsFixture[0], name: 'Foo Bar' }); | ||
|
||
cy.findAllByRole('button', { name: 'Edit' }).first().click(); | ||
|
||
cy.url().should('equal', 'http:https://localhost:1336/admin/edit/89222b2d-8d06-41ff-82cf-c989dd90de24'); | ||
|
||
cy.findByRole('textbox').clear(); | ||
cy.findByText('Name is a required field.').should('exist'); | ||
cy.findByRole('button', { name: 'Submit' }).should('be.disabled'); | ||
cy.findByRole('textbox').type('Foo Bar'); | ||
cy.findByRole('button', { name: 'Submit' }).click(); | ||
|
||
cy.url().should('equal', 'http:https://localhost:1336/admin/'); | ||
}); | ||
|
||
it('should delete a contact', () => { | ||
let interceptCount = 0; | ||
|
||
cy.intercept('DELETE', '/api/contacts/89222b2d-8d06-41ff-82cf-c989dd90de24', { statusCode: 200 }); | ||
cy.intercept('/api/contacts', (req) => { | ||
if (interceptCount === 0) { | ||
interceptCount += 1; | ||
req.reply(contactsFixture); | ||
} else { | ||
req.reply(contactsFixture.filter(({ id }) => id !== '89222b2d-8d06-41ff-82cf-c989dd90de24')); | ||
} | ||
}); | ||
|
||
cy.findAllByRole('button', { name: 'Delete' }).first().click(); | ||
cy.wait(2000); | ||
cy.findByRole('row', { name: 'Chad Williams' }).should('not.exist'); | ||
}); | ||
}); |
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,34 @@ | ||
import { contactsFixture, authFixture, IContact } from '@fake-company/types'; | ||
|
||
describe('queries', () => { | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
cy.intercept('GET', '/api/auth', authFixture); | ||
cy.intercept('GET', '/api/contacts/*', (req) => | ||
req.reply(contactsFixture.find(({ id }) => id === req.url.split('/').pop()) as IContact) | ||
); | ||
cy.intercept('GET', '/api/contacts', contactsFixture); | ||
}); | ||
|
||
it('should contain app name in toolbar', () => { | ||
cy.findByRole('heading').should('contain', 'Admin'); | ||
}); | ||
|
||
it('should have some nav links', () => { | ||
cy.findAllByRole('button', { name: 'View Contacts' }).should('exist'); | ||
cy.findAllByRole('button', { name: 'Add Contacts' }).should('exist'); | ||
}); | ||
|
||
it('should have have a table with contacts', () => { | ||
cy.findByRole('table', { name: 'simple table' }).should('exist'); | ||
cy.findAllByRole('link').should('have.length', 5); | ||
cy.findAllByRole('row').first().should('contain', 'Type'); | ||
}); | ||
|
||
it('should allow you to view a single contact', () => { | ||
cy.findAllByRole('link').last().click(); | ||
cy.url().should('equal', 'http:https://localhost:1336/admin/fd546b4e-747d-448f-abaf-b0d119bae119'); | ||
cy.findByText('Chloe Martinez').should('exist'); | ||
cy.findByText('Customer').should('exist'); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
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 @@ | ||
import '@testing-library/cypress/add-commands'; |
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 @@ | ||
import './commands'; |
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,7 @@ | ||
{ | ||
"extends": "../../../tsconfig.app.json", | ||
"compilerOptions": { | ||
"sourceMap": false | ||
}, | ||
"include": ["**/*.ts", "**/*.js"] | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"baseUrl": "http:https://localhost:1337", | ||
"fileServerFolder": ".", | ||
"fixturesFolder": "../../shared/types/src/fixtures", | ||
"integrationFolder": "./cypress/integration", | ||
"modifyObstructiveCode": false, | ||
"supportFile": "./cypress/support/index.ts", | ||
"screenshotOnRunFailure": true, | ||
"trashAssetsBeforeRuns": true, | ||
"video": true, | ||
"videosFolder": "./cypress/dist/videos", | ||
"screenshotsFolder": "./cypress/dist/screenshots", | ||
"chromeWebSecurity": false, | ||
"projectId": "73ueoy" | ||
} |
Oops, something went wrong.