Skip to content

Commit

Permalink
test: update cli test to use cognito user
Browse files Browse the repository at this point in the history
  • Loading branch information
Hein Jeong authored and hein-j committed Dec 19, 2022
1 parent 2dc66ee commit 4948b2e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/canaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ jobs:
wait-on: 'http://localhost:3000'
wait-on-timeout: 120
config-file: cypress.config.js

env:
REACT_APP_USER_EMAIL: ${{ secrets.E2E_TEST_USER_EMAIL }}
REACT_APP_USER_PASSWORD: ${{ secrets.E2E_TEST_USER_PASSWORD }}
write-beta-canary-failure-metric:
runs-on: ubuntu-latest
needs: beta-canary
Expand Down Expand Up @@ -123,7 +125,9 @@ jobs:
wait-on: 'http://localhost:3000'
wait-on-timeout: 120
config-file: cypress.config.js

env:
REACT_APP_USER_EMAIL: ${{ secrets.E2E_TEST_USER_EMAIL }}
REACT_APP_USER_PASSWORD: ${{ secrets.E2E_TEST_USER_PASSWORD }}
write-release-canary-failure-metric:
runs-on: ubuntu-latest
needs: release-canary
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ jobs:
wait-on: 'http://localhost:3000'
wait-on-timeout: 120
config-file: cypress.config.js
env:
REACT_APP_USER_EMAIL: ${{ secrets.E2E_TEST_USER_EMAIL }}
REACT_APP_USER_PASSWORD: ${{ secrets.E2E_TEST_USER_PASSWORD }}

functional-tests:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ describe('e2e-tests', () => {
});

it('renders datastore collection', () => {
// wait to log in
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(4000);
cy.get('#blogPosts').contains('Working on E2E Tests');
});
});
30 changes: 24 additions & 6 deletions packages/test-generator/e2e-test-templates/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,38 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
import { Amplify } from 'aws-amplify';
import { Amplify, Auth } from 'aws-amplify';
import '@aws-amplify/ui-react/styles.css';
import { AmplifyProvider } from '@aws-amplify/ui-react';
import { useEffect, useRef, useState } from 'react';
import awsconfig from './aws-exports';
import { BlogPosts } from './ui-components';

Amplify.configure(awsconfig);

function App() {
return (
<AmplifyProvider>
<BlogPosts id="blogPosts" />
</AmplifyProvider>
);
const [isLoggedIn, setIsLoggedIn] = useState(false);
const initialized = useRef(false);

useEffect(() => {
if (initialized.current) {
return;
}
initialized.current = true;
Auth.signIn(process.env.REACT_APP_USER_EMAIL, process.env.REACT_APP_USER_PASSWORD).then(() => {
setIsLoggedIn(true);
});
}, []);

if (isLoggedIn) {
return (
<AmplifyProvider>
<BlogPosts id="blogPosts" />
</AmplifyProvider>
);
}

return null;
}

export default App;

0 comments on commit 4948b2e

Please sign in to comment.